Whamcloud - gitweb
LU-1200 build: check page_mkwrite parameter
[fs/lustre-release.git] / lustre / autoconf / lustre-core.m4
index 63861c4..b1ef9c2 100644 (file)
@@ -49,68 +49,103 @@ esac
 ])
 
 #
-# Ensure stack size big than 8k in Lustre server (all kernels)
+# LC_CONFIG_OBD_BUFFER_SIZE
 #
-AC_DEFUN([LC_STACK_SIZE],
-[AC_MSG_CHECKING([stack size big than 8k])
-LB_LINUX_TRY_COMPILE([
-       #include <linux/thread_info.h>
+# the maximum buffer size of lctl ioctls
+#
+AC_DEFUN([LC_CONFIG_OBD_BUFFER_SIZE],
+[AC_MSG_CHECKING([maximum OBD ioctl size])
+AC_ARG_WITH([obd-buffer-size],
+       AC_HELP_STRING([--with-obd-buffer-size=[size]],
+                       [set lctl ioctl maximum bytes (default=8192)]),
+       [
+               OBD_BUFFER_SIZE=$with_obd_buffer_size
+       ],[
+               OBD_BUFFER_SIZE=8192
+       ])
+AC_MSG_RESULT([$OBD_BUFFER_SIZE bytes])
+AC_DEFINE_UNQUOTED(OBD_MAX_IOCTL_BUFFER, $OBD_BUFFER_SIZE, [IOCTL Buffer Size])
+])
+
+#
+# LC_READLINK_SSIZE_T
+#
+AC_DEFUN([LC_READLINK_SSIZE_T],
+[AC_MSG_CHECKING([if readlink returns ssize_t])
+AC_TRY_COMPILE([
+       #include <unistd.h>
 ],[
-        #if THREAD_SIZE < 8192
-        #error "stack size < 8192"
-        #endif
+       ssize_t readlink(const char *, char *, size_t);
 ],[
-        AC_MSG_RESULT(yes)
+       AC_MSG_RESULT([yes])
+       AC_DEFINE(HAVE_POSIX_1003_READLINK, 1, [readlink returns ssize_t])
 ],[
-        AC_MSG_ERROR([Lustre requires that Linux is configured with at least a 8KB stack.])
+       AC_MSG_RESULT([no])
+])
+])
+
+#
+# only for Lustre-patched kernels
+#
+AC_DEFUN([LC_LUSTRE_VERSION_H],
+[LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
+       rm -f "$LUSTRE/include/linux/lustre_version.h"
+],[
+       touch "$LUSTRE/include/linux/lustre_version.h"
+       if test x$enable_server = xyes ; then
+               AC_MSG_WARN([Unpatched kernel detected.])
+               AC_MSG_WARN([Lustre servers cannot be built with an unpatched kernel;])
+               AC_MSG_WARN([disabling server build])
+               enable_server='no'
+       fi
 ])
 ])
 
 #
 # LC_FUNC_DEV_SET_RDONLY
 #
-# check for the old-style dev_set_rdonly which took an extra "devno" param
-# and can only set a single device to discard writes at one time
+# check whether dev_set_rdonly is exported.  This is needed until we
+# have another mechanism to fence IO from the underlying device.
 #
 AC_DEFUN([LC_FUNC_DEV_SET_RDONLY],
-[AC_MSG_CHECKING([if kernel has new dev_set_rdonly])
+[LB_CHECK_SYMBOL_EXPORT([dev_set_rdonly],
+[block/ll_rw_block.c,block/blk-core.c],[
+        AC_DEFINE(HAVE_DEV_SET_RDONLY, 1, [kernel exports dev_set_rdonly])
+],[
+        AC_MSG_WARN([kernel missing dev_set_rdonly patch for testing])
+])
+])
+
+#
+# Ensure stack size big than 8k in Lustre server (all kernels)
+#
+AC_DEFUN([LC_STACK_SIZE],
+[AC_MSG_CHECKING([stack size big than 8k])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/fs.h>
-        #include <linux/blkdev.h>
+       #include <linux/thread_info.h>
 ],[
-        #ifndef HAVE_CLEAR_RDONLY_ON_PUT
-        #error needs to be patched by lustre kernel patches from Lustre version 1.4.3 or above.
+        #if THREAD_SIZE < 8192
+        #error "stack size < 8192"
         #endif
 ],[
-        AC_MSG_RESULT([yes])
-        AC_DEFINE(HAVE_DEV_SET_RDONLY, 1, [kernel has new dev_set_rdonly])
+        AC_MSG_RESULT(yes)
 ],[
-        AC_MSG_ERROR([no, Linux kernel source needs to be patches by lustre
-kernel patches from Lustre version 1.4.3 or above.])
+        AC_MSG_ERROR([Lustre requires that Linux is configured with at least a 8KB stack.])
 ])
 ])
 
 #
-# LC_CONFIG_BACKINGFS
+# Allow the user to set the MDS thread upper limit
 #
-# setup, check the backing filesystem
-#
-AC_DEFUN([LC_CONFIG_BACKINGFS],
+AC_DEFUN([LC_MDS_MAX_THREADS],
 [
-BACKINGFS="ldiskfs"
-
-if test x$with_ldiskfs = xno ; then
-       if test x$linux25$enable_server = xyesyes ; then
-               AC_MSG_ERROR([ldiskfs is required for 2.6-based servers.])
-       fi
-else
-       # ldiskfs is enabled
-       LB_DEFINE_LDISKFS_OPTIONS
-fi #ldiskfs
-
-AC_MSG_CHECKING([which backing filesystem to use])
-AC_MSG_RESULT([$BACKINGFS])
-AC_SUBST(BACKINGFS)
+        AC_ARG_WITH([mds_max_threads],
+        AC_HELP_STRING([--with-mds-max-threads=size],
+                        [define the maximum number of threads available on the MDS: (default=512)]),
+        [
+                MDS_THREAD_COUNT=$with_mds_max_threads
+                AC_DEFINE_UNQUOTED(MDT_MAX_THREADS, $MDS_THREAD_COUNT, [maximum number of mdt threads])
+        ])
 ])
 
 #
@@ -148,27 +183,18 @@ fi
 ])
 
 #
-# LC_HEADER_LDISKFS_XATTR
-#
-# CHAOS kernel-devel package will not include fs/ldiskfs/xattr.h
+# LC_CONFIG_LIBLUSTRE_RECOVERY
 #
-AC_DEFUN([LC_HEADER_LDISKFS_XATTR],
-[AC_MSG_CHECKING([if ldiskfs has xattr.h header])
-tmp_flags="$EXTRA_KCFLAGS"
-EXTRA_KCFLAGS="-I$LINUX/fs -I$LDISKFS_DIR -I$LDISKFS_DIR/ldiskfs"
-LB_LINUX_TRY_COMPILE([
-       #include <ldiskfs/xattr.h>
-],[
-        ldiskfs_xattr_get(NULL, 0, "", NULL, 0);
-        ldiskfs_xattr_set_handle(NULL, NULL, 0, "", NULL, 0, 0);
-
-],[
-       AC_MSG_RESULT([yes])
-       AC_DEFINE(HAVE_LDISKFS_XATTR_H, 1, [ldiskfs/xattr.h found])
-],[
-       AC_MSG_RESULT([no])
-])
-EXTRA_KCFLAGS="$tmp_flags"
+AC_DEFUN([LC_CONFIG_LIBLUSTRE_RECOVERY],
+[AC_MSG_CHECKING([whether to enable liblustre recovery support])
+AC_ARG_ENABLE([liblustre-recovery],
+       AC_HELP_STRING([--disable-liblustre-recovery],
+                       [disable liblustre recovery support]),
+       [],[enable_liblustre_recovery='yes'])
+AC_MSG_RESULT([$enable_liblustre_recovery])
+if test x$enable_liblustre_recovery != xno ; then
+  AC_DEFINE(ENABLE_LIBLUSTRE_RECOVERY, 1, Liblustre Can Recover)
+fi
 ])
 
 #
@@ -188,139 +214,90 @@ if test x$enable_health_write != xno ; then
 fi
 ])
 
-#
-# LC_CONFIG_LIBLUSTRE_RECOVERY
-#
-AC_DEFUN([LC_CONFIG_LIBLUSTRE_RECOVERY],
-[AC_MSG_CHECKING([whether to enable liblustre recovery support])
-AC_ARG_ENABLE([liblustre-recovery],
-       AC_HELP_STRING([--disable-liblustre-recovery],
-                       [disable liblustre recovery support]),
-       [],[enable_liblustre_recovery='yes'])
-AC_MSG_RESULT([$enable_liblustre_recovery])
-if test x$enable_liblustre_recovery != xno ; then
-  AC_DEFINE(ENABLE_LIBLUSTRE_RECOVERY, 1, Liblustre Can Recover)
+AC_DEFUN([LC_CONFIG_LRU_RESIZE],
+[AC_MSG_CHECKING([whether to enable lru self-adjusting])
+AC_ARG_ENABLE([lru_resize],
+       AC_HELP_STRING([--enable-lru-resize],
+                       [enable lru resize support]),
+       [],[enable_lru_resize='yes'])
+AC_MSG_RESULT([$enable_lru_resize])
+if test x$enable_lru_resize != xno; then
+   AC_DEFINE(HAVE_LRU_RESIZE_SUPPORT, 1, [Enable lru resize support])
 fi
 ])
 
-#
-# LC_CONFIG_OBD_BUFFER_SIZE
-#
-# the maximum buffer size of lctl ioctls
-#
-AC_DEFUN([LC_CONFIG_OBD_BUFFER_SIZE],
-[AC_MSG_CHECKING([maximum OBD ioctl size])
-AC_ARG_WITH([obd-buffer-size],
-       AC_HELP_STRING([--with-obd-buffer-size=[size]],
-                       [set lctl ioctl maximum bytes (default=8192)]),
-       [
-               OBD_BUFFER_SIZE=$with_obd_buffer_size
-       ],[
-               OBD_BUFFER_SIZE=8192
-       ])
-AC_MSG_RESULT([$OBD_BUFFER_SIZE bytes])
-AC_DEFINE_UNQUOTED(OBD_MAX_IOCTL_BUFFER, $OBD_BUFFER_SIZE, [IOCTL Buffer Size])
+# whether to enable quota support(kernel modules)
+AC_DEFUN([LC_QUOTA_MODULE],
+[if test x$enable_quota != xno; then
+    LB_LINUX_CONFIG([QUOTA],[
+       enable_quota_module='yes'
+       AC_DEFINE(HAVE_QUOTA_SUPPORT, 1, [Enable quota support])
+    ],[
+       enable_quota_module='no'
+       AC_MSG_WARN([quota is not enabled because the kernel - lacks quota support])
+    ])
+fi
 ])
 
-#
-# LC_STRUCT_STATFS
-#
-# AIX does not have statfs.f_namelen
-#
-AC_DEFUN([LC_STRUCT_STATFS],
-[AC_MSG_CHECKING([if struct statfs has a f_namelen field])
-LB_LINUX_TRY_COMPILE([
-       #include <linux/vfs.h>
-],[
-       struct statfs sfs;
-       sfs.f_namelen = 1;
-],[
-       AC_MSG_RESULT([yes])
-       AC_DEFINE(HAVE_STATFS_NAMELEN, 1, [struct statfs has a namelen field])
-],[
-       AC_MSG_RESULT([no])
-])
-])
+# truncate_complete_page() was exported from RHEL5/SLES10, but not in SLES11 SP0 (2.6.27)
+# remove_from_page_cache() was exported between 2.6.35 and 2.6.38
+# delete_from_page_cache() is exported from 2.6.39
+AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE],
+         [LB_CHECK_SYMBOL_EXPORT([truncate_complete_page],
+                                 [mm/truncate.c],
+                                 [AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
+                                            [kernel export truncate_complete_page])])
+          LB_CHECK_SYMBOL_EXPORT([remove_from_page_cache],
+                                 [mm/filemap.c],
+                                 [AC_DEFINE(HAVE_REMOVE_FROM_PAGE_CACHE, 1,
+                                            [kernel export remove_from_page_cache])])
+          LB_CHECK_SYMBOL_EXPORT([delete_from_page_cache],
+                                 [mm/filemap.c],
+                                 [AC_DEFINE(HAVE_DELETE_FROM_PAGE_CACHE, 1,
+                                            [kernel export delete_from_page_cache])])
+         ])
 
-#
-# LC_READLINK_SSIZE_T
-#
-AC_DEFUN([LC_READLINK_SSIZE_T],
-[AC_MSG_CHECKING([if readlink returns ssize_t])
-AC_TRY_COMPILE([
-       #include <unistd.h>
-],[
-       ssize_t readlink(const char *, char *, size_t);
-],[
-       AC_MSG_RESULT([yes])
-       AC_DEFINE(HAVE_POSIX_1003_READLINK, 1, [readlink returns ssize_t])
+AC_DEFUN([LC_EXPORT_D_REHASH_COND],
+[LB_CHECK_SYMBOL_EXPORT([d_rehash_cond],
+[fs/dcache.c],[
+AC_DEFINE(HAVE_D_REHASH_COND, 1,
+            [d_rehash_cond is exported by the kernel])
 ],[
-       AC_MSG_RESULT([no])
 ])
 ])
 
-#
-# LC_FUNC_MS_FLOCK_LOCK
-#
-# 2.6.5 kernel has MS_FLOCK_LOCK sb flag
-#
-AC_DEFUN([LC_FUNC_MS_FLOCK_LOCK],
-[AC_MSG_CHECKING([if kernel has MS_FLOCK_LOCK sb flag])
-LB_LINUX_TRY_COMPILE([
-        #include <linux/fs.h>
-],[
-        int flags = MS_FLOCK_LOCK;
-],[
-        AC_DEFINE(HAVE_MS_FLOCK_LOCK, 1,
-                [kernel has MS_FLOCK_LOCK flag])
-        AC_MSG_RESULT([yes])
+AC_DEFUN([LC_EXPORT___D_REHASH],
+[LB_CHECK_SYMBOL_EXPORT([__d_rehash],
+[fs/dcache.c],[
+AC_DEFINE(HAVE___D_REHASH, 1,
+            [__d_rehash is exported by the kernel])
 ],[
-        AC_MSG_RESULT([no])
 ])
 ])
 
-#
-# LC_FUNC_HAVE_CAN_SLEEP_ARG
-#
-# 2.6.5 kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()
-#
-AC_DEFUN([LC_FUNC_HAVE_CAN_SLEEP_ARG],
-[AC_MSG_CHECKING([if kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
-LB_LINUX_TRY_COMPILE([
-        #include <linux/fs.h>
-],[
-        int cansleep;
-        struct file *file;
-        struct file_lock *file_lock;
-        flock_lock_file_wait(file, file_lock, cansleep);
-],[
-        AC_DEFINE(HAVE_CAN_SLEEP_ARG, 1,
-                [kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
-        AC_MSG_RESULT([yes])
-],[
-        AC_MSG_RESULT([no])
-])
-])
+# 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
+# to the appropriate function and that's what we use.
+AC_DEFUN([LC_EXPORT_NODE_TO_CPUMASK],
+         [LB_CHECK_SYMBOL_EXPORT([node_to_cpumask],
+                                 [arch/$LINUX_ARCH/mm/numa.c],
+                                 [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
+                                            [node_to_cpumask is exported by
+                                             the kernel])]) # x86_64
+          LB_CHECK_SYMBOL_EXPORT([node_to_cpu_mask],
+                                 [arch/$LINUX_ARCH/kernel/smpboot.c],
+                                 [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
+                                            [node_to_cpumask is exported by
+                                             the kernel])]) # ia64
+          LB_CHECK_SYMBOL_EXPORT([node_2_cpu_mask],
+                                 [arch/$LINUX_ARCH/kernel/smpboot.c],
+                                 [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
+                                            [node_to_cpumask is exported by
+                                             the kernel])]) # i386
+          ])
 
 #
-# LC_FUNC_RELEASEPAGE_WITH_GFP
-#
-# 2.6.9 ->releasepage() takes a gfp_t arg
-# 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_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
-])
-
 #
 # between 2.6.5 - 2.6.22 filemap_populate is exported in some kernels
 #
@@ -340,23 +317,6 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
-# added in 2.6.15
-#
-AC_DEFUN([LC_D_ADD_UNIQUE],
-[AC_MSG_CHECKING([for d_add_unique])
-LB_LINUX_TRY_COMPILE([
-        #include <linux/dcache.h>
-],[
-       d_add_unique(NULL, NULL);
-],[
-        AC_MSG_RESULT([yes])
-        AC_DEFINE(HAVE_D_ADD_UNIQUE, 1, [Kernel has d_add_unique])
-],[
-        AC_MSG_RESULT([no])
-])
-])
-
-#
 # added in 2.6.17
 #
 AC_DEFUN([LC_BIT_SPINLOCK_H],
@@ -377,23 +337,47 @@ AC_DEFUN([LC_BIT_SPINLOCK_H],
 ])
 
 #
-# After 2.6.26 we no longer have xattr_acl.h
+# LC_CONST_ACL_SIZE
 #
-AC_DEFUN([LC_XATTR_ACL],
-[LB_CHECK_FILE([$LINUX/include/linux/xattr_acl.h],[
-       AC_MSG_CHECKING([if xattr_acl.h can be compiled])
-       LB_LINUX_TRY_COMPILE([
-               #include <linux/xattr_acl.h>
-       ],[],[
-               AC_MSG_RESULT([yes])
-               AC_DEFINE(HAVE_XATTR_ACL, 1, [Kernel has xattr_acl])
-       ],[
-               AC_MSG_RESULT([no])
-       ])
-],
-[])
-])
+AC_DEFUN([LC_CONST_ACL_SIZE],
+[AC_MSG_CHECKING([calc acl size])
+tmp_flags="$CFLAGS"
+CFLAGS="$CFLAGS -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -I$LINUX/arch/`uname -m|sed -e 's/ppc.*/powerpc/' -e 's/x86_64/x86/' -e 's/i.86/x86/'`/include -include $AUTOCONF_HDIR/autoconf.h $EXTRA_KCFLAGS"
+AC_TRY_RUN([
+        #define __KERNEL__
+        #include <linux/types.h>
+        #undef __KERNEL__
+        // block include
+        #define __LINUX_POSIX_ACL_H
+
+        #ifdef CONFIG_FS_POSIX_ACL
+        # include <linux/posix_acl_xattr.h>
+        #endif
 
+        #include <stdio.h>
+
+        int main(void)
+        {
+                /* LUSTRE_POSIX_ACL_MAX_ENTRIES  = 32 */
+            int size = posix_acl_xattr_size(32);
+            FILE *f = fopen("acl.size","w+");
+            fprintf(f,"%d", size);
+            fclose(f);
+
+            return 0;
+        }
+],[
+       acl_size=`cat acl.size`
+       AC_MSG_RESULT([ACL size $acl_size])
+        AC_DEFINE_UNQUOTED(XATTR_ACL_SIZE, AS_TR_SH([$acl_size]), [size of xattr acl])
+],[
+        AC_ERROR([ACL size can't be computed])
+],[
+       AC_MSG_RESULT([can't check ACL size, make it 260])
+        AC_DEFINE_UNQUOTED(XATTR_ACL_SIZE,260)
+])
+CFLAGS="$tmp_flags"
+])
 
 # added in 2.6.16
 #
@@ -413,57 +397,6 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
-
-#
-# After 2.6.16 the xattr_acl API is removed, and posix_acl is used instead
-#
-AC_DEFUN([LC_POSIX_ACL_XATTR_H],
-[LB_CHECK_FILE([$LINUX/include/linux/posix_acl_xattr.h],[
-        AC_MSG_CHECKING([if linux/posix_acl_xattr.h can be compiled])
-        LB_LINUX_TRY_COMPILE([
-                #include <linux/posix_acl_xattr.h>
-        ],[],[
-                AC_MSG_RESULT([yes])
-                AC_DEFINE(HAVE_LINUX_POSIX_ACL_XATTR_H, 1, [linux/posix_acl_xattr.h found])
-
-        ],[
-                AC_MSG_RESULT([no])
-        ])
-$1
-],[
-AC_MSG_RESULT([no])
-])
-])
-
-#
-# LC_EXPORT___IGET
-# starting from 2.6.19 linux kernel exports __iget()
-#
-AC_DEFUN([LC_EXPORT___IGET],
-[LB_CHECK_SYMBOL_EXPORT([__iget],
-[fs/inode.c],[
-        AC_DEFINE(HAVE_EXPORT___IGET, 1, [kernel exports __iget])
-],[
-])
-])
-
-#
-# only for Lustre-patched kernels
-#
-AC_DEFUN([LC_LUSTRE_VERSION_H],
-[LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
-       rm -f "$LUSTRE/include/linux/lustre_version.h"
-],[
-       touch "$LUSTRE/include/linux/lustre_version.h"
-       if test x$enable_server = xyes ; then
-               AC_MSG_WARN([Unpatched kernel detected.])
-               AC_MSG_WARN([Lustre servers cannot be built with an unpatched kernel;])
-               AC_MSG_WARN([disabling server build])
-               enable_server='no'
-       fi
-])
-])
-
 #
 # LC_CAPA_CRYPTO
 #
@@ -491,27 +424,6 @@ AC_DEFUN([LC_CONFIG_RMTCLIENT],
 ])
 ])
 
-AC_DEFUN([LC_SUNRPC_CACHE],
-[AC_MSG_CHECKING([if sunrpc struct cache_head uses kref])
-LB_LINUX_TRY_COMPILE([
-        #include <linux/sunrpc/cache.h>
-],[
-        struct cache_head ch;
-        &ch.ref.refcount;
-],[
-        AC_MSG_RESULT([yes])
-        AC_DEFINE(HAVE_SUNRPC_CACHE_V2, 1, [sunrpc cache facility v2])
-],[
-        AC_MSG_RESULT([no])
-])
-])
-
-AC_DEFUN([LC_CONFIG_SUNRPC],
-[LB_LINUX_CONFIG_IM([SUNRPC],[],
-                    [AC_MSG_ERROR([kernel SUNRPC support is required by using GSS.])])
- LC_SUNRPC_CACHE
-])
-
 #
 # LC_CONFIG_GSS_KEYRING (default enabled, if gss is enabled)
 #
@@ -535,6 +447,27 @@ AC_DEFUN([LC_CONFIG_GSS_KEYRING],
  fi
 ])
 
+AC_DEFUN([LC_SUNRPC_CACHE],
+[AC_MSG_CHECKING([if sunrpc struct cache_head uses kref])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/sunrpc/cache.h>
+],[
+        struct cache_head ch;
+        &ch.ref.refcount;
+],[
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_SUNRPC_CACHE_V2, 1, [sunrpc cache facility v2])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+AC_DEFUN([LC_CONFIG_SUNRPC],
+[LB_LINUX_CONFIG_IM([SUNRPC],[],
+                    [AC_MSG_ERROR([kernel SUNRPC support is required by using GSS.])])
+ LC_SUNRPC_CACHE
+])
+
 #
 # LC_CONFIG_GSS (default disabled)
 #
@@ -575,92 +508,83 @@ AC_DEFUN([LC_CONFIG_GSS],
  fi
 ])
 
-# 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],
-[AC_MSG_CHECKING([if inode has i_mutex ])
+#
+# LC_FUNC_HAVE_CAN_SLEEP_ARG
+#
+# 2.6.5 kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()
+#
+AC_DEFUN([LC_FUNC_HAVE_CAN_SLEEP_ARG],
+[AC_MSG_CHECKING([if kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
 LB_LINUX_TRY_COMPILE([
-       #include <linux/mutex.h>
-       #include <linux/fs.h>
-       #undef i_mutex
+        #include <linux/fs.h>
 ],[
-       struct inode i;
-
-       mutex_unlock(&i.i_mutex);
+        int cansleep;
+        struct file *file;
+        struct file_lock *file_lock;
+        flock_lock_file_wait(file, file_lock, cansleep);
 ],[
-        AC_MSG_RESULT(yes)
-        AC_DEFINE(HAVE_INODE_I_MUTEX, 1,
-                [after 2.6.15 inode have i_mutex intead of i_sem])
+        AC_DEFINE(HAVE_CAN_SLEEP_ARG, 1,
+                [kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
+        AC_MSG_RESULT([yes])
 ],[
-        AC_MSG_RESULT(no)
+        AC_MSG_RESULT([no])
 ])
 ])
 
-# LC_SEQ_LOCK
-# after 2.6.18 seq_file has lock intead of sem
-AC_DEFUN([LC_SEQ_LOCK],
-[AC_MSG_CHECKING([if struct seq_file has lock field])
+#
+# LC_FUNC_F_OP_FLOCK
+#
+# rhel4.2 kernel has f_op->flock field
+#
+AC_DEFUN([LC_FUNC_F_OP_FLOCK],
+[AC_MSG_CHECKING([if struct file_operations has flock field])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/seq_file.h>
+        #include <linux/fs.h>
 ],[
-       struct seq_file seq;
-
-       mutex_unlock(&seq.lock);
+        struct file_operations ll_file_operations_flock;
+        ll_file_operations_flock.flock = NULL;
 ],[
-        AC_MSG_RESULT(yes)
-        AC_DEFINE(HAVE_SEQ_LOCK, 1,
-                [after 2.6.18 seq_file has lock intead of sem])
+        AC_DEFINE(HAVE_F_OP_FLOCK, 1,
+                [struct file_operations has flock field])
+        AC_MSG_RESULT([yes])
 ],[
-        AC_MSG_RESULT(NO)
+        AC_MSG_RESULT([no])
 ])
 ])
 
-# LC_DQUOTOFF_MUTEX
-# after 2.6.17 dquote use mutex instead if semaphore
-AC_DEFUN([LC_DQUOTOFF_MUTEX],
-[AC_MSG_CHECKING([use dqonoff_mutex])
+AC_DEFUN([LC_QUOTA_READ],
+[AC_MSG_CHECKING([if kernel supports quota_read])
 LB_LINUX_TRY_COMPILE([
-       #include <linux/mutex.h>
        #include <linux/fs.h>
-        #include <linux/quota.h>
 ],[
-        struct quota_info dq;
-
-        mutex_unlock(&dq.dqonoff_mutex);
+       struct super_operations sp;
+        void *i = (void *)sp.quota_read;
 ],[
-        AC_MSG_RESULT(yes)
-        AC_DEFINE(HAVE_DQUOTOFF_MUTEX, 1,
-                [after 2.6.17 dquote use mutex instead if semaphore])
+       AC_MSG_RESULT([yes])
+       AC_DEFINE(KERNEL_SUPPORTS_QUOTA_READ, 1, [quota_read found])
 ],[
-        AC_MSG_RESULT(no)
+       AC_MSG_RESULT([no])
 ])
 ])
 
 #
-# LC_STATFS_DENTRY_PARAM
-# starting from 2.6.18 linux kernel uses dentry instead of
-# super_block for first vfs_statfs argument
+# LC_COOKIE_FOLLOW_LINK
 #
-AC_DEFUN([LC_STATFS_DENTRY_PARAM],
-[AC_MSG_CHECKING([first vfs_statfs parameter is dentry])
+# kernel 2.6.13+ ->follow_link returns a cookie
+#
+
+AC_DEFUN([LC_COOKIE_FOLLOW_LINK],
+[AC_MSG_CHECKING([if inode_operations->follow_link returns a cookie])
 LB_LINUX_TRY_COMPILE([
         #include <linux/fs.h>
+        #include <linux/namei.h>
 ],[
-       int vfs_statfs(struct dentry *, struct kstatfs *);
+        struct dentry dentry;
+        struct nameidata nd;
+
+        dentry.d_inode->i_op->put_link(&dentry, &nd, NULL);
 ],[
-        AC_DEFINE(HAVE_STATFS_DENTRY_PARAM, 1,
-                [first parameter of vfs_statfs is dentry])
+        AC_DEFINE(HAVE_COOKIE_FOLLOW_LINK, 1, [inode_operations->follow_link returns a cookie])
         AC_MSG_RESULT([yes])
 ],[
         AC_MSG_RESULT([no])
@@ -668,94 +592,173 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
-# LC_VFS_KERN_MOUNT
-# starting from 2.6.18 kernel don't export do_kern_mount
-# and want to use vfs_kern_mount instead.
+# LC_FUNC_RCU
 #
-AC_DEFUN([LC_VFS_KERN_MOUNT],
-[AC_MSG_CHECKING([vfs_kern_mount exist in kernel])
+# kernels prior than 2.6.0(?) have no RCU supported; in kernel 2.6.5(SUSE),
+# call_rcu takes three parameters.
+#
+AC_DEFUN([LC_FUNC_RCU],
+[AC_MSG_CHECKING([if kernel have RCU supported])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/mount.h>
-],[
-        vfs_kern_mount(NULL, 0, NULL, NULL);
-],[
-        AC_DEFINE(HAVE_VFS_KERN_MOUNT, 1,
-                [vfs_kern_mount exist in kernel])
+        #include <linux/rcupdate.h>
+],[],[
+        AC_DEFINE(HAVE_RCU, 1, [have RCU defined])
         AC_MSG_RESULT([yes])
+
+        AC_MSG_CHECKING([if call_rcu takes three parameters])
+        LB_LINUX_TRY_COMPILE([
+                #include <linux/rcupdate.h>
+        ],[
+                struct rcu_head rh;
+                call_rcu(&rh, (void (*)(struct rcu_head *))1, NULL);
+        ],[
+                AC_DEFINE(HAVE_CALL_RCU_PARAM, 1, [call_rcu takes three parameters])
+                AC_MSG_RESULT([yes])
+        ],[
+                AC_MSG_RESULT([no])
+        ])
+
 ],[
         AC_MSG_RESULT([no])
 ])
 ])
 
-#
-# LC_D_OBTAIN_ALIAS
-# starting from 2.6.18 kernel don't export do_kern_mount
-# and want to use vfs_kern_mount instead.
-#
-AC_DEFUN([LC_D_OBTAIN_ALIAS],
-[AC_MSG_CHECKING([d_obtain_alias exist in kernel])
+AC_DEFUN([LC_PERCPU_COUNTER],
+[AC_MSG_CHECKING([if have struct percpu_counter defined])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/dcache.h>
-],[
-        d_obtain_alias(NULL);
-],[
-        AC_DEFINE(HAVE_D_OBTAIN_ALIAS, 1,
-                [d_obtain_alias exist in kernel])
+        #include <linux/percpu_counter.h>
+],[],[
+        AC_DEFINE(HAVE_PERCPU_COUNTER, 1, [percpu_counter found])
         AC_MSG_RESULT([yes])
-],[
-        AC_MSG_RESULT([no])
-])
-])
 
-#
-# LC_INVALIDATEPAGE_RETURN_INT
-# 2.6.17 changes return type for invalidatepage to 'void' from 'int'
-#
-AC_DEFUN([LC_INVALIDATEPAGE_RETURN_INT],
-[AC_MSG_CHECKING([invalidatepage has return int])
+        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])
+])
+])
+
+AC_DEFUN([LC_TASK_CLENV_STORE],
+[
+        AC_MSG_CHECKING([if we can store cl_env in task_struct])
+        if test x$have_task_clenv_store != xyes ; then
+                LC_TASK_CLENV_TUX_INFO
+        fi
+])
+
+# ~2.6.11
+
+AC_DEFUN([LC_S_TIME_GRAN],
+[AC_MSG_CHECKING([if super block has s_time_gran member])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/buffer_head.h>
+        #include <linux/fs.h>
 ],[
-       int rc = block_invalidatepage(NULL, 0);
+       struct super_block sb;
+
+        return sb.s_time_gran;
 ],[
-       AC_MSG_RESULT(yes)
-       AC_DEFINE(HAVE_INVALIDATEPAGE_RETURN_INT, 1,
-               [Define if return type of invalidatepage should be int])
+       AC_MSG_RESULT([yes])
+       AC_DEFINE(HAVE_S_TIME_GRAN, 1, [super block has s_time_gran member])
 ],[
-       AC_MSG_RESULT(no)
+        AC_MSG_RESULT([no])
 ])
 ])
 
-# LC_UMOUNTBEGIN_HAS_VFSMOUNT
-# after 2.6.18 umount_begin has different parameters
-AC_DEFUN([LC_UMOUNTBEGIN_HAS_VFSMOUNT],
-[AC_MSG_CHECKING([if umount_begin needs vfsmount parameter instead of super_block])
+AC_DEFUN([LC_SB_TIME_GRAN],
+[AC_MSG_CHECKING([if kernel has old get_sb_time_gran])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+       return get_sb_time_gran(NULL);
+],[
+        AC_MSG_RESULT([yes])
+       AC_DEFINE(HAVE_SB_TIME_GRAN, 1, [kernel has old get_sb_time_gran])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.12
+
+# ~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.15
+
+# LC_INODE_I_MUTEX
+# after 2.6.15 inode have i_mutex intead of i_sem
+AC_DEFUN([LC_INODE_I_MUTEX],
+[AC_MSG_CHECKING([if inode has i_mutex ])
+LB_LINUX_TRY_COMPILE([
+       #include <linux/mutex.h>
        #include <linux/fs.h>
+       #undef i_mutex
+],[
+       struct inode i;
 
-       struct vfsmount;
-       static void cfg_umount_begin (struct vfsmount *v, int flags)
-       {
-               ;
-       }
+       mutex_unlock(&i.i_mutex);
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_INODE_I_MUTEX, 1,
+                [after 2.6.15 inode have i_mutex intead of i_sem])
+],[
+        AC_MSG_RESULT(no)
+])
+])
 
-       static struct super_operations cfg_super_operations = {
-               .umount_begin   = cfg_umount_begin,
-       };
+# 2.6.16
+
+# LC_SECURITY_PLUG  # for SLES10 SP2
+# 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([
+        #include <linux/fs.h>
 ],[
-       cfg_super_operations.umount_begin(NULL,0);
+        struct dentry   *dentry;
+        struct vfsmount *mnt;
+        struct iattr    *iattr;
+
+        notify_change(dentry, mnt, iattr);
 ],[
-       AC_MSG_RESULT(yes)
-       AC_DEFINE(HAVE_UMOUNTBEGIN_VFSMOUNT, 1,
-               [Define umount_begin need second argument])
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_SECURITY_PLUG, 1,
+                [SLES10 SP2 use extra parameter in vfs])
 ],[
-       AC_MSG_RESULT(no)
+        AC_MSG_RESULT(no)
 ])
-EXTRA_KCFLAGS="$tmp_flags"
 ])
 
+# 2.6.17
+
 # inode have i_private field since 2.6.17
 AC_DEFUN([LC_INODE_IPRIVATE],
 [AC_MSG_CHECKING([if inode has a i_private field])
@@ -773,152 +776,215 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
-# 2.6.19 API changes
-# inode don't have i_blksize field
-AC_DEFUN([LC_INODE_BLKSIZE],
-[AC_MSG_CHECKING([inode has i_blksize field])
+# LC_DQUOTOFF_MUTEX
+# after 2.6.17 dquote use mutex instead if semaphore
+AC_DEFUN([LC_DQUOTOFF_MUTEX],
+[AC_MSG_CHECKING([use dqonoff_mutex])
 LB_LINUX_TRY_COMPILE([
-#include <linux/fs.h>
+       #include <linux/mutex.h>
+       #include <linux/fs.h>
+        #include <linux/quota.h>
 ],[
-       struct inode i;
-       i.i_blksize = 0;
+        struct quota_info dq;
+
+        mutex_unlock(&dq.dqonoff_mutex);
 ],[
-       AC_MSG_RESULT(yes)
-       AC_DEFINE(HAVE_INODE_BLKSIZE, 1,
-               [struct inode has i_blksize field])
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_DQUOTOFF_MUTEX, 1,
+                [after 2.6.17 dquote use mutex instead if semaphore])
 ],[
-       AC_MSG_RESULT(no)
+        AC_MSG_RESULT(no)
 ])
 ])
 
-# LC_VFS_READDIR_U64_INO
-# 2.6.19 use u64 for inode number instead of inode_t
-AC_DEFUN([LC_VFS_READDIR_U64_INO],
-[AC_MSG_CHECKING([check vfs_readdir need 64bit inode number])
-tmp_flags="$EXTRA_KCFLAGS"
-EXTRA_KCFLAGS="-Werror"
+# 2.6.18
+
+# LC_NR_PAGECACHE
+# 2.6.18 don't export nr_pagecahe
+AC_DEFUN([LC_NR_PAGECACHE],
+[AC_MSG_CHECKING([kernel export nr_pagecache])
 LB_LINUX_TRY_COMPILE([
-#include <linux/fs.h>
-       int fillonedir(void * __buf, const char * name, int namlen, loff_t offset,
-                      u64 ino, unsigned int d_type)
-       {
-               return 0;
-       }
+        #include <linux/pagemap.h>
 ],[
-       filldir_t filter;
-
-       filter = fillonedir;
-       return 1;
+        return atomic_read(&nr_pagecache);
 ],[
         AC_MSG_RESULT(yes)
-        AC_DEFINE(HAVE_VFS_READDIR_U64_INO, 1,
-                [if vfs_readdir need 64bit inode number])
+        AC_DEFINE(HAVE_NR_PAGECACHE, 1,
+                [is kernel export nr_pagecache])
 ],[
         AC_MSG_RESULT(no)
 ])
-EXTRA_KCFLAGS="$tmp_flags"
 ])
 
-# LC_FILE_WRITEV
-# 2.6.19 replaced writev with aio_write
-AC_DEFUN([LC_FILE_WRITEV],
-[AC_MSG_CHECKING([writev in fops])
+#
+# LC_STATFS_DENTRY_PARAM
+# starting from 2.6.18 linux kernel uses dentry instead of super_block
+# for the first parameter of the super_operations->statfs() callback.
+#
+#
+AC_DEFUN([LC_STATFS_DENTRY_PARAM],
+[AC_MSG_CHECKING([if super_ops.statfs() first parameter is dentry])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
 LB_LINUX_TRY_COMPILE([
         #include <linux/fs.h>
 ],[
-        struct file_operations *fops = NULL;
-        fops->writev = NULL;
+        ((struct super_operations *)0)->statfs((struct dentry *)0, (struct kstatfs*)0);
 ],[
-        AC_MSG_RESULT(yes)
-        AC_DEFINE(HAVE_FILE_WRITEV, 1,
-                [use fops->writev])
+        AC_DEFINE(HAVE_STATFS_DENTRY_PARAM, 1,
+                  [super_ops.statfs() first parameter is dentry])
+        AC_MSG_RESULT([yes])
 ],[
-       AC_MSG_RESULT(no)
+        AC_MSG_RESULT([no])
 ])
+EXTRA_KCFLAGS="$tmp_flags"
 ])
 
-# LC_GENERIC_FILE_READ
-# 2.6.19 replaced readv with aio_read
-AC_DEFUN([LC_FILE_READV],
-[AC_MSG_CHECKING([readv in fops])
+#
+# LC_VFS_KERN_MOUNT
+# starting from 2.6.18 kernel don't export do_kern_mount
+# and want to use vfs_kern_mount instead.
+#
+AC_DEFUN([LC_VFS_KERN_MOUNT],
+[AC_MSG_CHECKING([vfs_kern_mount exist in kernel])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/fs.h>
+        #include <linux/mount.h>
 ],[
-        struct file_operations *fops = NULL;
-        fops->readv = NULL;
+        vfs_kern_mount(NULL, 0, NULL, NULL);
 ],[
-        AC_MSG_RESULT(yes)
-        AC_DEFINE(HAVE_FILE_READV, 1,
-                [use fops->readv])
+        AC_DEFINE(HAVE_VFS_KERN_MOUNT, 1,
+                [vfs_kern_mount exist in kernel])
+        AC_MSG_RESULT([yes])
 ],[
-        AC_MSG_RESULT(no)
+        AC_MSG_RESULT([no])
 ])
 ])
 
-# LC_NR_PAGECACHE
-# 2.6.18 don't export nr_pagecahe
-AC_DEFUN([LC_NR_PAGECACHE],
-[AC_MSG_CHECKING([kernel export nr_pagecache])
+#
+# LC_INVALIDATEPAGE_RETURN_INT
+# 2.6.17 changes return type for invalidatepage to 'void' from 'int'
+#
+AC_DEFUN([LC_INVALIDATEPAGE_RETURN_INT],
+[AC_MSG_CHECKING([invalidatepage has return int])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/pagemap.h>
+        #include <linux/buffer_head.h>
 ],[
-        return atomic_read(&nr_pagecache);
+       int rc = block_invalidatepage(NULL, 0);
 ],[
-        AC_MSG_RESULT(yes)
-        AC_DEFINE(HAVE_NR_PAGECACHE, 1,
-                [is kernel export nr_pagecache])
+       AC_MSG_RESULT(yes)
+       AC_DEFINE(HAVE_INVALIDATEPAGE_RETURN_INT, 1,
+               [Define if return type of invalidatepage should be int])
 ],[
-        AC_MSG_RESULT(no)
+       AC_MSG_RESULT(no)
 ])
 ])
 
-# LC_CANCEL_DIRTY_PAGE
-# 2.6.20 introduse cancel_dirty_page instead of
-# clear_page_dirty.
-AC_DEFUN([LC_CANCEL_DIRTY_PAGE],
-[AC_MSG_CHECKING([kernel has cancel_dirty_page])
+# LC_UMOUNTBEGIN_HAS_VFSMOUNT
+# after 2.6.18 umount_begin has different parameters
+AC_DEFUN([LC_UMOUNTBEGIN_HAS_VFSMOUNT],
+[AC_MSG_CHECKING([if umount_begin needs vfsmount parameter instead of super_block])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
 LB_LINUX_TRY_COMPILE([
-        #include <linux/mm.h>
-        #include <linux/page-flags.h>
+       #include <linux/fs.h>
+
+       struct vfsmount;
+       static void cfg_umount_begin (struct vfsmount *v, int flags)
+       {
+               ;
+       }
+
+       static struct super_operations cfg_super_operations = {
+               .umount_begin   = cfg_umount_begin,
+       };
 ],[
-        /* 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);
+       cfg_super_operations.umount_begin(NULL,0);
+],[
+       AC_MSG_RESULT(yes)
+       AC_DEFINE(HAVE_UMOUNTBEGIN_VFSMOUNT, 1,
+               [Define umount_begin need second argument])
+],[
+       AC_MSG_RESULT(no)
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+
+# LC_SEQ_LOCK
+# after 2.6.18 seq_file has lock intead of sem
+AC_DEFUN([LC_SEQ_LOCK],
+[AC_MSG_CHECKING([if struct seq_file has lock field])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/seq_file.h>
+],[
+       struct seq_file seq;
+
+       mutex_unlock(&seq.lock);
 ],[
         AC_MSG_RESULT(yes)
-        AC_DEFINE(HAVE_CANCEL_DIRTY_PAGE, 1,
-                  [kernel has cancel_dirty_page instead of clear_page_dirty])
+        AC_DEFINE(HAVE_SEQ_LOCK, 1,
+                [after 2.6.18 seq_file has lock intead of sem])
 ],[
-        AC_MSG_RESULT(no)
+        AC_MSG_RESULT(NO)
 ])
 ])
 
 #
-# LC_PAGE_CONSTANT
+# LC_EXPORT_FILEMAP_FDATAWRITE_RANGE
 #
-# In order to support raid5 zerocopy patch, we have to patch the kernel to make
-# it support constant page, which means the page won't be modified during the
-# IO.
+# No standard kernels export this
 #
-AC_DEFUN([LC_PAGE_CONSTANT],
-[AC_MSG_CHECKING([if kernel have PageConstant defined])
+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])
+],[
+])
+])
+
+# LC_FLUSH_OWNER_ID
+# starting from 2.6.18 the file_operations .flush
+# method has a new "fl_owner_t id" parameter
+#
+AC_DEFUN([LC_FLUSH_OWNER_ID],
+[AC_MSG_CHECKING([if file_operations .flush has an fl_owner_t id])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/mm.h>
-        #include <linux/page-flags.h>
+        #include <linux/fs.h>
 ],[
-        #ifndef PG_constant
-        #error "Have no raid5 zcopy patch"
-        #endif
+        struct file_operations *fops = NULL;
+        fl_owner_t id;
+        int i;
+
+        i = fops->flush(NULL, id);
 ],[
-        AC_MSG_RESULT(yes)
-        AC_DEFINE(HAVE_PAGE_CONSTANT, 1, [kernel have PageConstant supported])
+        AC_DEFINE(HAVE_FLUSH_OWNER_ID, 1,
+                [file_operations .flush method has an fl_owner_t id])
+        AC_MSG_RESULT([yes])
 ],[
-        AC_MSG_RESULT(no);
+        AC_MSG_RESULT([no])
 ])
 ])
 
+#
+# 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])
+  ])
+    ],[])
+])
+
+#2.6.18 + RHEL5 (fc6)
+
 # RHEL5 in FS-cache patch rename PG_checked flag into PG_fs_misc
 AC_DEFUN([LC_PG_FS_MISC],
 [AC_MSG_CHECKING([kernel has PG_fs_misc])
@@ -942,20 +1008,20 @@ LB_LINUX_TRY_COMPILE([
 AC_DEFUN([LC_PAGE_CHECKED],
 [AC_MSG_CHECKING([kernel has PageChecked and SetPageChecked])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/autoconf.h>
+        #include <linux/mm.h>
 #ifdef HAVE_LINUX_MMTYPES_H
         #include <linux/mm_types.h>
 #endif
-       #include <linux/page-flags.h>
+        #include <linux/page-flags.h>
 ],[
-       struct page *p;
+        struct page *p = NULL;
 
         /* before 2.6.26 this define*/
         #ifndef PageChecked    
-       /* 2.6.26 use function instead of define for it */
-       SetPageChecked(p);
-       PageChecked(p);
-       #endif
+        /* 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,
@@ -965,113 +1031,138 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
-AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE],
-[LB_CHECK_SYMBOL_EXPORT([truncate_complete_page],
-[mm/truncate.c],[
-AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
-            [kernel export truncate_complete_page])
-],[
-])
+#
+# LC_LINUX_FIEMAP_H
+#
+# If we have fiemap.h
+# after 2.6.27 use fiemap.h in include/linux
+#
+AC_DEFUN([LC_LINUX_FIEMAP_H],
+[LB_CHECK_FILE([$LINUX/include/linux/fiemap.h],[
+        AC_MSG_CHECKING([if fiemap.h can be compiled])
+        LB_LINUX_TRY_COMPILE([
+                #include <linux/types.h>
+                #include <linux/fiemap.h>
+        ],[],[
+                AC_MSG_RESULT([yes])
+                AC_DEFINE(HAVE_LINUX_FIEMAP_H, 1, [Kernel has fiemap.h])
+        ],[
+                AC_MSG_RESULT([no])
+        ])
+],
+[])
 ])
 
-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])
-],[
-])
-])
+# 2.6.19
 
-AC_DEFUN([LC_EXPORT_D_REHASH_COND],
-[LB_CHECK_SYMBOL_EXPORT([d_rehash_cond],
-[fs/dcache.c],[
-AC_DEFINE(HAVE_D_REHASH_COND, 1,
-            [d_rehash_cond is exported by the kernel])
+# 2.6.19 API changes
+# inode don't have i_blksize field
+AC_DEFUN([LC_INODE_BLKSIZE],
+[AC_MSG_CHECKING([inode has i_blksize field])
+LB_LINUX_TRY_COMPILE([
+#include <linux/fs.h>
+],[
+       struct inode i;
+       i.i_blksize = 0;
+],[
+       AC_MSG_RESULT(yes)
+       AC_DEFINE(HAVE_INODE_BLKSIZE, 1,
+               [struct inode has i_blksize field])
 ],[
+       AC_MSG_RESULT(no)
 ])
 ])
 
-AC_DEFUN([LC_EXPORT___D_REHASH],
-[LB_CHECK_SYMBOL_EXPORT([__d_rehash],
-[fs/dcache.c],[
-AC_DEFINE(HAVE___D_REHASH, 1,
-            [__d_rehash is exported by the kernel])
+# LC_FILE_WRITEV
+# 2.6.19 replaced writev with aio_write
+AC_DEFUN([LC_FILE_WRITEV],
+[AC_MSG_CHECKING([writev in fops])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        struct file_operations *fops = NULL;
+        fops->writev = NULL;
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_FILE_WRITEV, 1,
+                [use fops->writev])
 ],[
+       AC_MSG_RESULT(no)
 ])
 ])
 
-AC_DEFUN([LC_EXPORT_D_MOVE_LOCKED],
-[LB_CHECK_SYMBOL_EXPORT([d_move_locked],
-[fs/dcache.c],[
-AC_DEFINE(HAVE_D_MOVE_LOCKED, 1,
-            [d_move_locked is exported by the kernel])
+# LC_FILE_READV
+# 2.6.19 replaced readv with aio_read
+AC_DEFUN([LC_FILE_READV],
+[AC_MSG_CHECKING([readv in fops])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        struct file_operations *fops = NULL;
+        fops->readv = NULL;
 ],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_FILE_READV, 1,
+                [use fops->readv])
+],[
+        AC_MSG_RESULT(no)
 ])
 ])
 
-AC_DEFUN([LC_EXPORT___D_MOVE],
-[LB_CHECK_SYMBOL_EXPORT([__d_move],
-[fs/dcache.c],[
-AC_DEFINE(HAVE___D_MOVE, 1,
-            [__d_move is exported by the kernel])
+# 2.6.20
+
+# LC_CANCEL_DIRTY_PAGE
+# 2.6.20 introduced cancel_dirty_page instead of clear_page_dirty.
+AC_DEFUN([LC_CANCEL_DIRTY_PAGE],
+        [AC_MSG_CHECKING([kernel has cancel_dirty_page])
+        # the implementation of cancel_dirty_page in OFED 1.4.1's SLES10 SP2
+        # backport is broken, so ignore it
+        if test -f $OFED_BACKPORT_PATH/linux/mm.h &&
+           test "$(sed -ne '/^static inline void cancel_dirty_page(struct page \*page, unsigned int account_size)$/,/^}$/p' $OFED_BACKPORT_PATH/linux/mm.h | md5sum)" = "c518cb32d6394760c5bca14cb7538d3e  -"; then
+                AC_MSG_RESULT(no)
+        else
+                LB_LINUX_TRY_COMPILE([
+                        #include <linux/mm.h>
+                        #include <linux/page-flags.h>
+],[
+                        cancel_dirty_page(NULL, 0);
 ],[
+                        AC_MSG_RESULT(yes)
+                        AC_DEFINE(HAVE_CANCEL_DIRTY_PAGE, 1,
+                                  [kernel has cancel_dirty_page instead of clear_page_dirty])
+],[
+                        AC_MSG_RESULT(no)
 ])
+        fi
 ])
 
-#
-# 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])
-  ])
-    ],[])
-])
+# raid5-zerocopy patch
 
 #
-# LC_EXPORT_FILEMAP_FDATASYNC_RANGE
+# LC_PAGE_CONSTANT
 #
-# No standard kernels export this
+# In order to support raid5 zerocopy patch, we have to patch the kernel to make
+# it support constant page, which means the page won't be modified during the
+# IO.
 #
-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])
+AC_DEFUN([LC_PAGE_CONSTANT],
+[AC_MSG_CHECKING([if kernel have PageConstant defined])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/mm.h>
+        #include <linux/page-flags.h>
 ],[
-])
-])
-
-# 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
-# to the appropriate function and that's what we use.
-AC_DEFUN([LC_EXPORT_NODE_TO_CPUMASK],
-         [LB_CHECK_SYMBOL_EXPORT([node_to_cpumask],
-                                 [arch/$LINUX_ARCH/mm/numa.c],
-                                 [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
-                                            [node_to_cpumask is exported by
-                                             the kernel])]) # x86_64
-          LB_CHECK_SYMBOL_EXPORT([node_to_cpu_mask],
-                                 [arch/$LINUX_ARCH/kernel/smpboot.c],
-                                 [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
-                                            [node_to_cpumask is exported by
-                                             the kernel])]) # ia64
-          LB_CHECK_SYMBOL_EXPORT([node_2_cpu_mask],
-                                 [arch/$LINUX_ARCH/kernel/smpboot.c],
-                                 [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
-                                            [node_to_cpumask is exported by
-                                             the kernel])]) # i386
-          ])
+        #ifndef PG_constant
+        #error "Have no raid5 zcopy patch"
+        #endif
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_PAGE_CONSTANT, 1, [kernel have PageConstant supported])
+],[
+        AC_MSG_RESULT(no);
+])
+])
+
+# 2.6.22
 
 # 2.6.22 lost second parameter for invalidate_bdev
 AC_DEFUN([LC_INVALIDATE_BDEV_2ARG],
@@ -1089,8 +1180,79 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
-# 2.6.18
+#
+# check for crypto API
+#
+AC_DEFUN([LC_ASYNC_BLOCK_CIPHER],
+[AC_MSG_CHECKING([if kernel has block cipher support])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/err.h>
+        #include <linux/crypto.h>
+],[
+        struct crypto_blkcipher *tfm;
+        tfm = crypto_alloc_blkcipher("aes", 0, sizeof(tfm) );
+],[
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_ASYNC_BLOCK_CIPHER, 1, [kernel has block cipher support])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+#
+# check for struct hash_desc
+#
+AC_DEFUN([LC_STRUCT_HASH_DESC],
+[AC_MSG_CHECKING([if kernel has struct hash_desc])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/err.h>
+        #include <linux/crypto.h>
+],[
+        struct hash_desc foo;
+],[
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_STRUCT_HASH_DESC, 1, [kernel has struct hash_desc])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+#
+# check for struct blkcipher_desc
+#
+AC_DEFUN([LC_STRUCT_BLKCIPHER_DESC],
+[AC_MSG_CHECKING([if kernel has struct blkcipher_desc])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/err.h>
+        #include <linux/crypto.h>
+],[
+        struct blkcipher_desc foo;
+],[
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_STRUCT_BLKCIPHER_DESC, 1, [kernel has struct blkcipher_desc])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+#
+# 2.6.19 check for FS_RENAME_DOES_D_MOVE flag
+#
+AC_DEFUN([LC_FS_RENAME_DOES_D_MOVE],
+[AC_MSG_CHECKING([if kernel has FS_RENAME_DOES_D_MOVE flag])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        int v = FS_RENAME_DOES_D_MOVE;
+],[
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_FS_RENAME_DOES_D_MOVE, 1, [kernel has FS_RENAME_DOES_D_MOVE flag])
+],[
+        AC_MSG_RESULT([no])
+])
+])
 
+# 2.6.23
 
 # 2.6.23 have return type 'void' for unregister_blkdev
 AC_DEFUN([LC_UNREGISTER_BLKDEV_RETURN_INT],
@@ -1109,37 +1271,37 @@ 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])
+AC_DEFUN([LC_KERNEL_SPLICE_READ],
+[AC_MSG_CHECKING([if kernel has .splice_read])
 LB_LINUX_TRY_COMPILE([
         #include <linux/fs.h>
 ],[
         struct file_operations file;
 
-        file.sendfile = NULL;
+        file.splice_read = NULL;
 ], [
         AC_MSG_RESULT([yes])
-        AC_DEFINE(HAVE_KERNEL_SENDFILE, 1,
-                [kernel has .sendfile])
+        AC_DEFINE(HAVE_KERNEL_SPLICE_READ, 1,
+                [kernel has .slice_read])
 ],[
         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])
+# 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.splice_read = NULL;
+        file.sendfile = NULL;
 ], [
         AC_MSG_RESULT([yes])
-        AC_DEFINE(HAVE_KERNEL_SPLICE_READ, 1,
-                [kernel has .slice_read])
+        AC_DEFINE(HAVE_KERNEL_SENDFILE, 1,
+                [kernel has .sendfile])
 ],[
         AC_MSG_RESULT([no])
 ])
@@ -1173,17 +1335,41 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
-#2.6.23 has new shrinker API
-AC_DEFUN([LC_REGISTER_SHRINKER],
-[AC_MSG_CHECKING([if kernel has register_shrinker])
+# 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/mm.h>
+        #include <linux/proc_fs.h>
+],[
+        struct proc_dir_entry pde;
+
+        pde.pde_users   = 0;
 ],[
-        register_shrinker(NULL);
-], [
         AC_MSG_RESULT([yes])
-        AC_DEFINE(HAVE_REGISTER_SHRINKER, 1,
-                [kernel has register_shrinker])
+        AC_DEFINE(HAVE_PROCFS_USERS, 1,
+                [kernel has pde_users member in procfs entry struct])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.23 exports exportfs_decode_fh
+AC_DEFUN([LC_EXPORTFS_DECODE_FH],
+[LB_CHECK_SYMBOL_EXPORT([exportfs_decode_fh],
+[fs/exportfs/expfs.c],[
+        AC_DEFINE(HAVE_EXPORTFS_DECODE_FH, 1,
+                [exportfs_decode_fh has been export])
+],[
+])
+])
+
+# 2.6.24
+
+# 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])
 ])
@@ -1209,15 +1395,12 @@ LB_LINUX_TRY_COMPILE([
 AC_DEFUN([LC_FH_TO_DENTRY],
 [AC_MSG_CHECKING([if kernel has .fh_to_dentry member in export_operations struct])
 LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
 #ifdef HAVE_LINUX_EXPORTFS_H
         #include <linux/exportfs.h>
-#else
-        #include <linux/fs.h>
 #endif
 ],[
-        struct export_operations exp;
-
-        exp.fh_to_dentry   = NULL;
+        do{ }while(sizeof(((struct export_operations *)0)->fh_to_dentry));
 ], [
         AC_MSG_RESULT([yes])
         AC_DEFINE(HAVE_FH_TO_DENTRY, 1,
@@ -1227,16 +1410,6 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
-# 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 removes long aged procfs entry -> deleted member
 AC_DEFUN([LC_PROCFS_DELETED],
 [AC_MSG_CHECKING([if kernel has deleted member in procfs entry struct])
@@ -1245,7 +1418,7 @@ LB_LINUX_TRY_COMPILE([
 ],[
         struct proc_dir_entry pde;
 
-        pde.deleted   = NULL;
+        pde.deleted = sizeof(pde);
 ], [
         AC_MSG_RESULT([yes])
         AC_DEFINE(HAVE_PROCFS_DELETED, 1,
@@ -1255,25 +1428,17 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
-# 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
+# 2.6.24 has bdi_init()/bdi_destroy() functions.
+AC_DEFUN([LC_EXPORT_BDI_INIT],
+[LB_CHECK_SYMBOL_EXPORT([bdi_init],
+[mm/backing-dev.c],[
+        AC_DEFINE(HAVE_BDI_INIT, 1,
+                [bdi_init/bdi_destroy functions are present])
 ],[
-        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
 
 # 2.6.26 isn't export set_fs_pwd and change paramter in fs struct
 AC_DEFUN([LC_FS_STRUCT_USE_PATH],
@@ -1283,10 +1448,9 @@ LB_LINUX_TRY_COMPILE([
         #include <linux/spinlock.h>
         #include <linux/fs_struct.h>
 ],[
-        struct path path;
         struct fs_struct fs;
 
-        fs.pwd = path;
+        fs.pwd = *((struct path *)sizeof(fs));
 ], [
         AC_MSG_RESULT([yes])
         AC_DEFINE(HAVE_FS_STRUCT_USE_PATH, 1,
@@ -1296,495 +1460,648 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+
 #
-# LC_VFS_INTENT_PATCHES
+# 2.6.27
 #
-# check if the kernel has the VFS intent patches
-AC_DEFUN([LC_VFS_INTENT_PATCHES],
-[AC_MSG_CHECKING([if the kernel has the VFS intent patches])
+AC_DEFUN([LC_PGMKWRITE_USE_VMFAULT],
+[AC_MSG_CHECKING([kernel .page_mkwrite uses struct vm_fault *])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
 LB_LINUX_TRY_COMPILE([
-       #include <linux/fs.h>
-        #include <linux/namei.h>
+        #include <linux/mm.h>
 ],[
-        struct nameidata nd;
-        struct lookup_intent *it;
+        ((struct vm_operations_struct *)0)->page_mkwrite((struct vm_area_struct *)0, (struct vm_fault *)0);
+], [
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_PGMKWRITE_USE_VMFAULT, 1,
+                [kernel vm_operation_struct.page_mkwrite uses struct vm_fault * as second parameter])
+],[
+        AC_MSG_RESULT([no])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
 
-        it = &nd.intent;
-        intent_init(it, IT_OPEN);
-        it->d.lustre.it_disposition = 0;
-        it->d.lustre.it_data = NULL;
+AC_DEFUN([LC_INODE_PERMISION_2ARGS],
+[AC_MSG_CHECKING([inode_operations->permission has 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 has two args])
         AC_MSG_RESULT([yes])
-        AC_DEFINE(HAVE_VFS_INTENT_PATCHES, 1, [VFS intent patches are applied])
 ],[
         AC_MSG_RESULT([no])
 ])
 ])
 
-AC_DEFUN([LC_S_TIME_GRAN],
-[AC_MSG_CHECKING([if super block has s_time_gran member])
+# 2.6.27 has file_remove_suid instead of remove_suid
+AC_DEFUN([LC_FILE_REMOVE_SUID],
+[AC_MSG_CHECKING([kernel has file_remove_suid])
 LB_LINUX_TRY_COMPILE([
         #include <linux/fs.h>
 ],[
-       struct super_block sb;
+        file_remove_suid(NULL);
+],[
+        AC_DEFINE(HAVE_FILE_REMOVE_SUID, 1,
+                  [kernel have file_remove_suid])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
 
-        return sb.s_time_gran;
+# 2.6.27 have new page locking API
+AC_DEFUN([LC_TRYLOCKPAGE],
+[AC_MSG_CHECKING([kernel uses trylock_page for page lock])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/pagemap.h>
 ],[
-       AC_MSG_RESULT([yes])
-       AC_DEFINE(HAVE_S_TIME_GRAN, 1, [super block has s_time_gran member])
+        trylock_page(NULL);
+],[
+        AC_DEFINE(HAVE_TRYLOCK_PAGE, 1,
+                  [kernel uses trylock_page for page lock])
+        AC_MSG_RESULT([yes])
 ],[
         AC_MSG_RESULT([no])
 ])
 ])
 
-AC_DEFUN([LC_SB_TIME_GRAN],
-[AC_MSG_CHECKING([if kernel has old get_sb_time_gran])
+# 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>
 ],[
-       return get_sb_time_gran(NULL);
+        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_DEFINE(HAVE_SB_TIME_GRAN, 1, [kernel has old get_sb_time_gran])
 ],[
         AC_MSG_RESULT([no])
 ])
 ])
 
-#
-# LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
-#
-# Check for our patched grab_cache_page_nowait_gfp() function
-# after 2.6.29 we can emulate this using add_to_page_cache_lru()
-#
-AC_DEFUN([LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP],
-[LB_CHECK_SYMBOL_EXPORT([grab_cache_page_nowait_gfp],
-[mm/filemap.c],[
-        AC_DEFINE(HAVE_GRAB_CACHE_PAGE_NOWAIT_GFP, 1,
-                  [kernel exports grab_cache_page_nowait_gfp])
-        ],
-        [LB_CHECK_SYMBOL_EXPORT([add_to_page_cache_lru],
-        [mm/filemap.c],[
-                AC_DEFINE(HAVE_ADD_TO_PAGE_CACHE_LRU, 1,
-                        [kernel exports add_to_page_cache_lru])
-        ],[
-        ])
-        ])
+# 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.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"
+# 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/fs.h>
+        #include <linux/quota.h>
 ],[
-       struct address_space a;
+        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])
+])
+])
 
-       write_lock(&a.tree_lock);
+# 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_DEFINE(HAVE_RW_TREE_LOCK, 1, [kernel has tree_lock as rw_lock])
 ],[
         AC_MSG_RESULT([no])
 ])
-EXTRA_KCFLAGS="$tmp_flags"
 ])
 
-AC_DEFUN([LC_CONST_ACL_SIZE],
-[AC_MSG_CHECKING([calc acl size])
-tmp_flags="$CFLAGS"
-CFLAGS="$CFLAGS -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 $EXTRA_KCFLAGS"
-AC_TRY_RUN([
-#define __KERNEL__
-#include <linux/autoconf.h>
-#include <linux/types.h>
-#undef __KERNEL__
-// block include
-#define __LINUX_POSIX_ACL_H
-
-# ifdef CONFIG_FS_POSIX_ACL
-#  ifdef HAVE_XATTR_ACL
-#   include <linux/xattr_acl.h>
-#  endif
-#  ifdef HAVE_LINUX_POSIX_ACL_XATTR_H
-#   include <linux/posix_acl_xattr.h>
-#  endif
-# endif
-
-#include <lustre_acl.h>
-
-#include <stdio.h>
-
-int main(void)
-{
-    int size = mds_xattr_acl_size(LUSTRE_POSIX_ACL_MAX_ENTRIES);
-    FILE *f = fopen("acl.size","w+");
-    fprintf(f,"%d", size);
-    fclose(f);
-
-    return 0;
-}
-
+# LC_LOCK_MAP_ACQUIRE
+# after 2.6.27 lock_map_acquire replaces lock_acquire
+AC_DEFUN([LC_LOCK_MAP_ACQUIRE],
+[AC_MSG_CHECKING([if lock_map_acquire is defined])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/lockdep.h>
 ],[
-       acl_size=`cat acl.size`
-       AC_MSG_RESULT([ACL size $acl_size])
-        AC_DEFINE_UNQUOTED(XATTR_ACL_SIZE, AS_TR_SH([$acl_size]), [size of xattr acl])
+        lock_map_acquire(NULL);
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_LOCK_MAP_ACQUIRE, 1,
+                [lock_map_acquire is defined])
 ],[
-        AC_ERROR([ACL size can't computed])
+        AC_MSG_RESULT(no)
 ])
-CFLAGS="$tmp_flags"
 ])
 
-#
-# check for crypto API
-#
-AC_DEFUN([LC_ASYNC_BLOCK_CIPHER],
-[AC_MSG_CHECKING([if kernel has block cipher support])
+# 2.6.27.15-2 sles11
+
+# 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/err.h>
-        #include <linux/crypto.h>
+        #include <linux/bio.h>
 ],[
-        struct crypto_blkcipher *tfm;
-        tfm = crypto_alloc_blkcipher("aes", 0, 0 );
+        struct bio io;
+        io.bi_hw_segments = sizeof(io);
 ],[
+        AC_DEFINE(HAVE_BI_HW_SEGMENTS, 1,
+                [struct bio has a bi_hw_segments field])
         AC_MSG_RESULT([yes])
-        AC_DEFINE(HAVE_ASYNC_BLOCK_CIPHER, 1, [kernel has block cipher support])
 ],[
         AC_MSG_RESULT([no])
 ])
 ])
 
 #
-# check for struct hash_desc
-#
-AC_DEFUN([LC_STRUCT_HASH_DESC],
-[AC_MSG_CHECKING([if kernel has struct hash_desc])
+# 2.6.27 sles11 move the quotaio_v1{2}.h from include/linux to fs
+# 2.6.32 move the quotaio_v1{2}.h from fs to fs/quota
+AC_DEFUN([LC_HAVE_QUOTAIO_H],
+[LB_CHECK_FILE([$LINUX/include/linux/quotaio_v2.h],[
+        AC_DEFINE(HAVE_QUOTAIO_H, 1,
+                [kernel has include/linux/quotaio_v2.h])
+],[LB_CHECK_FILE([$LINUX/fs/quotaio_v2.h],[
+               AC_DEFINE(HAVE_FS_QUOTAIO_H, 1,
+                [kernel has fs/quotaio_v1.h])
+],[LB_CHECK_FILE([$LINUX/fs/quota/quotaio_v2.h],[
+               AC_DEFINE(HAVE_FS_QUOTA_QUOTAIO_H, 1,
+                [kernel has fs/quota/quotaio_v2.h])
+],[
+        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/err.h>
-        #include <linux/crypto.h>
+        #include <linux/quotaops.h>
 ],[
-        struct hash_desc foo;
+        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_DEFINE(HAVE_STRUCT_HASH_DESC, 1, [kernel has struct hash_desc])
 ],[
         AC_MSG_RESULT([no])
 ])
 ])
 
-#
-# check for struct blkcipher_desc
-#
-AC_DEFUN([LC_STRUCT_BLKCIPHER_DESC],
-[AC_MSG_CHECKING([if kernel has struct blkcipher_desc])
+# 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/err.h>
-        #include <linux/crypto.h>
+        #include <linux/quotaops.h>
 ],[
-        struct blkcipher_desc foo;
+        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_DEFINE(HAVE_STRUCT_BLKCIPHER_DESC, 1, [kernel has struct blkcipher_desc])
 ],[
         AC_MSG_RESULT([no])
 ])
 ])
 
+# 2.6.27 exported add_to_page_cache_lru.
+AC_DEFUN([LC_EXPORT_ADD_TO_PAGE_CACHE_LRU],
+[LB_CHECK_SYMBOL_EXPORT([add_to_page_cache_lru],
+[mm/filemap.c],[
+        AC_DEFINE(HAVE_ADD_TO_PAGE_CACHE_LRU, 1,
+                [add_to_page_cache_lru functions are present])
+],[
+])
+])
+
 #
-# 2.6.19 check for FS_RENAME_DOES_D_MOVE flag
+# 2.6.29 introduce sb_any_quota_loaded.
 #
-AC_DEFUN([LC_FS_RENAME_DOES_D_MOVE],
-[AC_MSG_CHECKING([if kernel has FS_RENAME_DOES_D_MOVE flag])
+AC_DEFUN([LC_SB_ANY_QUOTA_LOADED],
+[AC_MSG_CHECKING([Kernel has sb_any_quota_loaded])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/fs.h>
+        #include <linux/quotaops.h>
 ],[
-        int v = FS_RENAME_DOES_D_MOVE;
+        sb_any_quota_loaded(NULL);
 ],[
+        AC_DEFINE(HAVE_SB_ANY_QUOTA_LOADED, 1,
+                [Kernel has a sb_any_quota_loaded])
         AC_MSG_RESULT([yes])
-        AC_DEFINE(HAVE_FS_RENAME_DOES_D_MOVE, 1, [kernel has FS_RENAME_DOES_D_MOVE flag])
 ],[
         AC_MSG_RESULT([no])
 ])
 ])
 
-#
-# LC_FUNC_F_OP_FLOCK
-#
-# rhel4.2 kernel has f_op->flock field
-#
-AC_DEFUN([LC_FUNC_F_OP_FLOCK],
-[AC_MSG_CHECKING([if struct file_operations has flock field])
+# 2.6.30 x86 node_to_cpumask has been removed. must use cpumask_of_node
+AC_DEFUN([LC_EXPORT_CPUMASK_OF_NODE],
+         [LB_CHECK_SYMBOL_EXPORT([node_to_cpumask_map],
+                                 [arch/$LINUX_ARCH/mm/numa.c],
+                                 [AC_DEFINE(HAVE_CPUMASK_OF_NODE, 1,
+                                            [node_to_cpumask_map is exported by
+                                             the kernel])]) # x86_64
+         ])
+
+# 2.6.31 replaces blk_queue_hardsect_size by blk_queue_logical_block_size function
+AC_DEFUN([LC_BLK_QUEUE_LOG_BLK_SIZE],
+[AC_MSG_CHECKING([if blk_queue_logical_block_size is defined])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/fs.h>
+        #include <linux/blkdev.h>
 ],[
-        struct file_operations ll_file_operations_flock;
-        ll_file_operations_flock.flock = NULL;
+        blk_queue_logical_block_size(NULL, 0);
 ],[
-        AC_DEFINE(HAVE_F_OP_FLOCK, 1,
-                [struct file_operations has flock field])
-        AC_MSG_RESULT([yes])
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_BLK_QUEUE_LOG_BLK_SIZE, 1,
+                  [blk_queue_logical_block_size is defined])
 ],[
-        AC_MSG_RESULT([no])
+        AC_MSG_RESULT(no)
+])
 ])
+
+# 2.6.32
+
+# 2.6.32 changes cache_detail's member cache_request to cache_upcall
+# in kernel commit bc74b4f5e63a09fb78e245794a0de1e5a2716bbe
+AC_DEFUN([LC_CACHE_UPCALL],
+[AC_MSG_CHECKING([if cache_detail has cache_upcall field])
+        LB_LINUX_TRY_COMPILE([
+                #include <linux/sunrpc/cache.h>
+        ],[
+                struct cache_detail cd;
+                cd.cache_upcall = NULL;
+        ],[
+                AC_MSG_RESULT(yes)
+                AC_DEFINE(HAVE_CACHE_UPCALL, 1,
+                          [cache_detail has cache_upcall field])
+        ],[
+                AC_MSG_RESULT(no)
+        ])
 ])
 
-# 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])
+# 2.6.32 add a limits member in struct request_queue.
+AC_DEFUN([LC_REQUEST_QUEUE_LIMITS],
+[AC_MSG_CHECKING([if request_queue has a limits field])
 LB_LINUX_TRY_COMPILE([
-       #include <linux/fs.h>
+        #include <linux/blkdev.h>
 ],[
-       struct inode *dir;
-       struct dentry *dentry;
-       const char *oldname = NULL;
-       int mode = 0;
-
-       vfs_symlink(dir, dentry, oldname, mode);
+        struct request_queue rq;
+        rq.limits.io_min = 0;
 ],[
         AC_MSG_RESULT(yes)
-        AC_DEFINE(HAVE_4ARGS_VFS_SYMLINK, 1,
-                  [vfs_symlink wants 4 args])
+        AC_DEFINE(HAVE_REQUEST_QUEUE_LIMITS, 1,
+                  [request_queue has a limits field])
 ],[
         AC_MSG_RESULT(no)
 ])
 ])
 
-# 2.6.23 has new shrinker API
-AC_DEFUN([LC_REGISTER_SHRINKER],
-[LB_CHECK_SYMBOL_EXPORT([register_shrinker],
-[mm/vmscan.c],[
-        AC_DEFINE(HAVE_REGISTER_SHRINKER, 1,
-                  [kernel exports register_shrinker])
+# 2.6.32 has bdi_register() functions.
+AC_DEFUN([LC_EXPORT_BDI_REGISTER],
+[LB_CHECK_SYMBOL_EXPORT([bdi_register],
+[mm/backing-dev.c],[
+        AC_DEFINE(HAVE_BDI_REGISTER, 1,
+                [bdi_register function is present])
 ],[
 ])
 ])
 
-#2.6.27
-AC_DEFUN([LC_INODE_PERMISION_2ARGS],
-[AC_MSG_CHECKING([inode_operations->permission has two args])
+# 2.6.32 add s_bdi for super block
+AC_DEFUN([LC_SB_BDI],
+[AC_MSG_CHECKING([if super_block has s_bdi field])
 LB_LINUX_TRY_COMPILE([
         #include <linux/fs.h>
 ],[
-        struct inode *inode;
-
-        inode->i_op->permission(NULL,0);
+        struct super_block sb;
+        sb.s_bdi = NULL;
 ],[
-        AC_DEFINE(HAVE_INODE_PERMISION_2ARGS, 1, 
-                  [inode_operations->permission has two args])
-        AC_MSG_RESULT([yes])
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_SB_BDI, 1,
+                  [super_block has s_bdi field])
 ],[
-        AC_MSG_RESULT([no])
+        AC_MSG_RESULT(no)
 ])
 ])
 
-# 2.6.27 has file_remove_suid instead of remove_suid
-AC_DEFUN([LC_FILE_REMOVE_SUID],
-[AC_MSG_CHECKING([kernel has file_remove_suid])
+#  2.6.27.15-2 SuSE 11 sp0 kernels lack the name field for BDI
+AC_DEFUN([LC_BDI_NAME],
+[AC_MSG_CHECKING([if backing_device_info has name field])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/fs.h>
+        #include <linux/blkkdev.h>
 ],[
-        file_remove_suid(NULL);
+        struct backing_dev_info bdi;
+        bdi.name = NULL;
 ],[
-        AC_DEFINE(HAVE_FILE_REMOVE_SUID, 1,
-                  [kernel have file_remove_suid])
-        AC_MSG_RESULT([yes])
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_BDI_NAME, 1,
+                  [backing_device_info has name field])
 ],[
-        AC_MSG_RESULT([no])
-])
+        AC_MSG_RESULT(no)
 ])
+])  
 
-# 2.6.27 have new page locking API
-AC_DEFUN([LC_TRYLOCKPAGE],
-[AC_MSG_CHECKING([kernel uses trylock_page for page lock])
+# 2.6.32 removes blk_queue_max_sectors and add blk_queue_max_hw_sectors
+# check blk_queue_max_sectors and use it until disappear.
+AC_DEFUN([LC_BLK_QUEUE_MAX_SECTORS],
+[AC_MSG_CHECKING([if blk_queue_max_sectors is defined])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/pagemap.h>
+        #include <linux/blkdev.h>
 ],[
-        trylock_page(NULL);
+        blk_queue_max_sectors(NULL, 0);
 ],[
-        AC_DEFINE(HAVE_TRYLOCK_PAGE, 1,
-                  [kernel uses trylock_page for page lock])
-        AC_MSG_RESULT([yes])
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_BLK_QUEUE_MAX_SECTORS, 1,
+                  [blk_queue_max_sectors is defined])
 ],[
-        AC_MSG_RESULT([no])
+        AC_MSG_RESULT(no)
 ])
 ])
 
-# 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])
+# 2.6.32 replaces 2 functions blk_queue_max_phys_segments and blk_queue_max_hw_segments by blk_queue_max_segments
+AC_DEFUN([LC_BLK_QUEUE_MAX_SEGMENTS],
+[AC_MSG_CHECKING([if blk_queue_max_segments is defined])
 LB_LINUX_TRY_COMPILE([
-       #include <linux/fs.h>
+        #include <linux/blkdev.h>
 ],[
-       struct inode *dir;
-       struct dentry *dentry;
-       const char *oldname = NULL;
-       int mode = 0;
-
-       vfs_symlink(dir, dentry, oldname, mode);
+        blk_queue_max_segments(NULL, 0);
 ],[
         AC_MSG_RESULT(yes)
-        AC_DEFINE(HAVE_4ARGS_VFS_SYMLINK, 1,
-                  [vfs_symlink wants 4 args])
+        AC_DEFINE(HAVE_BLK_QUEUE_MAX_SEGMENTS, 1,
+                  [blk_queue_max_segments is defined])
 ],[
         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])
+#
+# LC_QUOTA64
+#
+# Check if kernel has been patched for 64-bit quota limits support.
+# The upstream version of this patch in RHEL6 2.6.32 kernels introduces
+# the constant QFMT_VFS_V1 in include/linux/quota.h, so we can check for
+# that in the absence of quotaio_v1.h in the kernel headers.
+#
+AC_DEFUN([LC_QUOTA64],[
+        AC_MSG_CHECKING([if kernel has 64-bit quota limits support])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-I$LINUX/fs"
+        LB_LINUX_TRY_COMPILE([
+                #include <linux/kernel.h>
+                #include <linux/fs.h>
+                #ifdef HAVE_QUOTAIO_H
+                # include <linux/quotaio_v2.h>
+                int versions[] = V2_INITQVERSIONS_R1;
+                struct v2_disk_dqblk_r1 dqblk_r1;
+                #elif defined(HAVE_FS_QUOTA_QUOTAIO_H)
+                # include <quota/quotaio_v2.h>
+                struct v2r1_disk_dqblk dqblk_r1;
+                #elif defined(HAVE_FS_QUOTAIO_H)
+                # include <quotaio_v2.h>
+                struct v2r1_disk_dqblk dqblk_r1;
+                #else
+                #include <linux/quota.h>
+                int ver = QFMT_VFS_V1;
+                #endif
+        ],[],[
+                AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
+                AC_MSG_RESULT([yes])
+        ],[
+                LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
+                        AC_MSG_ERROR([You have got no 64-bit kernel quota support.])
+                ],[])
+                AC_MSG_RESULT([no])
+        ])
+EXTRA_KCFLAGS=$tmp_flags
+])
+
+# 2.6.32 set_cpus_allowed is no more defined if CONFIG_CPUMASK_OFFSTACK=yes
+AC_DEFUN([LC_SET_CPUS_ALLOWED],
+         [AC_MSG_CHECKING([if kernel defines set_cpus_allowed])
+          LB_LINUX_TRY_COMPILE(
+                [#include <linux/sched.h>],
+                [struct task_struct *p = NULL;
+                 cpumask_t mask = { { 0 } };
+                 (void) set_cpus_allowed(p, mask);],
+                [AC_MSG_RESULT([yes])
+                 AC_DEFINE(HAVE_SET_CPUS_ALLOWED, 1,
+                           [set_cpus_allowed is exported by the kernel])],
+                [AC_MSG_RESULT([no])] )])
+
+#
+# LC_D_OBTAIN_ALIAS
+# starting from 2.6.28 kernel replaces d_alloc_anon() with
+# d_obtain_alias() for getting anonymous dentries
+# RHEL5(2.6.18) has d_obtain_alias but SLES11SP0(2.6.27) not
+#
+AC_DEFUN([LC_D_OBTAIN_ALIAS],
+[AC_MSG_CHECKING([d_obtain_alias exist in kernel])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/bio.h>
+        #include <linux/dcache.h>
 ],[
-        struct bio io;
-        io.bi_hw_segments = 0;
+        d_obtain_alias(NULL);
 ],[
-        AC_DEFINE(HAVE_BI_HW_SEGMENTS, 1,
-                [struct bio has a bi_hw_segments field])
+        AC_DEFINE(HAVE_D_OBTAIN_ALIAS, 1,
+                [d_obtain_alias exist in kernel])
         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])
-])
-])
+#
+# LC_EXPORT_GENERIC_ERROR_REMOVE_PAGE
+#
+AC_DEFUN([LC_EXPORT_GENERIC_ERROR_REMOVE_PAGE],
+         [LB_CHECK_SYMBOL_EXPORT(
+                        [generic_error_remove_page],
+                        [mm/truncate.c],
+                        [AC_DEFINE(HAS_GENERIC_ERROR_REMOVE_PAGE, 1,
+                                [kernel export generic_error_remove_page])],
+                        [])
+         ]
+)
 
-# sles10 sp2 need 5 parameter for vfs_symlink
-AC_DEFUN([LC_VFS_SYMLINK_5ARGS],
-[AC_MSG_CHECKING([vfs_symlink need 5 parameter])
+#
+# 2.6.36 fs_struct.lock use spinlock instead of rwlock.
+#
+AC_DEFUN([LC_FS_STRUCT_RWLOCK],
+[AC_MSG_CHECKING([if fs_struct.lock use rwlock])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/fs.h>
+        #include <asm/atomic.h>
+        #include <linux/spinlock.h>
+        #include <linux/fs_struct.h>
 ],[
-        struct inode *dir = NULL;
-        struct dentry *dentry = NULL;
-        struct vfsmount *mnt = NULL;
-        const char * path = NULL;
-        vfs_symlink(dir, dentry, mnt, path, 0);
+        ((struct fs_struct *)0)->lock = (rwlock_t){ 0 };
 ],[
-        AC_DEFINE(HAVE_VFS_SYMLINK_5ARGS, 1,
-                [vfs_symlink need 5 parameteres])
+        AC_DEFINE(HAVE_FS_STRUCT_RWLOCK, 1,
+                  [fs_struct.lock use rwlock])
         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])
+#
+# 2.6.36 super_operations add evict_inode method. it hybird of
+# delete_inode & clear_inode.
+#
+AC_DEFUN([LC_SBOPS_EVICT_INODE],
+[AC_MSG_CHECKING([if super_operations.evict_inode exist])
 LB_LINUX_TRY_COMPILE([
         #include <linux/fs.h>
 ],[
-        struct super_operations *sop;
-        sop->read_inode(NULL);
+        ((struct super_operations *)0)->evict_inode(NULL);
 ],[
-        AC_DEFINE(HAVE_READ_INODE_IN_SBOPS, 1,
-                [super_operations has a read_inode])
+        AC_DEFINE(HAVE_SBOPS_EVICT_INODE, 1,
+                [super_operations.evict_inode() is exist in kernel])
         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])
+#
+# 2.6.35 file_operations.fsync taken 2 arguments.
+# 3.0.0 file_operations.fsync takes 4 arguments.
+#
+AC_DEFUN([LC_FILE_FSYNC],
+[AC_MSG_CHECKING([if file_operations.fsync takes 4 or 2 arguments])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/quotaops.h>
+        #include <linux/fs.h>
 ],[
-        sb_any_quota_active(NULL);
+        ((struct file_operations *)0)->fsync(NULL, 0, 0, 0);
 ],[
-        AC_DEFINE(HAVE_SB_ANY_QUOTA_ACTIVE, 1,
-                [Kernel has a sb_any_quota_active])
-        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_FILE_FSYNC_4ARGS, 1,
+                [file_operations.fsync takes 4 arguments])
+        AC_MSG_RESULT([yes, 4 args])
 ],[
-        AC_MSG_RESULT([no])
+        LB_LINUX_TRY_COMPILE([
+                #include <linux/fs.h>
+        ],[
+           ((struct file_operations *)0)->fsync(NULL, 0);
+        ],[
+                AC_DEFINE(HAVE_FILE_FSYNC_2ARGS, 1,
+                        [file_operations.fsync takes 2 arguments])
+                AC_MSG_RESULT([yes, 2 args])
+        ],[
+                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])
+#
+# 2.6.38 export blkdev_get_by_dev
+#
+AC_DEFUN([LC_BLKDEV_GET_BY_DEV],
+[LB_CHECK_SYMBOL_EXPORT([blkdev_get_by_dev],
+[fs/block_dev.c],[
+AC_DEFINE(HAVE_BLKDEV_GET_BY_DEV, 1,
+            [blkdev_get_by_dev is exported by the kernel])
+],[
+])
+])
+
+#
+# 2.6.38 vfsmount.mnt_count doesn't use atomic_t
+#
+AC_DEFUN([LC_ATOMIC_MNT_COUNT],
+[AC_MSG_CHECKING([if vfsmount.mnt_count is atomic_t])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/quotaops.h>
+        #include <asm/atomic.h>
+        #include <linux/fs.h>
+        #include <linux/mount.h>
 ],[
-        sb_has_quota_active(NULL, 0);
+        ((struct vfsmount *)0)->mnt_count = ((atomic_t) { 0 });
 ],[
-        AC_DEFINE(HAVE_SB_HAS_QUOTA_ACTIVE, 1,
-                [Kernel has a sb_has_quota_active])
+        AC_DEFINE(HAVE_ATOMIC_MNT_COUNT, 1,
+                [vfsmount.mnt_count is atomic_t])
         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])
+#
+# 2.6.38 use path as 4th parameter in quota_on.
+#
+AC_DEFUN([LC_QUOTA_ON_USE_PATH],
+[AC_MSG_CHECKING([quota_on use path as parameter])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
 LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
         #include <linux/quota.h>
 ],[
-        struct quotactl_ops *qop;
-        qop->quota_on(NULL, 0, 0, NULL, 0);
+        ((struct quotactl_ops *)0)->quota_on(NULL, 0, 0, ((struct path*)0));
 ],[
-        AC_DEFINE(HAVE_QUOTA_ON_5ARGS, 1,
-                [quota_on needs 5 paramters])
+        AC_DEFINE(HAVE_QUOTA_ON_USE_PATH, 1,
+                [quota_on use path as 4th paramter])
         AC_MSG_RESULT([yes])
 ],[
         AC_MSG_RESULT([no])
 ])
+EXTRA_KCFLAGS="$tmp_flags"
 ])
 
-# 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])
+#
+# 2.6.39 remove unplug_fn from request_queue.
+#
+AC_DEFUN([LC_REQUEST_QUEUE_UNPLUG_FN],
+[AC_MSG_CHECKING([if request_queue has unplug_fn field])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/quota.h>
+        #include <linux/blkdev.h>
 ],[
-        struct quotactl_ops *qop;
-        qop->quota_off(NULL, 0, 0);
+        do{ }while(sizeof(((struct request_queue *)0)->unplug_fn));
 ],[
-        AC_DEFINE(HAVE_QUOTA_OFF_3ARGS, 1,
-                [quota_off needs 3 paramters])
+        AC_DEFINE(HAVE_REQUEST_QUEUE_UNPLUG_FN, 1,
+                  [request_queue has unplug_fn field])
         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])
+#
+# 2.6.38 generic_permission taken 4 paremater.
+# in fact, it means rcu-walk aware permission bring.
+#
+AC_DEFUN([LC_GENERIC_PERMISSION],
+[AC_MSG_CHECKING([if generic_permission take 4 arguments])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/quotaops.h>
+        #include <linux/fs.h>
 ],[
-        vfs_dq_off(NULL, 0);
+        generic_permission(NULL, 0, 0, NULL);
 ],[
-        AC_DEFINE(HAVE_VFS_DQ_OFF, 1, [vfs_dq_off is defined])
+        AC_DEFINE(HAVE_GENERIC_PERMISSION_4ARGS, 1,
+                  [generic_permission taken 4 arguments])
         AC_MSG_RESULT([yes])
 ],[
         AC_MSG_RESULT([no])
@@ -1792,25 +2109,15 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
-# LC_LINUX_FIEMAP_H
-#
-# If we have fiemap.h
-# after 2.6.27 use fiemap.h in include/linux
+# 2.6.38 export simple_setattr
 #
-AC_DEFUN([LC_LINUX_FIEMAP_H],
-[LB_CHECK_FILE([$LINUX/include/linux/fiemap.h],[
-        AC_MSG_CHECKING([if fiemap.h can be compiled])
-        LB_LINUX_TRY_COMPILE([
-                #include <linux/types.h>
-                #include <linux/fiemap.h>
-        ],[],[
-                AC_MSG_RESULT([yes])
-                AC_DEFINE(HAVE_LINUX_FIEMAP_H, 1, [Kernel has fiemap.h])
-        ],[
-                AC_MSG_RESULT([no])
-        ])
-],
-[])
+AC_DEFUN([LC_EXPORT_SIMPLE_SETATTR],
+[LB_CHECK_SYMBOL_EXPORT([simple_setattr],
+[fs/libfs.c],[
+AC_DEFINE(HAVE_SIMPLE_SETATTR, 1,
+            [simple_setattr is exported by the kernel])
+],[
+])
 ])
 
 #
@@ -1820,37 +2127,23 @@ AC_DEFUN([LC_LINUX_FIEMAP_H],
 #
 AC_DEFUN([LC_PROG_LINUX],
          [LC_LUSTRE_VERSION_H
-         if test x$enable_server = xyes ; then
-             AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
-             LC_FUNC_DEV_SET_RDONLY
-             LC_STACK_SIZE
-             LC_CONFIG_BACKINGFS
-         fi
          LC_CONFIG_PINGER
          LC_CONFIG_CHECKSUM
          LC_CONFIG_LIBLUSTRE_RECOVERY
          LC_CONFIG_HEALTH_CHECK_WRITE
          LC_CONFIG_LRU_RESIZE
          LC_QUOTA_MODULE
+         LC_LLITE_LLOOP_MODULE
 
          # RHEL4 patches
          LC_EXPORT_TRUNCATE_COMPLETE
-         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_HEADER_LDISKFS_XATTR
-         LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
-         LC_STRUCT_STATFS
          LC_FILEMAP_POPULATE
-         LC_D_ADD_UNIQUE
          LC_BIT_SPINLOCK_H
 
-         LC_XATTR_ACL
-         LC_POSIX_ACL_XATTR_H
          LC_CONST_ACL_SIZE
 
          LC_STRUCT_INTENT_FILE
@@ -1858,18 +2151,13 @@ AC_DEFUN([LC_PROG_LINUX],
          LC_CAPA_CRYPTO
          LC_CONFIG_RMTCLIENT
          LC_CONFIG_GSS
-         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
+         LC_TASK_CLENV_STORE
 
          # ~2.6.11
          LC_S_TIME_GRAN
@@ -1877,7 +2165,6 @@ AC_DEFUN([LC_PROG_LINUX],
 
          # 2.6.12
          LC_RW_TREE_LOCK
-         LC_EXPORT_SYNCHRONIZE_RCU
 
          # 2.6.15
          LC_INODE_I_MUTEX
@@ -1897,6 +2184,7 @@ AC_DEFUN([LC_PROG_LINUX],
          LC_UMOUNTBEGIN_HAS_VFSMOUNT
          LC_SEQ_LOCK
          LC_EXPORT_FILEMAP_FDATAWRITE_RANGE
+         LC_FLUSH_OWNER_ID
          if test x$enable_server = xyes ; then
                 LC_EXPORT_INVALIDATE_MAPPING_PAGES
          fi
@@ -1908,7 +2196,6 @@ AC_DEFUN([LC_PROG_LINUX],
 
          # 2.6.19
          LC_INODE_BLKSIZE
-         LC_VFS_READDIR_U64_INO
          LC_FILE_WRITEV
          LC_FILE_READV
 
@@ -1924,27 +2211,28 @@ AC_DEFUN([LC_PROG_LINUX],
          LC_STRUCT_HASH_DESC
          LC_STRUCT_BLKCIPHER_DESC
          LC_FS_RENAME_DOES_D_MOVE
+
          # 2.6.23
          LC_UNREGISTER_BLKDEV_RETURN_INT
          LC_KERNEL_SPLICE_READ
          LC_KERNEL_SENDFILE
          LC_HAVE_EXPORTFS_H
          LC_VM_OP_FAULT
-         LC_REGISTER_SHRINKER
-  
-        # 2.6.24
-        LC_HAVE_MMTYPES_H
+         LC_PROCFS_USERS
+         LC_EXPORTFS_DECODE_FH
+
+         # 2.6.24
+         LC_HAVE_MMTYPES_H
          LC_BIO_ENDIO_2ARG
          LC_FH_TO_DENTRY
          LC_PROCFS_DELETED
+         LC_EXPORT_BDI_INIT
 
-         #2.6.25
-         LC_MAPPING_CAP_WRITEBACK_DIRTY
-  
          # 2.6.26
          LC_FS_STRUCT_USE_PATH
 
          # 2.6.27
+         LC_PGMKWRITE_USE_VMFAULT
          LC_INODE_PERMISION_2ARGS
          LC_FILE_REMOVE_SUID
          LC_TRYLOCKPAGE
@@ -1953,13 +2241,59 @@ AC_DEFUN([LC_PROG_LINUX],
          LC_QUOTA_ON_5ARGS
          LC_QUOTA_OFF_3ARGS
          LC_VFS_DQ_OFF
+         LC_LOCK_MAP_ACQUIRE
 
          # 2.6.27.15-2 sles11
          LC_BI_HW_SEGMENTS
-         LC_HAVE_QUOTAIO_V1_H
-         LC_VFS_SYMLINK_5ARGS
+         LC_HAVE_QUOTAIO_H
+         LC_BDI_NAME
          LC_SB_ANY_QUOTA_ACTIVE
          LC_SB_HAS_QUOTA_ACTIVE
+         LC_EXPORT_ADD_TO_PAGE_CACHE_LRU
+
+         # 2.6.29
+         LC_SB_ANY_QUOTA_LOADED
+
+         # 2.6.30
+         LC_EXPORT_CPUMASK_OF_NODE
+
+         # 2.6.31
+         LC_BLK_QUEUE_LOG_BLK_SIZE
+
+         # 2.6.32
+         LC_REQUEST_QUEUE_LIMITS
+         LC_EXPORT_BDI_REGISTER
+         LC_SB_BDI
+         LC_BLK_QUEUE_MAX_SECTORS
+         LC_BLK_QUEUE_MAX_SEGMENTS
+         LC_SET_CPUS_ALLOWED
+         LC_CACHE_UPCALL
+         LC_EXPORT_GENERIC_ERROR_REMOVE_PAGE
+
+         # 2.6.35, 3.0.0
+         LC_FILE_FSYNC
+         LC_EXPORT_SIMPLE_SETATTR
+
+         # 2.6.36
+         LC_FS_STRUCT_RWLOCK
+         LC_SBOPS_EVICT_INODE
+
+         # 2.6.38
+         LC_ATOMIC_MNT_COUNT
+         LC_BLKDEV_GET_BY_DEV
+         LC_GENERIC_PERMISSION
+         LC_QUOTA_ON_USE_PATH
+
+         # 2.6.39
+         LC_REQUEST_QUEUE_UNPLUG_FN
+
+         #
+         if test x$enable_server = xyes ; then
+             AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
+             LC_FUNC_DEV_SET_RDONLY
+             LC_STACK_SIZE
+             LC_QUOTA64
+         fi
 ])
 
 #
@@ -2074,6 +2408,26 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+# 2.6.29 split file and anonymous page queues
+AC_DEFUN([LC_PAGEVEC_LRU_ADD_FILE],
+[AC_MSG_CHECKING([if kernel has .pagevec_lru_add_file])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/mm.h>
+        #include <linux/pagevec.h>
+],[
+        struct pagevec lru_pagevec;
+
+        pagevec_init(&lru_pagevec, 0);
+        pagevec_lru_add_file(&lru_pagevec);
+],[
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_PAGEVEC_LRU_ADD_FILE, 1,
+                [kernel has .pagevec_lru_add_file])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
 #
 # --enable-mpitest
 #
@@ -2128,18 +2482,6 @@ LC_CONFIG_PINGER
 LC_CONFIG_LIBLUSTRE_RECOVERY
 ])
 
-AC_DEFUN([LC_CONFIG_LRU_RESIZE],
-[AC_MSG_CHECKING([whether to enable lru self-adjusting])
-AC_ARG_ENABLE([lru_resize],
-       AC_HELP_STRING([--enable-lru-resize],
-                       [enable lru resize support]),
-       [],[enable_lru_resize='yes'])
-AC_MSG_RESULT([$enable_lru_resize])
-if test x$enable_lru_resize != xno; then
-   AC_DEFINE(HAVE_LRU_RESIZE_SUPPORT, 1, [Enable lru resize support])
-fi
-])
-
 #
 # LC_CONFIG_QUOTA
 #
@@ -2152,19 +2494,6 @@ AC_DEFUN([LC_CONFIG_QUOTA],
        [],[enable_quota='yes'])
 ])
 
-# whether to enable quota support(kernel modules)
-AC_DEFUN([LC_QUOTA_MODULE],
-[if test x$enable_quota != xno; then
-    LB_LINUX_CONFIG([QUOTA],[
-       enable_quota_module='yes'
-       AC_DEFINE(HAVE_QUOTA_SUPPORT, 1, [Enable quota support])
-    ],[
-       enable_quota_module='no'
-       AC_MSG_WARN([quota is not enabled because the kernel - lacks quota support])
-    ])
-fi
-])
-
 AC_DEFUN([LC_QUOTA],
 [#check global
 LC_CONFIG_QUOTA
@@ -2174,21 +2503,6 @@ AC_CHECK_HEADER(sys/quota.h,
                 [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
 ])
 
-AC_DEFUN([LC_QUOTA_READ],
-[AC_MSG_CHECKING([if kernel supports quota_read])
-LB_LINUX_TRY_COMPILE([
-       #include <linux/fs.h>
-],[
-       struct super_operations sp;
-        void *i = (void *)sp.quota_read;
-],[
-       AC_MSG_RESULT([yes])
-       AC_DEFINE(KERNEL_SUPPORTS_QUOTA_READ, 1, [quota_read found])
-],[
-       AC_MSG_RESULT([no])
-])
-])
-
 #
 # LC_CONFIG_SPLIT
 #
@@ -2206,143 +2520,41 @@ if test x$enable_split != xno; then
 fi
 ])
 
-#
-# LC_COOKIE_FOLLOW_LINK
-#
-# kernel 2.6.13+ ->follow_link returns a cookie
-#
-
-AC_DEFUN([LC_COOKIE_FOLLOW_LINK],
-[AC_MSG_CHECKING([if inode_operations->follow_link returns a cookie])
+# RHEL5(2.6.18) has tux_info
+AC_DEFUN([LC_TASK_CLENV_TUX_INFO],
+[AC_MSG_CHECKING([tux_info])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/fs.h>
-        #include <linux/namei.h>
-],[
-        struct dentry dentry;
-        struct nameidata nd;
-
-        dentry.d_inode->i_op->put_link(&dentry, &nd, NULL);
+        #include <linux/sched.h>
 ],[
-        AC_DEFINE(HAVE_COOKIE_FOLLOW_LINK, 1, [inode_operations->follow_link returns a cookie])
-        AC_MSG_RESULT([yes])
+        struct task_struct task;
+        &task.tux_info;
 ],[
-        AC_MSG_RESULT([no])
-])
-])
-
-#
-# LC_FUNC_RCU
-#
-# kernels prior than 2.6.0(?) have no RCU supported; in kernel 2.6.5(SUSE),
-# call_rcu takes three parameters.
-#
-AC_DEFUN([LC_FUNC_RCU],
-[AC_MSG_CHECKING([if kernel have RCU supported])
-LB_LINUX_TRY_COMPILE([
-        #include <linux/rcupdate.h>
-],[],[
-        AC_DEFINE(HAVE_RCU, 1, [have RCU defined])
         AC_MSG_RESULT([yes])
-
-        AC_MSG_CHECKING([if call_rcu takes three parameters])
-        LB_LINUX_TRY_COMPILE([
-                #include <linux/rcupdate.h>
-        ],[
-                struct rcu_head rh;
-                call_rcu(&rh, (void (*)(struct rcu_head *))1, NULL);
-        ],[
-                AC_DEFINE(HAVE_CALL_RCU_PARAM, 1, [call_rcu takes three parameters])
-                AC_MSG_RESULT([yes])
-        ],[
-                AC_MSG_RESULT([no])
-        ])
-
+        AC_DEFINE(LL_TASK_CL_ENV, tux_info, [have tux_info])
+        have_task_clenv_store='yes'
 ],[
         AC_MSG_RESULT([no])
 ])
 ])
 
 #
-# LC_QUOTA64
-# linux kernel have 64-bit limits support
+# LC_LLITE_LLOOP_MODULE
+# lloop_llite.ko does not currently work with page sizes
+# of 64k or larger.
 #
-AC_DEFUN([LC_QUOTA64],
-[if test x$enable_quota_module = xyes -a x$enable_server = xyes ; then
-        AC_MSG_CHECKING([if kernel has 64-bit quota limits support])
-        LB_LINUX_TRY_COMPILE([
-                #include <linux/kernel.h>
-                #include <linux/fs.h>
-                #include <linux/quotaio_v2.h>
-                int versions[] = V2_INITQVERSIONS_R1;
-                struct v2_disk_dqblk_r1 dqblk_r1;
-        ],[],[
-                AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
-                AC_MSG_RESULT([yes])
-        ],[
-        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])
-        ],[
-                LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
-                        AC_MSG_ERROR([You have got no 64-bit kernel quota support.])
-                ],[])
-                AC_MSG_RESULT([no])
-        ])
-        EXTRA_KCFLAGS=$tmp_flags
-        ])
-fi
-])
-
-# LC_SECURITY_PLUG  # for SLES10 SP2
-# check security plug in sles10 sp2 kernel
-AC_DEFUN([LC_SECURITY_PLUG],
-[AC_MSG_CHECKING([If kernel has security plug support])
+AC_DEFUN([LC_LLITE_LLOOP_MODULE],
+[AC_MSG_CHECKING([whether to enable llite_lloop module])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/fs.h>
-],[
-        struct dentry   *dentry;
-        struct vfsmount *mnt;
-        struct iattr    *iattr;
-
-        notify_change(dentry, mnt, iattr);
+        #include <asm/page.h>
 ],[
-        AC_MSG_RESULT(yes)
-        AC_DEFINE(HAVE_SECURITY_PLUG, 1,
-                [SLES10 SP2 use extra parameter in vfs])
+        #if PAGE_SIZE >= 65536
+        #error "PAGE_SIZE >= 65536"
+        #endif
 ],[
-        AC_MSG_RESULT(no)
-])
-])
-
-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])
+        enable_llite_lloop_module='yes'
         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])
-        ])
 ],[
+        enable_llite_lloop_module='no'
         AC_MSG_RESULT([no])
 ])
 ])
@@ -2359,6 +2571,9 @@ if test $target_cpu == "i686" -o $target_cpu == "x86_64"; then
         CFLAGS="$CFLAGS -Werror"
 fi
 
+# maximum MDS thread count
+LC_MDS_MAX_THREADS
+
 # include/liblustre.h
 AC_CHECK_HEADERS([sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
 
@@ -2438,11 +2653,23 @@ if test x$enable_lu_ref = xyes ; then
         AC_DEFINE([USE_LU_REF], 1, [enable lu_ref reference tracking code])
 fi
 
+AC_ARG_ENABLE([pgstate-track],
+              AC_HELP_STRING([--enable-pgstate-track],
+                             [enable page state tracking]),
+              [enable_pgstat_track='yes'],[])
+AC_MSG_CHECKING([whether to enable page state tracking])
+AC_MSG_RESULT([$enable_pgstat_track])
+if test x$enable_pgstat_track = xyes ; then
+        AC_DEFINE([LUSTRE_PAGESTATE_TRACKING], 1,
+                  [enable page state tracking code])
+fi
+
          #2.6.29
          LC_WRITE_BEGIN_END
          LC_D_OBTAIN_ALIAS
          LC_BLKDEV_PUT_2ARGS
          LC_DENTRY_OPEN_4ARGS
+         LC_PAGEVEC_LRU_ADD_FILE
 
 ])
 
@@ -2466,6 +2693,7 @@ AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
+AM_CONDITIONAL(LLITE_LLOOP, test x$enable_llite_lloop_module = xyes)
 ])
 
 #
@@ -2478,21 +2706,21 @@ AC_DEFUN([LC_CONFIG_FILES],
 lustre/Makefile
 lustre/autoMakefile
 lustre/autoconf/Makefile
+lustre/conf/Makefile
 lustre/contrib/Makefile
 lustre/doc/Makefile
 lustre/include/Makefile
 lustre/include/lustre_ver.h
 lustre/include/linux/Makefile
+lustre/include/darwin/Makefile
 lustre/include/lustre/Makefile
-lustre/kernel_patches/targets/2.6-vanilla.target
-lustre/kernel_patches/targets/2.6-rhel4.target
+lustre/kernel_patches/targets/2.6-rhel6.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/2.6-oel5.target
 lustre/kernel_patches/targets/2.6-fc11.target
+lustre/kernel_patches/targets/2.6-fc12.target
 lustre/ldlm/Makefile
 lustre/fid/Makefile
 lustre/fid/autoMakefile
@@ -2531,8 +2759,8 @@ lustre/osc/Makefile
 lustre/osc/autoMakefile
 lustre/ost/Makefile
 lustre/ost/autoMakefile
-lustre/osd/Makefile
-lustre/osd/autoMakefile
+lustre/osd-ldiskfs/Makefile
+lustre/osd-ldiskfs/autoMakefile
 lustre/mgc/Makefile
 lustre/mgc/autoMakefile
 lustre/mgs/Makefile
@@ -2548,11 +2776,6 @@ lustre/tests/Makefile
 lustre/tests/mpi/Makefile
 lustre/utils/Makefile
 lustre/utils/gss/Makefile
+lustre/obdclass/darwin/Makefile
 ])
-case $lb_target_os in
-        darwin)
-                AC_CONFIG_FILES([ lustre/obdclass/darwin/Makefile ])
-                ;;
-esac
-
 ])