Whamcloud - gitweb
LU-13258 obdclass: bind zombie export cleanup workqueue
[fs/lustre-release.git] / lustre / autoconf / lustre-core.m4
index 227fd38..b3242f7 100644 (file)
@@ -5,7 +5,6 @@
 #
 AC_DEFUN([LC_CONFIG_SRCDIR], [
 AC_CONFIG_SRCDIR([lustre/obdclass/obdo.c])
-libcfs_is_module="yes"
 ldiskfs_is_ext4="yes"
 ])
 
@@ -103,7 +102,7 @@ AC_ARG_ENABLE([pinger],
        [], [enable_pinger="yes"])
 AC_MSG_RESULT([$enable_pinger])
 AS_IF([test "x$enable_pinger" != xno],
-       [AC_DEFINE(ENABLE_PINGER, 1,[Use the Pinger])])
+       [AC_DEFINE(CONFIG_LUSTRE_FS_PINGER, 1,[Use the Pinger])])
 ]) # LC_CONFIG_PINGER
 
 #
@@ -123,6 +122,22 @@ AS_IF([test "x$enable_checksum" != xno],
 ]) # LC_CONFIG_CHECKSUM
 
 #
+# LC_CONFIG_FLOCK
+#
+# enable distributed flock by default
+#
+AC_DEFUN([LC_CONFIG_FLOCK], [
+AC_MSG_CHECKING([whether to enable flock by default])
+AC_ARG_ENABLE([flock],
+       AC_HELP_STRING([--disable-flock],
+               [disable flock by default]),
+       [], [enable_flock="yes"])
+AC_MSG_RESULT([$enable_flock])
+AS_IF([test "x$enable_flock" != xno],
+       [AC_DEFINE(ENABLE_FLOCK, 1, [enable flock by default])])
+]) # LC_CONFIG_FLOCK
+
+#
 # LC_CONFIG_HEALTH_CHECK_WRITE
 #
 # Turn off the actual write to the disk
@@ -166,1278 +181,195 @@ Lustre quota requires that CONFIG_QUOTA is enabled in your kernel.
 ]) # LC_QUOTA_CONFIG
 
 #
-# LC_EXPORT_TRUNCATE_COMPLETE_PAGE
-#
-# truncate_complete_page() has never been exported from an upstream kernel
-# 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_PAGE], [
-LB_CHECK_EXPORT([truncate_complete_page], [mm/truncate.c],
-       [AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
-               [kernel export truncate_complete_page])])
-LB_CHECK_EXPORT([remove_from_page_cache], [mm/filemap.c],
-       [AC_DEFINE(HAVE_REMOVE_FROM_PAGE_CACHE, 1,
-               [kernel export remove_from_page_cache])])
-LB_CHECK_EXPORT([delete_from_page_cache], [mm/filemap.c],
-       [AC_DEFINE(HAVE_DELETE_FROM_PAGE_CACHE, 1,
-               [kernel export delete_from_page_cache])])
-]) # LC_EXPORT_TRUNCATE_COMPLETE_PAGE
-
-#
-# LC_CONFIG_GSS_KEYRING
-#
-# default 'auto', tests for dependencies, if found, enables;
-# only called if gss is enabled
-#
-AC_DEFUN([LC_CONFIG_GSS_KEYRING], [
-AC_MSG_CHECKING([whether to enable gss keyring backend])
-AC_ARG_ENABLE([gss_keyring],
-       [AC_HELP_STRING([--disable-gss-keyring],
-               [disable gss keyring backend])],
-       [], [enable_gss_keyring="auto"])
-AC_MSG_RESULT([$enable_gss_keyring])
-AS_IF([test "x$enable_gss_keyring" != xno], [
-       LB_CHECK_CONFIG_IM([KEYS], [], [
-               gss_keyring_conf_test="fail"
-               AC_MSG_WARN([GSS keyring backend requires that CONFIG_KEYS be enabled in your kernel.])])
-
-       AC_CHECK_LIB([keyutils], [keyctl_search], [], [
-               gss_keyring_conf_test="fail"
-               AC_MSG_WARN([GSS keyring backend requires libkeyutils])])
-
-       AS_IF([test "x$gss_keyring_conf_test" != xfail], [
-               AC_DEFINE([HAVE_GSS_KEYRING], [1],
-                       [Define this if you enable gss keyring backend])
-               enable_gss_keyring="yes"
-       ], [
-               AS_IF([test "x$enable_gss_keyring" = xyes], [
-                       AC_MSG_ERROR([Cannot enable gss_keyring. See above for details.])
-               ])
-       ])
-])
-]) # LC_CONFIG_GSS_KEYRING
-
-#
-# LC_HAVE_CRED_TGCRED
-#
-# rhel7 struct cred has no member tgcred
-#
-AC_DEFUN([LC_HAVE_CRED_TGCRED], [
-LB_CHECK_COMPILE([if 'struct cred' has member 'tgcred'],
-cred_tgcred, [
-       #include <linux/cred.h>
-],[
-       ((struct cred *)0)->tgcred = NULL;
-],[
-       AC_DEFINE(HAVE_CRED_TGCRED, 1,
-               [struct cred has member tgcred])
-])
-]) # LC_HAVE_CRED_TGCRED
-
-#
-# LC_KEY_TYPE_INSTANTIATE_2ARGS
-#
-# rhel7 key_type->instantiate takes 2 args (struct key, struct key_preparsed_payload)
-#
-AC_DEFUN([LC_KEY_TYPE_INSTANTIATE_2ARGS], [
-LB_CHECK_COMPILE([if 'key_type->instantiate' has two args],
-key_type_instantiate_2args, [
-       #include <linux/key-type.h>
-],[
-       ((struct key_type *)0)->instantiate(0, NULL);
-],[
-       AC_DEFINE(HAVE_KEY_TYPE_INSTANTIATE_2ARGS, 1,
-               [key_type->instantiate has two args])
-])
-]) # LC_KEY_TYPE_INSTANTIATE_2ARGS
-
-#
-# LC_CONFIG_SUNRPC
-#
-AC_DEFUN([LC_CONFIG_SUNRPC], [
-LB_CHECK_CONFIG_IM([SUNRPC], [], [
-       AS_IF([test "x$sunrpc_required" = xyes], [
-               AC_MSG_ERROR([
-
-kernel SUNRPC support is required by using GSS.
-])
-       ])])
-]) # LC_CONFIG_SUNRPC
-
-#
-# LC_CONFIG_GSS (default 'auto' (tests for dependencies, if found, enables))
-#
-# Build gss and related tools of Lustre. Currently both kernel and user space
-# parts are depend on linux platform.
-#
-AC_DEFUN([LC_CONFIG_GSS], [
-AC_MSG_CHECKING([whether to enable gss support])
-AC_ARG_ENABLE([gss],
-       [AC_HELP_STRING([--enable-gss], [enable gss support])],
-       [], [enable_gss="auto"])
-AC_MSG_RESULT([$enable_gss])
-
-AS_IF([test "x$enable_gss" != xno], [
-       LC_CONFIG_GSS_KEYRING
-       LC_HAVE_CRED_TGCRED
-       LC_KEY_TYPE_INSTANTIATE_2ARGS
-       sunrpc_required=$enable_gss
-       LC_CONFIG_SUNRPC
-       sunrpc_required="no"
-
-       LB_CHECK_CONFIG_IM([CRYPTO_MD5], [],
-               [AC_MSG_WARN([kernel MD5 support is recommended by using GSS.])])
-       LB_CHECK_CONFIG_IM([CRYPTO_SHA1], [],
-               [AC_MSG_WARN([kernel SHA1 support is recommended by using GSS.])])
-       LB_CHECK_CONFIG_IM([CRYPTO_SHA256], [],
-               [AC_MSG_WARN([kernel SHA256 support is recommended by using GSS.])])
-       LB_CHECK_CONFIG_IM([CRYPTO_SHA512], [],
-               [AC_MSG_WARN([kernel SHA512 support is recommended by using GSS.])])
-
-       require_krb5=$enable_gss
-       AC_KERBEROS_V5
-       require_krb5="no"
-
-       AS_IF([test -n "$KRBDIR"], [
-               gss_conf_test="success"
-       ], [
-               gss_conf_test="failure"
-       ])
-
-       AS_IF([test "x$gss_conf_test" = xsuccess && test "x$enable_gss" != xno], [
-               AC_DEFINE([HAVE_GSS], [1], [Define this is if you enable gss])
-               enable_gss="yes"
-       ], [
-               enable_gss_keyring="no"
-               enable_gss="no"
-       ])
-
-       enable_ssk=$enable_gss
-], [
-       enable_gss_keyring="no"
-])
-]) # LC_CONFIG_GSS
-
-# LC_OPENSSL_SSK
-#
-# OpenSSL 1.0+ return int for HMAC functions but older SLES11 versions do not
-AC_DEFUN([LC_OPENSSL_SSK], [
-AC_MSG_CHECKING([whether OpenSSL has functions needed for SSK])
-AS_IF([test "x$enable_ssk" != xno], [
-AC_COMPILE_IFELSE([AC_LANG_SOURCE([
-       #include <openssl/hmac.h>
-       #include <openssl/evp.h>
-
-       int main(void) {
-               int rc;
-               rc = HMAC_Init_ex(NULL, "test", 4, EVP_md_null(), NULL);
-       }
-])],[AC_DEFINE(HAVE_OPENSSL_SSK, 1,
-              [OpenSSL HMAC functions needed for SSK])],
-       [enable_ssk="no"])
-])
-AC_MSG_RESULT([$enable_ssk])
-]) # LC_OPENSSL_SSK
-
-# LC_INODE_PERMISION_2ARGS
-#
-# up to v2.6.27 had a 3 arg version (inode, mask, nameidata)
-# v2.6.27->v2.6.37 had a 2 arg version (inode, mask)
-# v2.6.37->v3.0 had a 3 arg version (inode, mask, nameidata)
-# v3.1 onward have a 2 arg version (inode, mask)
-#
-AC_DEFUN([LC_INODE_PERMISION_2ARGS], [
-LB_CHECK_COMPILE([if 'inode_operations->permission' has two args],
-inode_ops_permission_2args, [
-       #include <linux/fs.h>
-],[
-       struct inode *inode __attribute__ ((unused));
-
-       inode = NULL;
-       inode->i_op->permission(NULL, 0);
-],[
-       AC_DEFINE(HAVE_INODE_PERMISION_2ARGS, 1,
-               [inode_operations->permission has two args])
-])
-]) # LC_INODE_PERMISION_2ARGS
-
-#
-# LC_BLK_QUEUE_MAX_SEGMENTS
-#
-# 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], [
-LB_CHECK_COMPILE([if 'blk_queue_max_segments' is defined],
-blk_queue_max_segments, [
-       #include <linux/blkdev.h>
-],[
-       blk_queue_max_segments(NULL, 0);
-],[
-       AC_DEFINE(HAVE_BLK_QUEUE_MAX_SEGMENTS, 1,
-               [blk_queue_max_segments is defined])
-])
-]) # LC_BLK_QUEUE_MAX_SEGMENTS
-
-#
-# LC_HAVE_XATTR_HANDLER_FLAGS
-#
-# 2.6.33 added a private flag to xattr_handler
-#
-AC_DEFUN([LC_HAVE_XATTR_HANDLER_FLAGS], [
-LB_CHECK_COMPILE([if 'struct xattr_handler' has flags field],
-xattr_handler_flags, [
-       #include <linux/xattr.h>
-],[
-       struct xattr_handler handler;
-
-       handler.flags = 0;
-],[
-       AC_DEFINE(HAVE_XATTR_HANDLER_FLAGS, 1, [flags field exist])
-])
-]) # LC_HAVE_XATTR_HANDLER_FLAGS
-
-#
-# LC_HAVE_DQUOT_FS_DISK_QUOTA
-#
-# 2.6.34 has quotactl_ops->[sg]et_dqblk that take struct fs_disk_quota
-#
-AC_DEFUN([LC_HAVE_DQUOT_FS_DISK_QUOTA], [
-tmp_flags="$EXTRA_KCFLAGS"
-EXTRA_KCFLAGS="-Werror"
-LB_CHECK_COMPILE([if 'quotactl_ops.set_dqblk' takes struct fs_disk_quota],
-fs_disk_quota, [
-       #include <linux/fs.h>
-       #include <linux/quota.h>
-],[
-       ((struct quotactl_ops *)0)->set_dqblk(NULL, 0, 0, (struct fs_disk_quota*)0);
-],[
-       AC_DEFINE(HAVE_DQUOT_FS_DISK_QUOTA, 1,
-               [quotactl_ops.set_dqblk takes struct fs_disk_quota])
-],[
-       LB_CHECK_COMPILE([if 'quotactl_ops.set_dqblk' takes struct kqid & fs_disk_quota],
-       kqid_fs_disk_quota, [
-               #include <linux/fs.h>
-               #include <linux/quota.h>
-       ],[
-               ((struct quotactl_ops *)0)->set_dqblk((struct super_block*)0, *((struct kqid*)0), (struct fs_disk_quota*)0);
-       ],[
-               AC_DEFINE(HAVE_DQUOT_FS_DISK_QUOTA, 1,
-                       [quotactl_ops.set_dqblk takes struct fs_disk_quota])
-               AC_DEFINE(HAVE_DQUOT_KQID, 1,
-                       [quotactl_ops.set_dqblk takes struct kqid])
-       ])
-])
-EXTRA_KCFLAGS="$tmp_flags"
-]) # LC_HAVE_DQUOT_FS_DISK_QUOTA
-
-#
-# LC_HAVE_DQUOT_SUSPEND
-#
-# 2.6.34 has renamed dquot options to dquot_*, check for dquot_suspend
-#
-AC_DEFUN([LC_HAVE_DQUOT_SUSPEND], [
-LB_CHECK_COMPILE([if 'dquot_suspend' is defined],
-dquot_suspend, [
-       #include <linux/quotaops.h>
-],[
-       dquot_suspend(NULL, -1);
-],[
-       AC_DEFINE(HAVE_DQUOT_SUSPEND, 1, [dquot_suspend is defined])
-])
-]) # LC_HAVE_DQUOT_SUSPEND
-
-#
-# 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], [
-tmp_flags="$EXTRA_KCFLAGS"
-EXTRA_KCFLAGS="-I$LINUX/fs"
-LB_CHECK_COMPILE([if kernel has 64-bit quota limits support],
-quota64, [
-       #include <linux/kernel.h>
-       #include <linux/fs.h>
-       #if defined(HAVE_FS_QUOTA_QUOTAIO_H)
-       #include <quota/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])
-],[
-       LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],
-               [AC_MSG_ERROR([You have got no 64-bit kernel quota support.])])
-])
-EXTRA_KCFLAGS=$tmp_flags
-]) # LC_QUOTA64
-
-#
-# LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE
-#
-# 2.6.34 adds __add_wait_queue_exclusive
-#
-AC_DEFUN([LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE], [
-LB_CHECK_COMPILE([if '__add_wait_queue_exclusive' exists],
-__add_wait_queue_exclusive, [
-       #include <linux/wait.h>
-],[
-       wait_queue_head_t queue = { };
-       wait_queue_t wait = { };
-
-       __add_wait_queue_exclusive(&queue, &wait);
-],[
-       AC_DEFINE(HAVE___ADD_WAIT_QUEUE_EXCLUSIVE, 1,
-                 [__add_wait_queue_exclusive exists])
-])
-]) # LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE
-
-#
-# LC_FS_STRUCT_RWLOCK
-#
-# 2.6.36 fs_struct.lock use spinlock instead of rwlock.
-#
-AC_DEFUN([LC_FS_STRUCT_RWLOCK], [
-LB_CHECK_COMPILE([if 'fs_struct.lock' use rwlock],
-fs_struct_rwlock, [
-       #include <asm/atomic.h>
-       #include <linux/spinlock.h>
-       #include <linux/fs_struct.h>
-],[
-       struct fs_struct fss = { };
-       rwlock_t rwl = { };
-
-       fss.lock = rwl;
-],[
-       AC_DEFINE(HAVE_FS_STRUCT_RWLOCK, 1, [fs_struct.lock use rwlock])
-])
-]) # LC_FS_STRUCT_RWLOCK
-
-#
-# LC_SBOPS_EVICT_INODE
-#
-# 2.6.36 super_operations add evict_inode method. it hybird of
-# delete_inode & clear_inode.
-#
-AC_DEFUN([LC_SBOPS_EVICT_INODE], [
-LB_CHECK_COMPILE([if 'super_operations.evict_inode' exist],
-super_ops_evict_inode, [
-       #include <linux/fs.h>
-],[
-       ((struct super_operations *)0)->evict_inode(NULL);
-],[
-       AC_DEFINE(HAVE_SBOPS_EVICT_INODE, 1,
-               [super_operations.evict_inode() is exist in kernel])
-])
-]) # LC_SBOPS_EVICT_INODE
-
-#
-# LC_FILE_FSYNC
-#
-# 2.6.35 file_operations.fsync taken 2 arguments.
-# 3.0.0 file_operations.fsync takes 4 arguments.
-#
-AC_DEFUN([LC_FILE_FSYNC], [
-LB_CHECK_COMPILE([if 'file_operations.fsync' takes 4 arguments],
-file_ops_fsync_4args, [
-       #include <linux/fs.h>
-],[
-       ((struct file_operations *)0)->fsync(NULL, 0, 0, 0);
-],[
-       AC_DEFINE(HAVE_FILE_FSYNC_4ARGS, 1,
-               [file_operations.fsync takes 4 arguments])
-],[
-       LB_CHECK_COMPILE([if 'file_operations.fsync' takes 2 arguments],
-       file_ops_fsync_2args, [
-               #include <linux/fs.h>
-       ],[
-               ((struct file_operations *)0)->fsync(NULL, 0);
-       ],[
-               AC_DEFINE(HAVE_FILE_FSYNC_2ARGS, 1,
-                       [file_operations.fsync takes 2 arguments])
-       ])
-])
-]) # LC_FILE_FSYNC
-
-#
-# LC_KERNEL_LOCKED
+# LC_CONFIG_FHANDLE
 #
-# 2.6.37 remove kernel_locked
+# fhandle kernel support for open_by_handle_at() and name_to_handle_at()
+# system calls. The kernel must support CONFIG_FHANDLE.
 #
-AC_DEFUN([LC_KERNEL_LOCKED], [
-LB_CHECK_COMPILE([if 'kernel_locked' is defined],
-kernel_locked, [
-       #include <linux/smp_lock.h>
-],[
-       kernel_locked();
-],[
-       AC_DEFINE(HAVE_KERNEL_LOCKED, 1, [kernel_locked is defined])
-])
-]) # LC_KERNEL_LOCKED
+AC_DEFUN([LC_CONFIG_FHANDLE], [
+LB_CHECK_CONFIG_IM([FHANDLE], [],
+       [AC_MSG_ERROR([
 
-#
-# LC_FS_STRUCT_SEQCOUNT
-#
-# 2.6.37 uses seqlock in fs_struct
-#
-AC_DEFUN([LC_FS_STRUCT_SEQCOUNT], [
-LB_CHECK_COMPILE([if fs_struct use seqcount],
-fs_struct_seqcount, [
-       #include <linux/fs_struct.h>
-],[
-       ((struct fs_struct *)0)->seq = (struct seqcount){ 0 };
-],[
-       AC_DEFINE(HAVE_FS_STRUCT_SEQCOUNT, 1, [fs_struct use seqcount])
-])
-]) # LC_FS_STRUCT_SEQCOUNT
-
-#
-# LC_D_COMPARE_7ARGS
-#
-# 2.6.38 dentry_operations.d_compare() taken 7 arguments.
-#
-AC_DEFUN([LC_D_COMPARE_7ARGS], [
-LB_CHECK_COMPILE([if 'dentry_operations.d_compare()' taken 7 arguments],
-dentry_ops_d_compare_7arg, [
-       #include <linux/dcache.h>
-],[
-       ((struct dentry_operations*)0)->d_compare(NULL,NULL,NULL,NULL,0,NULL,NULL);
-],[
-       AC_DEFINE(HAVE_D_COMPARE_7ARGS, 1, [d_compare need 7 arguments])
-])
-]) # LC_D_COMPARE_7ARGS
-
-#
-# LC_D_DELETE_CONST
-#
-# 2.6.38 dentry_operations.d_delete() defined 'const' for 1st parameter.
-#
-AC_DEFUN([LC_D_DELETE_CONST], [
-tmp_flags="$EXTRA_KCFLAGS"
-EXTRA_KCFLAGS="-Werror"
-LB_CHECK_COMPILE([if 'dentry_operations.d_delete()' has const declare on first parameter],
-dentry_ops_d_delete_1st_const, [
-       #include <linux/dcache.h>
-],[
-       const struct dentry *d = NULL;
-       ((struct dentry_operations*)0)->d_delete(d);
-],[
-       AC_DEFINE(HAVE_D_DELETE_CONST, const,
-               [d_delete first parameter declared const])
-],[
-       AC_DEFINE(HAVE_D_DELETE_CONST, [],
-               [d_delete first parameter declared is not const])
-])
-EXTRA_KCFLAGS="$tmp_flags"
-]) # LC_D_DELETE_CONST
-
-#
-# LC_DCACHE_LOCK
-#
-# 2.6.38 dcache_lock removed. rcu-walk committed.
-#
-AC_DEFUN([LC_DCACHE_LOCK], [
-LB_CHECK_COMPILE([if 'dcache_lock' is exist],
-dcache_lock, [
-       #include <linux/dcache.h>
-],[
-       spin_lock(&dcache_lock);
-],[
-       AC_DEFINE(HAVE_DCACHE_LOCK, 1,
-               [dcache_lock is exist])
-])
-]) # LC_DCACHE_LOCK
-
-#
-# LC_INODE_I_RCU
-#
-# 2.6.38 inode.i_rcu added.
-#
-AC_DEFUN([LC_INODE_I_RCU], [
-LB_CHECK_COMPILE([if 'inode.i_rcu' exists],
-inode_i_rcu, [
-       #include <linux/fs.h>
-],[
-       struct inode ino;
-       struct rcu_head rcu = {};
-       ino.i_rcu = rcu;
-],[
-       AC_DEFINE(HAVE_INODE_I_RCU, 1,
-               [inode.i_rcu exists])
-])
-]) # LC_INODE_I_RCU
-
-#
-# LC_BLKDEV_GET_BY_DEV
-#
-# 2.6.38 export blkdev_get_by_dev
-#
-AC_DEFUN([LC_BLKDEV_GET_BY_DEV], [
-LB_CHECK_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])])
-]) # LC_BLKDEV_GET_BY_DEV
-
-#
-# LC_EXPORT_SIMPLE_SETATTR
-#
-# 2.6.38 export simple_setattr
-#
-AC_DEFUN([LC_EXPORT_SIMPLE_SETATTR], [
-LB_CHECK_EXPORT([simple_setattr], [fs/libfs.c],
-       [AC_DEFINE(HAVE_SIMPLE_SETATTR, 1,
-               [simple_setattr is exported by the kernel])])
-]) # LC_EXPORT_SIMPLE_SETATTR
-
-#
-# LC_HAVE_BLK_PLUG
-#
-# 2.6.38 add struct blk_plug
-#
-AC_DEFUN([LC_HAVE_BLK_PLUG], [
-LB_CHECK_COMPILE([if 'struct blk_plug' exists],
-blk_plug, [
-       #include <linux/blkdev.h>
-],[
-       struct blk_plug plug;
-
-       blk_start_plug(&plug);
-       blk_finish_plug(&plug);
-],[
-       AC_DEFINE(HAVE_BLK_PLUG, 1,
-               [blk_plug struct exists])
-])
-]) # LC_HAVE_BLK_PLUG
-
-#
-# LC_IOP_TRUNCATE
-#
-# truncate callback removed since 2.6.39
-#
-AC_DEFUN([LC_IOP_TRUNCATE], [
-LB_CHECK_COMPILE([if 'inode_operations' has '.truncate' member function],
-inode_ops_truncate, [
-       #include <linux/fs.h>
-],[
-       ((struct inode_operations *)0)->truncate(NULL);
-],[
-       AC_DEFINE(HAVE_INODEOPS_TRUNCATE, 1,
-               [inode_operations has .truncate member function])
-])
-]) # LC_IOP_TRUNCATE
-
-#
-# LC_HAVE_FSTYPE_MOUNT
-#
-# 2.6.39 replace get_sb with mount in struct file_system_type
-#
-AC_DEFUN([LC_HAVE_FSTYPE_MOUNT], [
-LB_CHECK_COMPILE([if 'file_system_type' has 'mount' field],
-file_system_type_mount, [
-       #include <linux/fs.h>
-],[
-       struct file_system_type fst = { };
-       void *mount;
-
-       mount = (void *)fst.mount;
-],[
-       AC_DEFINE(HAVE_FSTYPE_MOUNT, 1,
-               [struct file_system_type has mount field])
-])
-]) # LC_HAVE_FSTYPE_MOUNT
-
-#
-# LC_HAVE_FHANDLE_SYSCALLS
-#
-# 2.6.39 The open_by_handle_at() and name_to_handle_at() system calls were
-# added to Linux kernel 2.6.39.
-# Check if client supports these functions
-#
-AC_DEFUN([LC_HAVE_FHANDLE_SYSCALLS], [
-LB_CHECK_CONFIG_IM([FHANDLE],[
-       AC_DEFINE(HAVE_FHANDLE_SYSCALLS, 1,
-               [kernel supports fhandles and related syscalls])
-       ])
-]) # LC_HAVE_FHANDLE_SYSCALLS
-
-#
-# LC_HAVE_INODE_OWNER_OR_CAPABLE
-#
-# 2.6.39 renames is_owner_or_cap to inode_owner_or_capable
-#
-AC_DEFUN([LC_HAVE_INODE_OWNER_OR_CAPABLE], [
-LB_CHECK_COMPILE([if 'inode_owner_or_capable' exist],
-inode_owner_or_capable, [
-       #include <linux/fs.h>
-],[
-       inode_owner_or_capable(NULL);
-],[
-       AC_DEFINE(HAVE_INODE_OWNER_OR_CAPABLE, 1,
-               [inode_owner_or_capable exist])
-])
-]) # LC_HAVE_INODE_OWNER_OR_CAPABLE
-
-#
-# LC_DIRTY_INODE_WITH_FLAG
-#
-# 3.0 dirty_inode() has a flag parameter
-# see kernel commit aa38572954ade525817fe88c54faebf85e5a61c0
-#
-AC_DEFUN([LC_DIRTY_INODE_WITH_FLAG], [
-LB_CHECK_COMPILE([if 'dirty_inode' super_operation takes flag],
-dirty_inode_super_operation_flag, [
-       #include <linux/fs.h>
-],[
-       struct inode *inode = NULL;
-       inode->i_sb->s_op->dirty_inode(NULL, 0);
-],[
-       AC_DEFINE(HAVE_DIRTY_INODE_HAS_FLAG, 1,
-               [dirty_inode super_operation takes flag])
-])
-]) # LC_DIRTY_INODE_WITH_FLAG
-
-#
-# LC_SETNS
-#
-# 3.0 introduced setns
-#
-AC_DEFUN([LC_SETNS], [
-AC_CHECK_HEADERS([sched.h], [], [],
-                [#define _GNU_SOURCE
-                ])
-AC_CHECK_FUNCS([setns])
-]) # LC_SETNS
-
-#
-# LC_GENERIC_PERMISSION
-#
-# 2.6.38 generic_permission taken 4 parameters.
-# in fact, it means rcu-walk aware permission bring.
-#
-# 3.1 generic_permission taken 2 parameters.
-# see kernel commit 2830ba7f34ebb27c4e5b8b6ef408cd6d74860890
-#
-AC_DEFUN([LC_GENERIC_PERMISSION], [
-LB_CHECK_COMPILE([if 'generic_permission' take 2 arguments],
-generic_permission_2args, [
-       #include <linux/fs.h>
-],[
-       generic_permission(NULL, 0);
-],[
-       AC_DEFINE(HAVE_GENERIC_PERMISSION_2ARGS, 1,
-               [generic_permission taken 2 arguments])
-],[
-       LB_CHECK_COMPILE([if 'generic_permission' take 4 arguments],
-       generic_permission_4args, [
-               #include <linux/fs.h>
-       ],[
-               generic_permission(NULL, 0, 0, NULL);
-       ],[
-               AC_DEFINE(HAVE_GENERIC_PERMISSION_4ARGS, 1,
-                       [generic_permission taken 4 arguments])
-       ])
-])
-]) # LC_GENERIC_PERMISSION
-
-#
-# LC_LM_XXX_LOCK_MANAGER_OPS
-#
-# 3.1 renames lock-manager ops(lock_manager_operations) from fl_xxx to lm_xxx
-# see kernel commit 8fb47a4fbf858a164e973b8ea8ef5e83e61f2e50
-#
-AC_DEFUN([LC_LM_XXX_LOCK_MANAGER_OPS], [
-LB_CHECK_COMPILE([if 'lock-manager' ops renamed to 'lm_xxx'],
-lock_manager_ops_lm_xxx, [
-       #include <linux/fs.h>
-],[
-       struct lock_manager_operations lm_ops;
-       lm_ops.lm_compare_owner = NULL;
-],[
-       AC_DEFINE(HAVE_LM_XXX_LOCK_MANAGER_OPS, 1,
-               [lock-manager ops renamed to lm_xxx])
-])
-]) # LC_LM_XXX_LOCK_MANAGER_OPS
-
-#
-# LC_INODE_DIO_WAIT
-#
-# 3.1 kills inode->i_alloc_sem, use i_dio_count and inode_dio_wait
-#     instead.
-# see kernel commit bd5fe6c5eb9c548d7f07fe8f89a150bb6705e8e3
-#
-AC_DEFUN([LC_INODE_DIO_WAIT], [
-LB_CHECK_COMPILE([if 'inode->i_alloc_sem' is killed and use inode_dio_wait],
-inode_dio_wait, [
-       #include <linux/fs.h>
-],[
-       inode_dio_wait((struct inode *)0);
-],[
-       AC_DEFINE(HAVE_INODE_DIO_WAIT, 1,
-               [inode->i_alloc_sem is killed and use inode_dio_wait])
-])
-]) # LC_INODE_DIO_WAIT
-
-#
-# LC_IOP_GET_ACL
-#
-# 3.1 adds get_acl method to inode_operations to read ACL from disk.
-# see kernel commit 4e34e719e457f2e031297175410fc0bd4016a085
-#
-AC_DEFUN([LC_IOP_GET_ACL], [
-LB_CHECK_COMPILE([if 'inode_operations' has '.get_acl' member function],
-inode_ops_get_acl, [
-       #include <linux/fs.h>
-],[
-       struct inode_operations iop;
-       iop.get_acl = NULL;
-],[
-       AC_DEFINE(HAVE_IOP_GET_ACL, 1,
-               [inode_operations has .get_acl member function])
-])
-]) # LC_IOP_GET_ACL
-
-#
-# LC_FILE_LLSEEK_SIZE
-#
-# 3.1 introduced generic_file_llseek_size()
-#
-AC_DEFUN([LC_FILE_LLSEEK_SIZE], [
-LB_CHECK_EXPORT([generic_file_llseek_size], [fs/read_write.c],
-       [AC_DEFINE(HAVE_FILE_LLSEEK_SIZE, 1,
-               [generic_file_llseek_size is exported by the kernel])])
-]) # LC_FILE_LLSEEK_SIZE
-
-#
-# LC_RADIX_EXCEPTION_ENTRY
-# 3.1 adds radix_tree_exception_entry.
-#
-AC_DEFUN([LC_RADIX_EXCEPTION_ENTRY], [
-LB_CHECK_COMPILE([radix_tree_exceptional_entry exist],
-radix_tree_exceptional_entry, [
-       #include <linux/radix-tree.h>
-],[
-       radix_tree_exceptional_entry(NULL);
-],[
-       AC_DEFINE(HAVE_RADIX_EXCEPTION_ENTRY, 1,
-               [radix_tree_exceptional_entry exist])
-])
-]) # LC_RADIX_EXCEPTION_ENTRY
-
-#
-# LC_HAVE_PROTECT_I_NLINK
-#
-# 3.2 protects inode->i_nlink from direct modification
-# see kernel commit a78ef704a8dd430225955f0709b22d4a6ba21deb
-# at the same time adds set_nlink(), so checks set_nlink() for it.
-#
-AC_DEFUN([LC_HAVE_PROTECT_I_NLINK], [
-LB_CHECK_COMPILE([if 'inode->i_nlink' is protected from direct modification],
-inode_i_nlink_protected, [
-       #include <linux/fs.h>
-],[
-       struct inode i;
-       set_nlink(&i, 1);
-],[
-       AC_DEFINE(HAVE_PROTECT_I_NLINK, 1,
-               [inode->i_nlink is protected from direct modification])
-])
-]) # LC_HAVE_PROTECT_I_NLINK
-
-#
-# 2.6.39 security_inode_init_security takes a 'struct qstr' parameter
-#
-# 3.2 security_inode_init_security takes a callback to set xattrs
-#
-AC_DEFUN([LC_HAVE_SECURITY_IINITSEC], [
-LB_CHECK_COMPILE([if security_inode_init_security takes a callback],
-security_inode_init_security_callback, [
-       #include <linux/security.h>
-],[
-       security_inode_init_security(NULL, NULL, NULL, (const initxattrs)NULL, NULL);
-],[
-       AC_DEFINE(HAVE_SECURITY_IINITSEC_CALLBACK, 1,
-                 [security_inode_init_security takes a callback to set xattrs])
-],[
-       LB_CHECK_COMPILE([if security_inode_init_security takes a 'struct qstr' parameter],
-       security_inode_init_security_qstr, [
-               #include <linux/security.h>
-       ],[
-               security_inode_init_security(NULL, NULL, (struct qstr *)NULL, NULL, NULL, NULL);
-       ],[
-               AC_DEFINE(HAVE_SECURITY_IINITSEC_QSTR, 1,
-                         [security_inode_init_security takes a 'struct qstr' parameter])
-       ])
-])
-]) # LC_HAVE_SECURITY_IINITSEC
-
-#
-# LC_HAVE_MIGRATE_HEADER
-#
-# 3.3 introduces migrate_mode.h and migratepage has 4 args
-#
-AC_DEFUN([LC_HAVE_MIGRATE_HEADER], [
-LB_CHECK_FILE([$LINUX/include/linux/migrate.h], [
-       AC_DEFINE(HAVE_MIGRATE_H, 1,
-               [kernel has include/linux/migrate.h])
-],[
-       LB_CHECK_FILE([$LINUX/include/linux/migrate_mode.h], [
-               AC_DEFINE(HAVE_MIGRATE_MODE_H, 1,
-                       [kernel has include/linux/migrate_mode.h])
-       ])
-])
-]) # LC_HAVE_MIGRATE_HEADER
-
-#
-# LC_MIGRATEPAGE_4ARGS
-#
-AC_DEFUN([LC_MIGRATEPAGE_4ARGS], [
-LB_CHECK_COMPILE([if 'address_space_operations.migratepage' has 4 args],
-address_space_ops_migratepage_4args, [
-       #include <linux/fs.h>
-#ifdef HAVE_MIGRATE_H
-       #include <linux/migrate.h>
-#elif defined(HAVE_MIGRATE_MODE_H)
-       #include <linux/migrate_mode.h>
-#endif
-],[
-       struct address_space_operations aops = { };
-       aops.migratepage(NULL, NULL, NULL, MIGRATE_ASYNC);
-],[
-       AC_DEFINE(HAVE_MIGRATEPAGE_4ARGS, 1,
-               [address_space_operations.migratepage has 4 args])
-])
-]) # LC_MIGRATEPAGE_4ARGS
-
-#
-# LC_SUPEROPS_USE_DENTRY
-#
-# 3.3 switchs super_operations to use dentry as parameter (but not vfsmount)
-# see kernel commit 34c80b1d93e6e20ca9dea0baf583a5b5510d92d4
-#
-AC_DEFUN([LC_SUPEROPS_USE_DENTRY], [
-tmp_flags="$EXTRA_KCFLAGS"
-EXTRA_KCFLAGS="-Werror"
-LB_CHECK_COMPILE([if 'super_operations' use 'dentry' as parameter],
-super_ops_dentry, [
-       #include <linux/fs.h>
-       int show_options(struct seq_file *seq, struct dentry *root) {
-               return 0;
-       }
-],[
-       struct super_operations ops;
-       ops.show_options = show_options;
-],[
-       AC_DEFINE(HAVE_SUPEROPS_USE_DENTRY, 1,
-               [super_operations use dentry as parameter])
-])
-EXTRA_KCFLAGS="$tmp_flags"
-]) # LC_SUPEROPS_USE_DENTRY
-
-#
-# LC_INODEOPS_USE_UMODE_T
-#
-# 3.3 switchs inode_operations to use umode_t as parameter (but not int)
-# see kernel commit 1a67aafb5f72a436ca044293309fa7e6351d6a35
-#
-AC_DEFUN([LC_INODEOPS_USE_UMODE_T], [
-tmp_flags="$EXTRA_KCFLAGS"
-EXTRA_KCFLAGS="-Werror"
-LB_CHECK_COMPILE([if 'inode_operations' use 'umode_t' as parameter],
-inode_ops_umode_t, [
-       #include <linux/fs.h>
-       #include <linux/types.h>
-       int my_mknod(struct inode *dir, struct dentry *dchild,
-                    umode_t mode, dev_t dev)
-       {
-               return 0;
-       }
-],[
-       struct inode_operations ops;
-       ops.mknod = my_mknod;
-],[
-       AC_DEFINE(HAVE_INODEOPS_USE_UMODE_T, 1,
-               [inode_operations use umode_t as parameter])
-])
-EXTRA_KCFLAGS="$tmp_flags"
-]) # LC_INODEOPS_USE_UMODE_T
-
-#
-# LC_KMAP_ATOMIC_HAS_1ARG
-#
-# 3.4 kmap_atomic removes second argument
-# see kernel commit 1ec9c5ddc17aa398f05646abfcbaf315b544e62f
-#
-AC_DEFUN([LC_KMAP_ATOMIC_HAS_1ARG], [
-LB_CHECK_COMPILE([if 'kmap_atomic' has only 1 argument],
-kmap_atomic_1arg, [
-       #include <linux/highmem.h>
-],[
-       kmap_atomic(NULL);
-],[
-       AC_DEFINE(HAVE_KMAP_ATOMIC_HAS_1ARG, 1,
-               [have kmap_atomic has only 1 argument])
-])
-]) # LC_KMAP_ATOMIC_HAS_1ARG
-
-#
-# LC_HAVE_D_MAKE_ROOT
-#
-# 3.4 converts d_alloc_root to d_make_root
-# see kernel commit 32991ab305ace7017c62f8eecbe5eb36dc32e13b
-#
-AC_DEFUN([LC_HAVE_D_MAKE_ROOT], [
-LB_CHECK_COMPILE([if have 'd_make_root'],
-d_make_root, [
-       #include <linux/fs.h>
-],[
-       d_make_root((struct inode *)NULL);
-],[
-       AC_DEFINE(HAVE_D_MAKE_ROOT, 1,
-               [have d_make_root])
-])
-]) # LC_HAVE_D_MAKE_ROOT
-
-#
-# LC_HAVE_CACHE_REGISTER
-#
-# 3.4 cache_register/cache_unregister are removed
-# see kernel commit 2c5f846747526e2b83c5f1b8e69016be0e2e87c0
-# Note, since 2.6.37 cache_register_net/cache_unregister_net
-# are defined, but not exported.
-# 3.3 cache_register_net/cache_unregister_net are
-# exported and replacing cache_register/cache_unregister in 3.4
-#
-AC_DEFUN([LC_HAVE_CACHE_REGISTER], [
-LB_CHECK_COMPILE([if have 'cache_register'],
-cache_register, [
-       #include <linux/sunrpc/cache.h>
-],[
-       cache_register(NULL);
-],[
-       AC_DEFINE(HAVE_CACHE_REGISTER, 1,
-               [have cache_register])
-])
-]) # LC_HAVE_CACHE_REGISTER
-
-#
-# LC_HAVE_CLEAR_INODE
-#
-# 3.5 renames end_writeback() back to clear_inode()...
-# see kernel commit dbd5768f87ff6fb0a4fe09c4d7b6c4a24de99430
-#
-AC_DEFUN([LC_HAVE_CLEAR_INODE], [
-LB_CHECK_COMPILE([if have 'clear_inode'],
-clear_inode, [
-       #include <linux/fs.h>
-],[
-       clear_inode((struct inode *)NULL);
-],[
-       AC_DEFINE(HAVE_CLEAR_INODE, 1,
-               [have clear_inode])
-])
-]) # LC_HAVE_CLEAR_INODE
-
-#
-# LC_HAVE_ENCODE_FH_PARENT
-#
-# 3.5 encode_fh has parent inode passed in directly
-# see kernel commit b0b0382b
-#
-AC_DEFUN([LC_HAVE_ENCODE_FH_PARENT], [
-tmp_flags="$EXTRA_KCFLAGS"
-EXTRA_KCFLAGS="-Werror"
-LB_CHECK_COMPILE([if 'encode_fh' have parent inode as parameter],
-encode_fh_parent_inode, [
-       #include <linux/exportfs.h>
-       #include <linux/fs.h>
-       #include <linux/types.h>
-       int ll_encode_fh(struct inode *i, __u32 *a, int *b, struct inode *p)
-       {
-               return 0;
-       }
-],[
-       struct export_operations exp_op;
-       exp_op.encode_fh = ll_encode_fh;
-],[
-       AC_DEFINE(HAVE_ENCODE_FH_PARENT, 1,
-               [have parent inode as parameter])
-])
-EXTRA_KCFLAGS="$tmp_flags"
-]) # LC_HAVE_ENCODE_FH_PARENT
-
-#
-# LC_FILE_LLSEEK_SIZE_5ARG
-#
-# 3.5 has generic_file_llseek_size with 5 args
-#
-AC_DEFUN([LC_FILE_LLSEEK_SIZE_5ARG], [
-LB_CHECK_COMPILE([if Linux kernel has 'generic_file_llseek_size' with 5 args],
-generic_file_llseek_size_5args, [
-       #include <linux/fs.h>
-],[
-       generic_file_llseek_size(NULL, 0, 0, 0, 0);
-], [
-       AC_DEFINE(HAVE_FILE_LLSEEK_SIZE_5ARGS, 1,
-               [kernel has generic_file_llseek_size with 5 args])
-])
-]) # LC_FILE_LLSEEK_SIZE_5ARG
-
-#
-# LC_LLITE_DATA_IS_LIST
-#
-# 3.6 switch i_dentry/d_alias from list to hlist
-#
-# In the upstream kernels d_alias first changes
-# to a hlist and then in later version, 3.11, gets
-# moved to the union d_u. Due to some distros having
-# d_alias in the d_u union as a struct list, which
-# has never existed upstream stream, we can't test
-# if d_alias is a list or hlist directly. If ever
-# i_dentry and d_alias even up different combos then
-# the build will fail. In that case then we will need
-# to separate out the i_dentry and d_alias test below.
-#
-AC_DEFUN([LC_DATA_FOR_LLITE_IS_LIST], [
-tmp_flags="$EXTRA_KCFLAGS"
-EXTRA_KCFLAGS="-Werror"
-LB_CHECK_COMPILE([if 'i_dentry/d_alias' uses 'list'],
-i_dentry_d_alias_list, [
-       #include <linux/fs.h>
-],[
-       struct inode inode;
-       INIT_LIST_HEAD(&inode.i_dentry);
-],[
-       AC_DEFINE(DATA_FOR_LLITE_IS_LIST, 1,
-               [both i_dentry/d_alias uses list])
-])
-EXTRA_KCFLAGS="$tmp_flags"
-]) # LC_DATA_FOR_LLITE_IS_LIST
-
-#
-# LC_DENTRY_OPEN_USE_PATH
-#
-# 3.6 dentry_open uses struct path as first argument
-# see kernel commit 765927b2
-#
-AC_DEFUN([LC_DENTRY_OPEN_USE_PATH], [
-tmp_flags="$EXTRA_KCFLAGS"
-EXTRA_KCFLAGS="-Werror"
-LB_CHECK_COMPILE([if 'dentry_open' uses 'struct path' as first argument],
-dentry_open_path, [
-       #include <linux/fs.h>
-       #include <linux/path.h>
-],[
-       struct path path;
-       dentry_open(&path, 0, NULL);
-],[
-       AC_DEFINE(HAVE_DENTRY_OPEN_USE_PATH, 1,
-               [dentry_open uses struct path as first argument])
-])
-EXTRA_KCFLAGS="$tmp_flags"
-]) # LC_DENTRY_OPEN_USE_PATH
-
-#
-# LC_HAVE_IOP_ATOMIC_OPEN
-#
-# 3.6 vfs adds iop->atomic_open
-#
-AC_DEFUN([LC_HAVE_IOP_ATOMIC_OPEN], [
-LB_CHECK_COMPILE([if 'iop' has 'atomic_open'],
-inode_ops_atomic_open, [
-       #include <linux/fs.h>
-],[
-       struct inode_operations iop;
-       iop.atomic_open = NULL;
-],[
-       AC_DEFINE(HAVE_IOP_ATOMIC_OPEN, 1,
-               [have iop atomic_open])
-])
-]) # LC_HAVE_IOP_ATOMIC_OPEN
-
-#
-# LC_HAVE_SB_START_WRITE
-#
-# RHEL6 2.6.32, 3.6 or newer support wrapped FS freeze functions
-#
-AC_DEFUN([LC_HAVE_SB_START_WRITE], [
-LB_CHECK_COMPILE([if kernel supports wrapped FS freeze functions],
-sb_start_write, [
-       #include <linux/fs.h>
-],[
-       sb_start_write(NULL);
-],[
-       AC_DEFINE(HAVE_SB_START_WRITE, 1,
-               [kernel supports wrapped FS freeze functions])
-])
-]) # LC_HAVE_SB_START_WRITE
-
-#
-# LC_HAVE_POSIXACL_USER_NS
-#
-# 3.7 posix_acl_{to,from}_xattr take struct user_namespace
-#
-AC_DEFUN([LC_HAVE_POSIXACL_USER_NS], [
-LB_CHECK_COMPILE([if 'posix_acl_to_xattr' takes 'struct user_namespace'],
-posix_acl_to_xattr_user_namespace, [
-       #include <linux/fs.h>
-       #include <linux/posix_acl_xattr.h>
-],[
-       posix_acl_to_xattr((struct user_namespace *)NULL, NULL, NULL, 0);
-],[
-       AC_DEFINE(HAVE_POSIXACL_USER_NS, 1,
-               [posix_acl_to_xattr takes struct user_namespace])
-])
-]) # LC_HAVE_POSIXACL_USER_NS
-
-#
-# LC_HAVE_FILE_F_INODE
-#
-# 3.8 struct file has new member f_inode
-#
-AC_DEFUN([LC_HAVE_FILE_F_INODE], [
-LB_CHECK_COMPILE([if 'struct file' has member 'f_inode'],
-file_f_inode, [
-       #include <linux/fs.h>
-],[
-       ((struct file *)0)->f_inode = NULL;
-],[
-       AC_DEFINE(HAVE_FILE_F_INODE, 1,
-               [struct file has member f_inode])
-])
-]) # LC_HAVE_FILE_F_INODE
-
-#
-# LC_HAVE_FILE_INODE
-#
-# 3.8 has introduced inline function file_inode
-#
-AC_DEFUN([LC_HAVE_FILE_INODE], [
-LB_CHECK_COMPILE([if file_inode() exists],
-file_inode, [
-       #include <linux/fs.h>
-],[
-       file_inode(NULL);
-],[
-       AC_DEFINE(HAVE_FILE_INODE, 1,
-               [file_inode() has been defined])
-])
-]) # LC_HAVE_FILE_INODE
+Lustre fid handling requires that CONFIG_FHANDLE is enabled in your kernel.
+])])
+]) # LC_CONFIG_FHANDLE
 
 #
-# LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS
+# LC_POSIX_ACL_CONFIG
 #
-AC_DEFUN([LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS], [
-LB_CHECK_COMPILE([if 'sunrpc_cache_pipe_upcall' takes 3 args],
-sunrpc_cache_pipe_upcall_3args, [
-       #include <linux/sunrpc/cache.h>
-],[
-       sunrpc_cache_pipe_upcall(NULL, NULL, NULL);
-],[
-       AC_DEFINE(HAVE_SUNRPC_UPCALL_HAS_3ARGS, 1,
-               [sunrpc_cache_pipe_upcall takes 3 args])
-])
-]) # LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS
+# POSIX ACL support.
+#
+AC_DEFUN([LC_POSIX_ACL_CONFIG], [
+LB_CHECK_CONFIG_IM([FS_POSIX_ACL],
+       [AC_DEFINE(CONFIG_LUSTRE_FS_POSIX_ACL, 1, [Enable POSIX acl])
+], [ ])
+]) # LC_POSIX_ACL_CONFIG
+
+LB_CHECK_CONFIG_IM([CRYPTO_MD5], [],
+               [AC_MSG_WARN([kernel MD5 support is recommended by using GSS.])])
 
 #
-# LC_HAVE_HLIST_FOR_EACH_3ARG
+# LC_CONFIG_GSS_KEYRING
 #
-# 3.9 uses hlist_for_each_entry with 3 args
-# b67bfe0d42cac56c512dd5da4b1b347a23f4b70a
+# default 'auto', tests for dependencies, if found, enables;
+# only called if gss is enabled
 #
-AC_DEFUN([LC_HAVE_HLIST_FOR_EACH_3ARG], [
-LB_CHECK_COMPILE([if 'hlist_for_each_entry' has 3 args],
-hlist_for_each_entry_3args, [
-       #include <linux/list.h>
-       #include <linux/fs.h>
-],[
-       struct hlist_head *head = NULL;
-       struct inode *inode;
+AC_DEFUN([LC_CONFIG_GSS_KEYRING], [
+AC_MSG_CHECKING([whether to enable gss keyring backend])
+AC_ARG_ENABLE([gss_keyring],
+       [AC_HELP_STRING([--disable-gss-keyring],
+               [disable gss keyring backend])],
+       [], [enable_gss_keyring="auto"])
+AC_MSG_RESULT([$enable_gss_keyring])
+AS_IF([test "x$enable_gss_keyring" != xno], [
+       LB_CHECK_CONFIG_IM([KEYS], [], [
+               gss_keyring_conf_test="fail"
+               AC_MSG_WARN([GSS keyring backend requires that CONFIG_KEYS be enabled in your kernel.])])
 
-       hlist_for_each_entry(inode, head, i_hash) {
-               continue;
-       }
-],[
-       AC_DEFINE(HAVE_HLIST_FOR_EACH_3ARG, 1,
-               [hlist_for_each_entry has 3 args])
+       AC_CHECK_LIB([keyutils], [keyctl_search], [], [
+               gss_keyring_conf_test="fail"
+               AC_MSG_WARN([GSS keyring backend requires libkeyutils])])
+
+       AS_IF([test "x$gss_keyring_conf_test" != xfail], [
+               AC_DEFINE([HAVE_GSS_KEYRING], [1],
+                       [Define this if you enable gss keyring backend])
+               enable_gss_keyring="yes"
+       ], [
+               AS_IF([test "x$enable_gss_keyring" = xyes], [
+                       AC_MSG_ERROR([Cannot enable gss_keyring. See above for details.])
+               ])
+       ])
 ])
-]) # LC_HAVE_HLIST_FOR_EACH_3ARG
+]) # LC_CONFIG_GSS_KEYRING
 
 #
-# LC_HAVE_BIO_END_SECTOR
+# LC_KEY_TYPE_INSTANTIATE_2ARGS
 #
-# 3.9 introduces bio_end_sector macro
-# f73a1c7d117d07a96d89475066188a2b79e53c48
+# rhel7 key_type->instantiate takes 2 args (struct key, struct key_preparsed_payload)
 #
-AC_DEFUN([LC_HAVE_BIO_END_SECTOR], [
-LB_CHECK_COMPILE([if 'bio_end_sector' is defined],
-bio_end_sector, [
-       #include <linux/bio.h>
+AC_DEFUN([LC_KEY_TYPE_INSTANTIATE_2ARGS], [
+LB_CHECK_COMPILE([if 'key_type->instantiate' has two args],
+key_type_instantiate_2args, [
+       #include <linux/key-type.h>
 ],[
-       struct bio bio = { };
-       unsigned long long end;
-
-       end = bio_end_sector(&bio);
+       ((struct key_type *)0)->instantiate(0, NULL);
 ],[
-       AC_DEFINE(HAVE_BIO_END_SECTOR, 1,
-                 [bio_end_sector is defined])
+       AC_DEFINE(HAVE_KEY_TYPE_INSTANTIATE_2ARGS, 1,
+               [key_type->instantiate has two args])
 ])
-]) # LC_HAVE_BIO_END_SECTOR
+]) # LC_KEY_TYPE_INSTANTIATE_2ARGS
 
 #
-# 3.9 created is_sxid
+# LC_CONFIG_SUNRPC
 #
-AC_DEFUN([LC_HAVE_IS_SXID], [
-LB_CHECK_COMPILE([if 'is_sxid' is defined],
-is_sxid, [
-       #include <linux/fs.h>
-],[
-       struct inode inode = { };
+AC_DEFUN([LC_CONFIG_SUNRPC], [
+LB_CHECK_CONFIG_IM([SUNRPC], [], [
+       AS_IF([test "x$sunrpc_required" = xyes], [
+               AC_MSG_ERROR([
 
-       is_sxid(inode.i_mode);
-],[
-       AC_DEFINE(HAVE_IS_SXID, 1, [is_sxid is defined])
+kernel SUNRPC support is required by using GSS.
 ])
-]) # LC_HAVE_IS_SXID
+       ])])
+]) # LC_CONFIG_SUNRPC
 
 #
-# LC_HAVE_REMOVE_PROC_SUBTREE
+# LC_CONFIG_GSS (default 'auto' (tests for dependencies, if found, enables))
 #
-# 3.10 introduced remove_proc_subtree
+# Build gss and related tools of Lustre. Currently both kernel and user space
+# parts are depend on linux platform.
 #
-AC_DEFUN([LC_HAVE_REMOVE_PROC_SUBTREE], [
-LB_CHECK_COMPILE([if 'remove_proc_subtree' is defined],
-remove_proc_subtree, [
-       #include <linux/proc_fs.h>
-],[
-       remove_proc_subtree(NULL, NULL);
+AC_DEFUN([LC_CONFIG_GSS], [
+AC_MSG_CHECKING([whether to enable gss support])
+AC_ARG_ENABLE([gss],
+       [AC_HELP_STRING([--enable-gss], [enable gss support])],
+       [], [enable_gss="auto"])
+AC_MSG_RESULT([$enable_gss])
+
+AS_IF([test "x$enable_gss" != xno], [
+       LC_CONFIG_GSS_KEYRING
+       LC_KEY_TYPE_INSTANTIATE_2ARGS
+       sunrpc_required=$enable_gss
+       LC_CONFIG_SUNRPC
+       sunrpc_required="no"
+
+       LB_CHECK_CONFIG_IM([CRYPTO_MD5], [],
+               [AC_MSG_WARN([kernel MD5 support is recommended by using GSS.])])
+       LB_CHECK_CONFIG_IM([CRYPTO_SHA1], [],
+               [AC_MSG_WARN([kernel SHA1 support is recommended by using GSS.])])
+       LB_CHECK_CONFIG_IM([CRYPTO_SHA256], [],
+               [AC_MSG_WARN([kernel SHA256 support is recommended by using GSS.])])
+       LB_CHECK_CONFIG_IM([CRYPTO_SHA512], [],
+               [AC_MSG_WARN([kernel SHA512 support is recommended by using GSS.])])
+
+       require_krb5=$enable_gss
+       AC_KERBEROS_V5
+       require_krb5="no"
+
+       AS_IF([test -n "$KRBDIR"], [
+               gss_conf_test="success"
+       ], [
+               gss_conf_test="failure"
+       ])
+
+       AS_IF([test "x$gss_conf_test" = xsuccess && test "x$enable_gss" != xno], [
+               AC_DEFINE([HAVE_GSS], [1], [Define this is if you enable gss])
+               enable_gss="yes"
+       ], [
+               enable_gss_keyring="no"
+               enable_gss="no"
+       ])
+
+       enable_ssk=$enable_gss
 ], [
-       AC_DEFINE(HAVE_REMOVE_PROC_SUBTREE, 1,
-                 [remove_proc_subtree is defined])
+       enable_gss_keyring="no"
 ])
-]) # LC_HAVE_REMOVE_PROC_SUBTREE
+]) # LC_CONFIG_GSS
 
+# LC_OPENSSL_SSK
 #
-# LC_HAVE_PROC_REMOVE
-#
-# 3.10 introduced proc_remove
+# OpenSSL 1.0+ return int for HMAC functions but older SLES11 versions do not
+AC_DEFUN([LC_OPENSSL_SSK], [
+AC_MSG_CHECKING([whether OpenSSL has functions needed for SSK])
+AS_IF([test "x$enable_ssk" != xno], [
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+       #include <openssl/hmac.h>
+       #include <openssl/evp.h>
+
+       int main(void) {
+               int rc;
+               rc = HMAC_Init_ex(NULL, "test", 4, EVP_md_null(), NULL);
+       }
+])],[AC_DEFINE(HAVE_OPENSSL_SSK, 1,
+              [OpenSSL HMAC functions needed for SSK])],
+       [enable_ssk="no"])
+])
+AC_MSG_RESULT([$enable_ssk])
+]) # LC_OPENSSL_SSK
+
+# LC_OPENSSL_GETSEPOL
 #
-AC_DEFUN([LC_HAVE_PROC_REMOVE], [
-LB_CHECK_COMPILE([if 'proc_remove' is defined],
-proc_remove, [
-       #include <linux/proc_fs.h>
+# OpenSSL is needed for l_getsepol
+AC_DEFUN([LC_OPENSSL_GETSEPOL], [
+AC_MSG_CHECKING([whether openssl-devel is present])
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+       #include <openssl/evp.h>
+
+       int main(void) {
+               EVP_MD_CTX *mdctx = EVP_MD_CTX_create();
+       }
+])],[
+       AC_DEFINE(HAVE_OPENSSL_GETSEPOL, 1, [openssl-devel is present])
+       enable_getsepol="yes"
+
 ],[
-       proc_remove(NULL);
-], [
-       AC_DEFINE(HAVE_PROC_REMOVE, 1,
-                 [proc_remove is defined])
+       enable_getsepol="no"
+       AC_MSG_WARN([
+
+No openssk-devel headers found, unable to build l_getsepol and SELinux status checking
+])
 ])
-]) # LC_HAVE_PROC_REMOVE
+AC_MSG_RESULT([$enable_getsepol])
+]) # LC_OPENSSL_GETSEPOL
 
 AC_DEFUN([LC_HAVE_PROJECT_QUOTA], [
 LB_CHECK_COMPILE([if get_projid exists],
@@ -1454,24 +386,6 @@ get_projid, [
 ])
 ]) # LC_HAVE_PROJECT_QUOTA
 
-
-#
-# LC_HAVE_SECURITY_DENTRY_INIT_SECURITY
-#
-# 3.10 introduced security_dentry_init_security()
-#
-AC_DEFUN([LC_HAVE_SECURITY_DENTRY_INIT_SECURITY], [
-LB_CHECK_COMPILE([if 'security_dentry_init_security' is defined],
-security_dentry_init_security, [
-       #include <linux/security.h>
-],[
-       security_dentry_init_security(NULL, 0, NULL, NULL, NULL);
-],[
-       AC_DEFINE(HAVE_SECURITY_DENTRY_INIT_SECURITY, 1,
-               [security_dentry_init_security' is defined])
-])
-]) # LC_HAVE_SECURITY_DENTRY_INIT_SECURITY
-
 #
 # LC_INVALIDATE_RANGE
 #
@@ -1676,27 +590,6 @@ kiocb_ki_left, [
 ]) # LC_KIOCB_KI_LEFT
 
 #
-# LC_INIT_LIST_HEAD_RCU
-#
-# 3.12 added INIT_LIST_HEAD_RCU in commit 2a855b644c310d5db5
-# which is unfortunately an inline function and not a macro
-# that can be tested directly, so it needs a configure check.
-#
-AC_DEFUN([LC_INIT_LIST_HEAD_RCU], [
-LB_CHECK_COMPILE([if 'INIT_LIST_HEAD_RCU' exists],
-init_list_head_rcu, [
-       #include <linux/list.h>
-       #include <linux/rculist.h>
-],[
-       struct list_head list;
-       INIT_LIST_HEAD_RCU(&list);
-],[
-       AC_DEFINE(HAVE_INIT_LIST_HEAD_RCU, 1,
-                 [INIT_LIST_HEAD_RCU exists])
-])
-]) # LC_INIT_LIST_HEAD_RCU
-
-#
 # LC_VFS_RENAME_5ARGS
 #
 # 3.13 has vfs_rename with 5 args
@@ -1730,6 +623,23 @@ vfs_unlink_3args, [
 ])
 ]) # LC_VFS_UNLINK_3ARGS
 
+# LC_HAVE_D_IS_POSITIVE
+#
+# Kernel version 3.13 b18825a7c8e37a7cf6abb97a12a6ad71af160de7
+# d_is_positive is added
+#
+AC_DEFUN([LC_HAVE_D_IS_POSITIVE], [
+LB_CHECK_COMPILE([if 'd_is_positive' exist],
+d_is_positive, [
+       #include <linux/dcache.h>
+],[
+       d_is_positive(NULL);
+],[
+       AC_DEFINE(HAVE_D_IS_POSITIVE, 1,
+               ['d_is_positive' is available])
+])
+]) # LC_HAVE_D_IS_POSITIVE
+
 #
 # LC_HAVE_BVEC_ITER
 #
@@ -1770,81 +680,6 @@ inode_ops_set_acl, [
 ]) # LC_IOP_SET_ACL
 
 #
-# LC_HAVE_BI_CNT
-#
-# 4.4 redefined bi_cnt as __bi_cnt
-#
-AC_DEFUN([LC_HAVE_BI_CNT], [
-LB_CHECK_COMPILE([if Linux kernel has bi_cnt in struct bio],
-have_bi_cnt, [
-       #include <asm/atomic.h>
-       #include <linux/bio.h>
-],[
-       struct bio bio = { };
-       int cnt;
-       cnt = atomic_read(&bio.bi_cnt);
-], [
-       AC_DEFINE(HAVE_BI_CNT, 1,
-               [struct bio has bi_cnt])
-])
-]) # LC_HAVE_BI_CNT
-
-#
-# LC_HAVE_BI_RW
-#
-# 4.4 redefined bi_rw as bi_opf
-#
-AC_DEFUN([LC_HAVE_BI_RW], [
-LB_CHECK_COMPILE([if Linux kernel has bi_rw in struct bio],
-have_bi_rw, [
-       #include <linux/bio.h>
-],[
-       struct bio bio;
-
-       bio.bi_rw = 0;
-], [
-       AC_DEFINE(HAVE_BI_RW, 1,
-               [struct bio has bi_rw])
-])
-]) # LC_HAVE_BI_RW
-
-#
-# LC_HAVE_SUBMIT_BIO_2ARGS
-#
-# 4.4 removed an argument from submit_bio
-#
-AC_DEFUN([LC_HAVE_SUBMIT_BIO_2ARGS], [
-LB_CHECK_COMPILE([if submit_bio takes two arguments],
-have_submit_bio_2args, [
-       #include <linux/bio.h>
-],[
-       struct bio bio;
-       submit_bio(READ, &bio);
-], [
-       AC_DEFINE(HAVE_SUBMIT_BIO_2ARGS, 1,
-               [submit_bio takes two arguments])
-])
-]) # LC_HAVE_SUBMIT_BIO_2_ARGS
-
-#
-# LC_HAVE_CLEAN_BDEV_ALIASES
-#
-# 4.4 unmap_underlying_metadata was replaced by clean_bdev_aliases
-#
-AC_DEFUN([LC_HAVE_CLEAN_BDEV_ALIASES], [
-LB_CHECK_COMPILE([if kernel has clean_bdev_aliases],
-have_clean_bdev_aliases, [
-       #include <linux/buffer_head.h>
-],[
-       struct block_device bdev;
-       clean_bdev_aliases(&bdev,1,1);
-], [
-       AC_DEFINE(HAVE_CLEAN_BDEV_ALIASES, 1,
-               [kernel has clean_bdev_aliases])
-])
-]) # LC_HAVE_CLEAN_BDEV_ALIASES
-
-#
 # LC_HAVE_TRUNCATE_IPAGE_FINAL
 #
 # 3.14 bring truncate_inode_pages_final for evict_inode
@@ -2116,6 +951,22 @@ EXTRA_KCFLAGS="$tmp_flags"
 ]) # LC_HAVE_DQUOT_QC_DQBLK
 
 #
+# LC_HAVE_AIO_COMPLETE
+#
+# 3.19 kernel makes aio_complete() static
+#
+AC_DEFUN([LC_HAVE_AIO_COMPLETE], [
+LB_CHECK_COMPILE([if kernel has exported aio_complete() ],
+aio_complete, [
+       #include <linux/aio.h>
+],[
+       aio_complete(NULL, 0, 0);
+],[
+       AC_DEFINE(HAVE_AIO_COMPLETE, 1, [aio_complete defined])
+])
+]) # LC_HAVE_AIO_COMPLETE
+
+#
 # LC_BACKING_DEV_INFO_REMOVAL
 #
 # 3.20 kernel removed backing_dev_info from address_space
@@ -2155,23 +1006,6 @@ bdi_cap_map_copy, [
 ]) # LC_HAVE_BDI_CAP_MAP_COPY
 
 #
-# LC_CANCEL_DIRTY_PAGE
-#
-# 4.0.0 kernel removed cancel_dirty_page
-#
-AC_DEFUN([LC_CANCEL_DIRTY_PAGE], [
-LB_CHECK_COMPILE([if cancel_dirty_page still exist],
-cancel_dirty_page, [
-       #include <linux/mm.h>
-],[
-       cancel_dirty_page(NULL, PAGE_SIZE);
-],[
-       AC_DEFINE(HAVE_CANCEL_DIRTY_PAGE, 1,
-               [cancel_dirty_page is still available])
-])
-]) # LC_CANCEL_DIRTY_PAGE
-
-#
 # LC_IOV_ITER_RW
 #
 # 4.1 kernel has iov_iter_rw
@@ -2203,21 +1037,25 @@ LB_CHECK_EXPORT([new_sync_read], [fs/read_write.c],
 ]) # LC_HAVE_SYNC_READ_WRITE
 
 #
-# LC_NEW_CANCEL_DIRTY_PAGE
+# LC_HAVE___BI_CNT
 #
-# 4.2 kernel has new cancel_dirty_page
+# 4.1 redefined bi_cnt as __bi_cnt in commit dac56212e8127dbc0
 #
-AC_DEFUN([LC_NEW_CANCEL_DIRTY_PAGE], [
-LB_CHECK_COMPILE([if cancel_dirty_page with one argument exist],
-new_cancel_dirty_page, [
-       #include <linux/mm.h>
-],[
-       cancel_dirty_page(NULL);
+AC_DEFUN([LC_HAVE___BI_CNT], [
+LB_CHECK_COMPILE([if Linux kernel has __bi_cnt in struct bio],
+have___bi_cnt, [
+       #include <asm/atomic.h>
+       #include <linux/bio.h>
+       #include <linux/blk_types.h>
 ],[
-       AC_DEFINE(HAVE_NEW_CANCEL_DIRTY_PAGE, 1,
-               [cancel_dirty_page with one arguement is available])
+       struct bio bio = { };
+       int cnt;
+       cnt = atomic_read(&bio.__bi_cnt);
+], [
+       AC_DEFINE(HAVE___BI_CNT, 1,
+               [struct bio has __bi_cnt])
 ])
-]) # LC_NEW_CANCEL_DIRTY_PAGE
+]) # LC_HAVE___BI_CNT
 
 #
 # LC_SYMLINK_OPS_USE_NAMEIDATA
@@ -2251,12 +1089,29 @@ LB_CHECK_COMPILE([if 'bio_endio' with one argument exist],
 bio_endio, [
        #include <linux/bio.h>
 ],[
-       bio_endio(NULL);
+       bio_endio(NULL);
+],[
+       AC_DEFINE(HAVE_BIO_ENDIO_USES_ONE_ARG, 1,
+               [bio_endio takes only one argument])
+])
+]) # LC_BIO_ENDIO_USES_ONE_ARG
+
+#
+# LC_ACCOUNT_PAGE_DIRTIED_3ARGS
+#
+# 4.2 [to 4.5] kernel page dirtied takes 3 arguments
+#
+AC_DEFUN([LC_ACCOUNT_PAGE_DIRTIED_3ARGS], [
+LB_CHECK_COMPILE([if 'account_page_dirtied' with 3 args exists],
+account_page_dirtied, [
+       #include <linux/mm.h>
+],[
+       account_page_dirtied(NULL, NULL, NULL);
 ],[
-       AC_DEFINE(HAVE_BIO_ENDIO_USES_ONE_ARG, 1,
-               [bio_endio takes only one argument])
+       AC_DEFINE(HAVE_ACCOUNT_PAGE_DIRTIED_3ARGS, 1,
+               [account_page_dirtied takes three arguments])
 ])
-]) # LC_BIO_ENDIO_USES_ONE_ARG
+]) # LC_ACCOUNT_PAGE_DIRTIED_3ARGS
 
 #
 # LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
@@ -2278,32 +1133,6 @@ blk_integrity_interval_exp, [
 ]) # LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
 
 #
-# LC_HAVE_LOOP_CTL_GET_FREE
-#
-# 4.x kernel have moved userspace APIs to
-# the separate directory and all of them
-# support LOOP_CTL_GET_FREE
-#
-AC_DEFUN([LC_HAVE_LOOP_CTL_GET_FREE], [
-LB_CHECK_FILE([$LINUX/include/linux/loop.h], [
-       LB_CHECK_COMPILE([if have 'HAVE_LOOP_CTL_GET_FREE'],
-       LOOP_CTL_GET_FREE, [
-               #include <linux/loop.h>
-       ],[
-               int i;
-
-               i = LOOP_CTL_GET_FREE;
-       ],[
-               AC_DEFINE(HAVE_LOOP_CTL_GET_FREE, 1,
-                       [LOOP_CTL_GET_FREE exist])
-       ])
-],[
-       AC_DEFINE(HAVE_LOOP_CTL_GET_FREE, 1,
-               [kernel has LOOP_CTL_GET_FREE])
-])
-]) # LC_HAVE_LOOP_CTL_GET_FREE
-
-#
 # LC_HAVE_CACHE_HEAD_HLIST
 #
 # 4.3 kernel swiched to hlist for cache_head
@@ -2382,6 +1211,62 @@ bio_integrity_prep_fn, [
 ]) # LC_BIO_INTEGRITY_PREP_FN
 
 #
+# LC_HAVE_BI_OPF
+#
+# 4.4/4.8 redefined bi_rw as bi_opf (SLES12/kernel commit 4382e33ad37486)
+#
+AC_DEFUN([LC_HAVE_BI_OPF], [
+LB_CHECK_COMPILE([if Linux kernel has bi_opf in struct bio],
+have_bi_opf, [
+       #include <linux/bio.h>
+],[
+       struct bio bio;
+
+       bio.bi_opf = 0;
+], [
+       AC_DEFINE(HAVE_BI_OPF, 1,
+               [struct bio has bi_opf])
+])
+]) # LC_HAVE_BI_OPF
+
+#
+# LC_HAVE_SUBMIT_BIO_2ARGS
+#
+# 4.4 removed an argument from submit_bio
+#
+AC_DEFUN([LC_HAVE_SUBMIT_BIO_2ARGS], [
+LB_CHECK_COMPILE([if submit_bio takes two arguments],
+have_submit_bio_2args, [
+       #include <linux/bio.h>
+],[
+       struct bio bio;
+       submit_bio(READ, &bio);
+], [
+       AC_DEFINE(HAVE_SUBMIT_BIO_2ARGS, 1,
+               [submit_bio takes two arguments])
+])
+]) # LC_HAVE_SUBMIT_BIO_2_ARGS
+
+#
+# LC_HAVE_CLEAN_BDEV_ALIASES
+#
+# 4.4/4.9 unmap_underlying_metadata was replaced by clean_bdev_aliases
+# (SLES12/kernel commit 29f3ad7d8380364c)
+#
+AC_DEFUN([LC_HAVE_CLEAN_BDEV_ALIASES], [
+LB_CHECK_COMPILE([if kernel has clean_bdev_aliases],
+have_clean_bdev_aliases, [
+       #include <linux/buffer_head.h>
+],[
+       struct block_device bdev;
+       clean_bdev_aliases(&bdev,1,1);
+], [
+       AC_DEFINE(HAVE_CLEAN_BDEV_ALIASES, 1,
+               [kernel has clean_bdev_aliases])
+])
+]) # LC_HAVE_CLEAN_BDEV_ALIASES
+
+#
 # LC_HAVE_LOCKS_LOCK_FILE_WAIT
 #
 # 4.4 kernel have moved locks API users to
@@ -2532,6 +1417,45 @@ EXTRA_KCFLAGS="$tmp_flags"
 ]) # LC_HAVE_XATTR_HANDLER_INODE_PARAM
 
 #
+# LC_D_IN_LOOKUP
+#
+# Kernel version 4.6 commit 85c7f81041d57cfe9dc97f4680d5586b54534a39
+# introduced parallel lookups in the VFS layer. The inline function
+# d_in_lookup was added to notify when the same item was being queried
+# at the same time.
+#
+AC_DEFUN([LC_D_IN_LOOKUP], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if 'd_in_lookup' is defined],
+d_in_lookup, [
+       #include <linux/dcache.h>
+],[
+       d_in_lookup(NULL);
+],[
+       AC_DEFINE(HAVE_D_IN_LOOKUP, 1, [d_in_lookup is defined])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LC_D_IN_LOOKUP
+
+#
+# LC_LOCK_PAGE_MEMCG
+#
+# Kernel version 4.6 adds lock_page_memcg
+#
+AC_DEFUN([LC_LOCK_PAGE_MEMCG], [
+LB_CHECK_COMPILE([if 'lock_page_memcg' is defined],
+lock_page_memcg, [
+       #include <linux/memcontrol.h>
+],[
+       lock_page_memcg(NULL);
+],[
+       AC_DEFINE(HAVE_LOCK_PAGE_MEMCG, 1,
+               [lock_page_memcg is defined])
+])
+]) # LC_LOCK_PAGE_MEMCG
+
+#
 # LC_DIRECTIO_2ARGS
 #
 # Kernel version 4.7 commit c8b8e32d700fe943a935e435ae251364d016c497
@@ -2557,8 +1481,8 @@ direct_io_2args, [
 #
 # LC_GENERIC_WRITE_SYNC_2ARGS
 #
-# Kernel version 4.7 commit c8b8e32d700fe943a935e435ae251364d016c497
-# direct-io: eliminate the offset argument to ->direct_IO
+# Kernel version 4.7 commit dde0c2e79848298cc25621ad080d47f94dbd7cce
+# fs: add IOCB_SYNC and IOCB_DSYNC
 #
 AC_DEFUN([LC_GENERIC_WRITE_SYNC_2ARGS], [
 LB_CHECK_COMPILE([if 'generic_write_sync()' taken 2 arguments],
@@ -2578,7 +1502,7 @@ generic_write_sync_2args, [
 #
 # LC_FOP_ITERATE_SHARED
 #
-# Kernel version 4.7 adds iterate_shared method to file_operations
+# Kernel v4.6-rc3-29-g6192269 adds iterate_shared method to file_operations
 #
 AC_DEFUN([LC_FOP_ITERATE_SHARED], [
 LB_CHECK_COMPILE([if 'file_operations' has 'iterate_shared'],
@@ -2594,29 +1518,6 @@ fop_iterate_shared, [
 ]) # LC_FOP_ITERATE_SHARED
 
 #
-# LC_FOPS_ITERATE_SHARED
-#
-# 4.7 commit ae05327a00fd47c34dfe25294b359a3f3fef96e8
-# ext4: switch to ->iterate_shared()
-# this replaces ext4_dir_operations iterate with iterate_shared.
-# dir_relaxed_shared() was also added in this commit, so we can
-# use that function to verify that the ext4_dir_operations is using
-# iterate_shared.
-#
-AC_DEFUN([LC_FOPS_ITERATE_SHARED], [
-LB_CHECK_COMPILE([if ext4_dir_operations uses iterate_shared],
-iterate_shared, [
-       #include <linux/fs.h>
-],[
-       ((struct file_operations *)0)->iterate_shared(NULL, NULL);
-       dir_relax_shared(NULL);
-],[
-       AC_DEFINE(HAVE_ITERATE_SHARED, 1,
-               ['iterate_shared' is available])
-])
-]) # LC_FOPS_ITERATE_SHARED
-
-#
 # LC_HAVE_POSIX_ACL_VALID_USER_NS
 #
 # 4.8 posix_acl_valid takes struct user_namespace
@@ -2909,6 +1810,23 @@ current_time, [
 ]) # LIBCFS_CURRENT_TIME
 
 #
+# Kernel version 4.12-rc3 85787090a21eb749d8b347eaf9ff1a455637473c
+# changed struct super_block s_uuid into a proper uuid_t
+#
+AC_DEFUN([LC_SUPER_BLOCK_S_UUID], [
+LB_CHECK_COMPILE([if 'struct super_block' s_uuid is uuid_t],
+super_block_s_uuid, [
+       #include <linux/fs.h>
+],[
+       struct super_block sb;
+
+       uuid_parse(NULL, &sb.s_uuid);
+],[
+       AC_DEFINE(HAVE_S_UUID_AS_UUID_T, 1, ['s_uuid' is an uuid_t])
+])
+]) # LC_SUPER_BLOCK_S_UUID
+
+#
 # LC_SUPER_SETUP_BDI_NAME
 #
 # Kernel version 4.12 commit 9594caf216dc0fe3e318b34af0127276db661241
@@ -2995,6 +1913,300 @@ bi_bdev, [
 ]) # LC_BI_BDEV
 
 #
+# LC_IS_ENCRYPTED
+#
+# 4.14 introduced IS_ENCRYPTED and S_ENCRYPTED
+#
+AC_DEFUN([LC_IS_ENCRYPTED], [
+LB_CHECK_COMPILE([if IS_ENCRYPTED is defined],
+is_encrypted, [
+       #include <linux/fs.h>
+],[
+       IS_ENCRYPTED((struct inode *)0);
+],[
+       has_is_encrypted="yes"
+])
+]) # LC_IS_ENCRYPTED
+
+#
+# LC_I_PAGES
+#
+# kernel 4.17 commit b93b016313b3ba8003c3b8bb71f569af91f19fc7
+#
+AC_DEFUN([LC_I_PAGES], [
+LB_CHECK_COMPILE([if struct address_space has i_pages],
+i_pages, [
+       #include <linux/fs.h>
+],[
+       struct address_space mapping = {};
+       void *i_pages;
+
+       i_pages = &mapping.i_pages;
+],[
+       AC_DEFINE(HAVE_I_PAGES, 1,
+               [struct address_space has i_pages])
+])
+]) # LC_I_PAGES
+
+#
+# LC_VM_FAULT_T
+#
+# kernel 4.17 commit 3d3539018d2cbd12e5af4a132636ee7fd8d43ef0
+# mm: create the new vm_fault_t type
+#
+AC_DEFUN([LC_VM_FAULT_T], [
+LB_CHECK_COMPILE([if vm_fault_t type exists],
+vm_fault_t, [
+       #include <linux/mm_types.h>
+],[
+       vm_fault_t x = VM_FAULT_SIGBUS;
+       (void)x
+],[
+       AC_DEFINE(HAVE_VM_FAULT_T, 1,
+               [if vm_fault_t type exists])
+])
+]) # LC_VM_FAULT_T
+
+#
+# LC_INODE_TIMESPEC64
+#
+# kernel 4.17-rc7 commit 8efd6894ff089adeeac7cb9f32125b85d963d1bc
+# fs: add timespec64_truncate()
+# kernel 4.18 commit 95582b00838837fc07e042979320caf917ce3fe6
+# inode timestamps switched to timespec64
+# kernel 4.19-rc2 commit 976516404ff3fab2a8caa8bd6f5efc1437fed0b8
+# y2038: remove unused time interfaces
+# ...
+#  timespec_trunc
+# ...
+# When inode times are timespec64 stop using the deprecated
+# time interfaces.
+#
+AC_DEFUN([LC_INODE_TIMESPEC64], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if inode timestamps are struct timespec64],
+inode_timespec64, [
+       #include <linux/fs.h>
+],[
+       struct inode *inode = NULL;
+       struct timespec64 ts = {};
+
+       inode->i_atime = timespec64_trunc(ts, 1);
+       (void)inode;
+],[
+       AC_DEFINE(HAVE_INODE_TIMESPEC64, 1,
+               [inode times are using timespec64])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LC_INODE_TIMESPEC64
+
+#
+# LC___XA_SET_MARK
+#
+# kernel 4.20 commit v4.19-rc5-248-g9b89a0355144
+# xarray: Add XArray marks - replaced radix_tree_tag_set
+#
+AC_DEFUN([LC___XA_SET_MARK], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if '__xa_set_mark' exists],
+__xa_set_mark, [
+       #include <linux/fs.h>
+       #include <linux/radix-tree.h>
+],[
+       radix_tree_tag_set(NULL, 0, PAGECACHE_TAG_DIRTY);
+],[
+       AC_DEFINE(HAVE_RADIX_TREE_TAG_SET, 1,
+               [__xa_set_mark exists])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LC___XA_SET_MARK
+
+#
+# LC_UAPI_LINUX_MOUNT_H
+#
+# kernel 4.20 commit e262e32d6bde0f77fb0c95d977482fc872c51996
+# vfs: Suppress MS_* flag defs within the kernel ...
+#
+AC_DEFUN([LC_UAPI_LINUX_MOUNT_H], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if MS_RDONLY was moved to uapi/linux/mount.h],
+uapi_linux_mount, [
+       #include <uapi/linux/mount.h>
+],[
+       int x = MS_RDONLY;
+       (void)x;
+],[
+       AC_DEFINE(HAVE_UAPI_LINUX_MOUNT_H, 1,
+               [if MS_RDONLY was moved to uapi/linux/mount.h])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LC_UAPI_LINUX_MOUNT_H
+
+#
+# LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
+#
+# kernel 4.20 commit 1863d77f15da0addcd293a1719fa5d3ef8cde3ca
+# SUNRPC: Replace the cache_detail->hash_lock with a regular spinlock
+#
+# Now that the reader functions are all RCU protected, use a regular
+# spinlock rather than a reader/writer lock.
+#
+AC_DEFUN([LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if cache_detail->hash_lock is a spinlock],
+hash_lock_isa_spinlock_t, [
+       #include <linux/sunrpc/cache.h>
+],[
+       spinlock_t *lock = &(((struct cache_detail *)0)->hash_lock);
+       spin_lock(lock);
+],[
+       AC_DEFINE(HAVE_CACHE_HASH_SPINLOCK, 1,
+               [if cache_detail->hash_lock is a spinlock])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
+
+#
+# LC_HAS_LINUX_SELINUX_ENABLED
+#
+# kernel 5.1 commit 3d252529480c68bfd6a6774652df7c8968b28e41
+# SELinux: Remove unused selinux_is_enabled
+#
+AC_DEFUN([LC_HAS_LINUX_SELINUX_ENABLED], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if linux/selinux.h exists],
+selinux_is_enabled, [
+       #include <linux/selinux.h>
+],[
+       bool has_selinux = selinux_is_enabled();
+       (void)has_selinux;
+],[
+       AC_DEFINE(HAVE_LINUX_SELINUX_IS_ENABLED, 1,
+               [if linux/selinux.h exists])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LC_HAS_LINUX_SELINUX_ENABLED
+
+#
+# LB_HAVE_BVEC_ITER_ALL
+#
+# kernel 5.1 commit 6dc4f100c175dd0511ae8674786e7c9006cdfbfa
+# block: allow bio_for_each_segment_all() to iterate over multi-page bvec
+#
+AC_DEFUN([LB_HAVE_BVEC_ITER_ALL], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if bvec_iter_all exists for multi-page bvec iternation],
+ext4fs_dirhash, [
+       #include <linux/bvec.h>
+],[
+       struct bvec_iter_all iter;
+       (void)iter;
+],[
+       AC_DEFINE(HAVE_BVEC_ITER_ALL, 1,
+               [if bvec_iter_all exists for multi-page bvec iternation])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LB_HAVE_BVEC_ITER_ALL
+
+#
+# LC_ACCOUNT_PAGE_DIRTIED
+#
+# After 5.2 kernel page dirtied is not exported
+#
+AC_DEFUN([LC_ACCOUNT_PAGE_DIRTIED], [
+LB_CHECK_EXPORT([account_page_dirtied], [mm/page-writeback.c],
+       [AC_DEFINE(HAVE_ACCOUNT_PAGE_DIRTIED_EXPORT, 1,
+                       [account_page_dirtied is exported])])
+]) # LC_ACCOUNT_PAGE_DIRTIED
+
+#
+# LC_KEYRING_SEARCH_4ARGS
+#
+# Kernel 5.2 commit dcf49dbc8077
+# keys: Add a 'recurse' flag for keyring searches
+#
+AC_DEFUN([LC_KEYRING_SEARCH_4ARGS], [
+LB_CHECK_COMPILE([if 'keyring_search' has 4 args],
+keyring_search_4args, [
+       #include <linux/key.h>
+],[
+       key_ref_t keyring;
+       keyring_search(keyring, NULL, NULL, false);
+],[
+       AC_DEFINE(HAVE_KEYRING_SEARCH_4ARGS, 1,
+               [keyring_search has 4 args])
+])
+]) # LC_KEYRING_SEARCH_4ARGS
+
+#
+# LC_BIO_BI_PHYS_SEGMENTS
+#
+# kernel 5.3-rc1 commit 14ccb66b3f585b2bc21e7256c96090abed5a512c
+# block: remove the bi_phys_segments field in struct bio
+#
+AC_DEFUN([LC_BIO_BI_PHYS_SEGMENTS], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if struct bio has bi_phys_segments member],
+bye_bio_bi_phys_segments, [
+       #include <linux/bio.h>
+],[
+       struct bio *bio = NULL;
+       bio->bi_phys_segments++;
+],[
+       AC_DEFINE(HAVE_BIO_BI_PHYS_SEGMENTS, 1,
+               [struct bio has bi_phys_segments member])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LC_BIO_BI_PHYS_SEGMENTS
+
+#
+# LC_LM_COMPARE_OWNER_EXISTS
+#
+# kernel 5.3-rc3 commit f85d93385e9fe6886a751f647f6812a89bf6bee3
+# locks: Cleanup lm_compare_owner and lm_owner_key
+# removed lm_compare_owner
+#
+AC_DEFUN([LC_LM_COMPARE_OWNER_EXISTS], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if lock_manager_operations has lm_compare_owner],
+lock_manager_ops_lm_compare_owner, [
+       #include <linux/fs.h>
+],[
+       struct lock_manager_operations lm_ops;
+       lm_ops.lm_compare_owner = NULL;
+],[
+       AC_DEFINE(HAVE_LM_COMPARE_OWNER, 1,
+               [lock_manager_operations has lm_compare_owner])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LC_LM_COMPARE_OWNER_EXISTS
+
+#
+# LC_FSCRYPT_SUPPORT
+#
+# 5.4 introduced fscrypt encryption policies v2
+#
+AC_DEFUN([LC_FSCRYPT_SUPPORT], [
+LB_CHECK_COMPILE([for fscrypt in-kernel support],
+fscrypt_support, [
+       #define __FS_HAS_ENCRYPTION 0
+       #include <linux/fscrypt.h>
+],[
+       fscrypt_ioctl_get_policy_ex(NULL, NULL);
+],[
+       has_fscrypt_support="yes"
+])
+]) # LC_FSCRYPT_SUPPORT
+
+#
 # LC_PROG_LINUX
 #
 # Lustre linux kernel checks
@@ -3005,109 +2217,18 @@ AC_DEFUN([LC_PROG_LINUX], [
 
        LC_CONFIG_PINGER
        LC_CONFIG_CHECKSUM
+       LC_CONFIG_FLOCK
        LC_CONFIG_HEALTH_CHECK_WRITE
        LC_CONFIG_LRU_RESIZE
+       LC_CONFIG_FHANDLE
+       LC_CONFIG_GSS
 
        LC_GLIBC_SUPPORT_FHANDLES
-       LC_CONFIG_GSS
        LC_OPENSSL_SSK
-
-       # 2.6.32
-       LC_BLK_QUEUE_MAX_SEGMENTS
-
-       # 2.6.33
-       LC_HAVE_XATTR_HANDLER_FLAGS
-
-       # 2.6.34
-       LC_HAVE_DQUOT_FS_DISK_QUOTA
-       LC_HAVE_DQUOT_SUSPEND
-       LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE
-
-       # 2.6.35, 3.0.0
-       LC_FILE_FSYNC
-       LC_EXPORT_SIMPLE_SETATTR
-       LC_EXPORT_TRUNCATE_COMPLETE_PAGE
-
-       # 2.6.36
-       LC_FS_STRUCT_RWLOCK
-       LC_SBOPS_EVICT_INODE
-
-       # 2.6.37
-       LC_KERNEL_LOCKED
-       LC_FS_STRUCT_SEQCOUNT
-
-       # 2.6.38
-       LC_BLKDEV_GET_BY_DEV
-       LC_GENERIC_PERMISSION
-       LC_DCACHE_LOCK
-       LC_INODE_I_RCU
-       LC_D_COMPARE_7ARGS
-       LC_D_DELETE_CONST
-       LC_HAVE_BLK_PLUG
-
-       # 2.6.39
-       LC_HAVE_FHANDLE_SYSCALLS
-       LC_HAVE_FSTYPE_MOUNT
-       LC_IOP_TRUNCATE
-       LC_HAVE_INODE_OWNER_OR_CAPABLE
-       LC_HAVE_SECURITY_IINITSEC
-
-       # 3.0
-       LC_DIRTY_INODE_WITH_FLAG
-       LC_SETNS
-
-       # 3.1
-       LC_LM_XXX_LOCK_MANAGER_OPS
-       LC_INODE_DIO_WAIT
-       LC_IOP_GET_ACL
-       LC_FILE_LLSEEK_SIZE
-       LC_INODE_PERMISION_2ARGS
-       LC_RADIX_EXCEPTION_ENTRY
-       LC_HAVE_LOOP_CTL_GET_FREE
-
-       # 3.2
-       LC_HAVE_PROTECT_I_NLINK
-
-       # 3.3
-       LC_HAVE_MIGRATE_HEADER
-       LC_MIGRATEPAGE_4ARGS
-       LC_SUPEROPS_USE_DENTRY
-       LC_INODEOPS_USE_UMODE_T
-       LC_HAVE_CACHE_REGISTER
-
-       # 3.4
-       LC_HAVE_D_MAKE_ROOT
-       LC_KMAP_ATOMIC_HAS_1ARG
-
-       # 3.5
-       LC_HAVE_CLEAR_INODE
-       LC_HAVE_ENCODE_FH_PARENT
-       LC_FILE_LLSEEK_SIZE_5ARG
-
-       # 3.6
-       LC_DATA_FOR_LLITE_IS_LIST
-       LC_DENTRY_OPEN_USE_PATH
-       LC_HAVE_IOP_ATOMIC_OPEN
-       LC_HAVE_SB_START_WRITE
-
-       # 3.7
-       LC_HAVE_POSIXACL_USER_NS
-
-       # 3.8
-       LC_HAVE_FILE_F_INODE
-       LC_HAVE_FILE_INODE
-       LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS
-
-       # 3.9
-       LC_HAVE_HLIST_FOR_EACH_3ARG
-       LC_HAVE_BIO_END_SECTOR
-       LC_HAVE_IS_SXID
+       LC_OPENSSL_GETSEPOL
 
        # 3.10
-       LC_HAVE_REMOVE_PROC_SUBTREE
-       LC_HAVE_PROC_REMOVE
        LC_HAVE_PROJECT_QUOTA
-       LC_HAVE_SECURITY_DENTRY_INIT_SECURITY
 
        # 3.11
        LC_INVALIDATE_RANGE
@@ -3122,11 +2243,11 @@ AC_DEFUN([LC_PROG_LINUX], [
        LC_OLDSIZE_TRUNCATE_PAGECACHE
        LC_PTR_ERR_OR_ZERO_MISSING
        LC_KIOCB_KI_LEFT
-       LC_INIT_LIST_HEAD_RCU
 
        # 3.13
        LC_VFS_RENAME_5ARGS
        LC_VFS_UNLINK_3ARGS
+       LC_HAVE_D_IS_POSITIVE
 
        # 3.14
        LC_HAVE_BVEC_ITER
@@ -3154,22 +2275,21 @@ AC_DEFUN([LC_PROG_LINUX], [
        # 3.19
        LC_KIOCB_HAS_NBYTES
        LC_HAVE_DQUOT_QC_DQBLK
+       LC_HAVE_AIO_COMPLETE
 
        # 3.20
        LC_BACKING_DEV_INFO_REMOVAL
        LC_HAVE_BDI_CAP_MAP_COPY
 
-       # 4.0.0
-       LC_CANCEL_DIRTY_PAGE
-
        # 4.1.0
        LC_IOV_ITER_RW
        LC_HAVE_SYNC_READ_WRITE
+       LC_HAVE___BI_CNT
 
        # 4.2
-       LC_NEW_CANCEL_DIRTY_PAGE
        LC_BIO_ENDIO_USES_ONE_ARG
        LC_SYMLINK_OPS_USE_NAMEIDATA
+       LC_ACCOUNT_PAGE_DIRTIED_3ARGS
 
        # 4.3
        LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
@@ -3181,8 +2301,7 @@ AC_DEFUN([LC_PROG_LINUX], [
        LC_HAVE_LOCKS_LOCK_FILE_WAIT
        LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
        LC_HAVE_XATTR_HANDLER_NAME
-       LC_HAVE_BI_CNT
-       LC_HAVE_BI_RW
+       LC_HAVE_BI_OPF
        LC_HAVE_SUBMIT_BIO_2ARGS
        LC_HAVE_CLEAN_BDEV_ALIASES
 
@@ -3196,11 +2315,13 @@ AC_DEFUN([LC_PROG_LINUX], [
        # 4.6
        LC_HAVE_IN_COMPAT_SYSCALL
        LC_HAVE_XATTR_HANDLER_INODE_PARAM
+       LC_LOCK_PAGE_MEMCG
 
        # 4.7
+       LC_D_IN_LOOKUP
        LC_DIRECTIO_2ARGS
        LC_GENERIC_WRITE_SYNC_2ARGS
-       LC_FOPS_ITERATE_SHARED
+       LC_FOP_ITERATE_SHARED
 
        # 4.8
        LC_HAVE_POSIX_ACL_VALID_USER_NS
@@ -3226,6 +2347,7 @@ AC_DEFUN([LC_PROG_LINUX], [
 
        # 4.12
        LC_CURRENT_TIME
+       LC_SUPER_BLOCK_S_UUID
        LC_SUPER_SETUP_BDI_NAME
        LC_BI_STATUS
 
@@ -3236,15 +2358,39 @@ AC_DEFUN([LC_PROG_LINUX], [
        LC_PAGEVEC_INIT_ONE_PARAM
        LC_BI_BDEV
 
+       # 4.17
+       LC_VM_FAULT_T
+       LC_I_PAGES
+
+       # 4.18
+       LC_INODE_TIMESPEC64
+
+       # 4.20
+       LC___XA_SET_MARK
+       LC_UAPI_LINUX_MOUNT_H
+       LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
+
+       # 5.1
+       LC_HAS_LINUX_SELINUX_ENABLED
+       LB_HAVE_BVEC_ITER_ALL
+
+       # 5.2
+       LC_ACCOUNT_PAGE_DIRTIED
+       LC_KEYRING_SEARCH_4ARGS
+
+       # 5.3
+       LC_BIO_BI_PHYS_SEGMENTS
+       LC_LM_COMPARE_OWNER_EXISTS
+
        # kernel patch to extend integrity interface
        LC_BIO_INTEGRITY_PREP_FN
 
        #
        AS_IF([test "x$enable_server" != xno], [
                LC_STACK_SIZE
-               LC_QUOTA64
                LC_QUOTA_CONFIG
        ])
+       LC_POSIX_ACL_CONFIG
 ]) # LC_PROG_LINUX
 
 #
@@ -3272,17 +2418,21 @@ AC_ARG_ENABLE([mpitests],
                case $enableval in
                yes)
                        MPICC_WRAPPER="mpicc"
+                       MPI_BIN=$(eval which $MPICC_WRAPPER | xargs dirname)
                        ;;
                no)
                        enable_mpitests="no"
+                       MPI_BIN=""
                        ;;
                *)
                        MPICC_WRAPPER=$enableval
+                       MPI_BIN=$(eval echo $MPICC_WRAPPER | xargs dirname)
                        ;;
                esac
        ], [
                enable_mpitests="yes"
                MPICC_WRAPPER="mpicc"
+               MPI_BIN=$(eval which $MPICC_WRAPPER | xargs dirname)
        ])
 
        if test "x$enable_mpitests" != "xno"; then
@@ -3301,6 +2451,7 @@ AC_ARG_ENABLE([mpitests],
                enable_mpitests=$lb_cv_mpi_tests
                CC=$oldcc
        fi
+       AC_SUBST(MPI_BIN)
        AC_SUBST(MPICC_WRAPPER)
 ]) # LB_CONFIG_MPITESTS
 
@@ -3336,23 +2487,6 @@ AS_IF([test "x$enable_quota" != xno -a "x$enable_utils" != xno], [
 ]) # LC_QUOTA
 
 #
-# LC_CONFIG_NODEMAP_PROC_DEBUG
-#
-# enable nodemap proc file debugging
-#
-AC_DEFUN([LC_NODEMAP_PROC_DEBUG], [
-AC_MSG_CHECKING([whether to enable nodemap proc debug])
-AC_ARG_ENABLE([nodemap_proc_debug],
-       AC_HELP_STRING([--enable-nodemap-proc-debug],
-               [enable nodemap proc debug]),
-       [], [enable_nodemap_proc_debug="no"])
-AC_MSG_RESULT([$enable_nodemap_proc_debug])
-AS_IF([test "x$enable_nodemap_proc_debug" != xno],
-       [AC_DEFINE(NODEMAP_PROC_DEBUG, 1,
-               [enable nodemap proc debug support])])
-]) # LC_NODEMAP_PROC_DEBUG
-
-#
 # LC_OSD_ADDON
 #
 # configure support for optional OSD implementation
@@ -3385,7 +2519,7 @@ AS_IF([test $ENABLEOSDADDON -eq 0], [
                OSDADDON=""
        ], [ln -s $OSDADDON $LUSTRE/$OSDMODNAME], [
                AC_MSG_RESULT([$OSDMODNAME])
-               OSDADDON="subdir-m += $OSDMODNAME"
+               OSDADDON="obj-m += $OSDMODNAME/"
        ], [
                AC_MSG_RESULT([can't link])
                OSDADDON=""
@@ -3395,6 +2529,41 @@ AC_SUBST(OSDADDON)
 ]) # LC_OSD_ADDON
 
 #
+# LC_CONFIG_CRYPTO
+#
+# Check whether to enable Lustre client crypto
+#
+AC_DEFUN([LC_CONFIG_CRYPTO], [
+AC_MSG_CHECKING([whether to enable Lustre client crypto])
+AC_ARG_ENABLE([crypto],
+       AC_HELP_STRING([--enable-crypto],
+               [enable Lustre client crypto]),
+       [], [enable_crypto="auto"])
+AS_IF([test "x$enable_crypto" != xno -a "x$enable_dist" = xno], [
+       AC_MSG_RESULT(
+       )
+       LC_IS_ENCRYPTED
+       LC_FSCRYPT_SUPPORT])
+AS_IF([test "x$has_fscrypt_support" = xyes], [
+       AC_DEFINE(HAVE_LUSTRE_CRYPTO, 1, [Enable Lustre client crypto via in-kernel fscrypt])
+       enable_crypto=yes],
+       [AS_IF([test "x$has_is_encrypted" = xyes], [
+             AC_DEFINE(HAVE_LUSTRE_CRYPTO, 1, [Enable Lustre client crypto via embedded llcrypt])
+             AC_DEFINE(CONFIG_LL_ENCRYPTION, 1, [embedded llcrypt])
+             enable_crypto=yes
+             enable_llcrypt=yes], [
+             AS_IF([test "x$enable_crypto" = xyes],
+                   [AC_MSG_ERROR([Lustre client crypto cannot be enabled because of lack of encryption support in your kernel.])])
+             AS_IF([test "x$enable_crypto" != xno -a "x$enable_dist" = xno],
+                   [AC_MSG_WARN(Lustre client crypto cannot be enabled because of lack of encryption support in your kernel.)])
+             enable_crypto=no])])
+AS_IF([test "x$enable_dist" != xno], [
+       enable_crypto=yes
+       enable_llcrypt=yes])
+AC_MSG_RESULT([$enable_crypto])
+]) # LC_CONFIG_CRYPTO
+
+#
 # LC_CONFIGURE
 #
 # other configure checks
@@ -3418,22 +2587,31 @@ LC_MDS_MAX_THREADS
 AC_CHECK_HEADERS([netdb.h endian.h])
 AC_CHECK_FUNCS([gethostbyname])
 
-# lustre/utils/llverdev.c
-AC_CHECK_HEADERS([blkid/blkid.h])
+# lustre/utils/llverfs.c lustre/utils/libmount_utils_ldiskfs.c
+AC_CHECK_HEADERS([ext2fs/ext2fs.h], [], [
+       AS_IF([test "x$enable_utils" = xyes -a "x$enable_ldiskfs" = xyes], [
+               AC_MSG_ERROR([
+ext2fs.h not found. Please install e2fsprogs development package.
+               ])
+       ])
+])
 
-# lustre/utils/llverfs.c
-AC_CHECK_HEADERS([ext2fs/ext2fs.h])
+# lustre/tests/statx_test.c
+AC_CHECK_FUNCS([statx])
 
 # lustre/utils/lfs.c
-AC_CHECK_LIB([z], [crc32], [
-            AC_CHECK_HEADER([zlib.h], [], [
-                            AC_MSG_ERROR([zlib.h not found.])])
-            ], [
-            AC_MSG_ERROR([
-zlib library not found. Please install zlib development package.])
+AS_IF([test "$enable_dist" = "no"], [
+               AC_CHECK_LIB([z], [crc32], [
+                                AC_CHECK_HEADER([zlib.h], [], [
+                                                AC_MSG_ERROR([zlib.h not found.])])
+                                ], [
+                                AC_MSG_ERROR([
+               zlib library not found. Please install zlib development package.])
+               ])
 ])
 
 SELINUX=""
+
 AC_CHECK_LIB([selinux], [is_selinux_enabled],
        [AC_CHECK_HEADERS([selinux/selinux.h],
                        [SELINUX="-lselinux"
@@ -3517,6 +2695,23 @@ AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitd
 AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
        [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
 AC_MSG_RESULT([$with_systemdsystemunitdir])
+
+AC_MSG_CHECKING([bash-completion directory])
+AC_ARG_WITH([bash-completion-dir],
+       AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
+               [Install the bash auto-completion script in this directory.]),
+       [],
+       [with_bash_completion_dir=yes])
+AS_IF([test "x$with_bash_completion_dir" = "xyes"], [
+       BASH_COMPLETION_DIR="`pkg-config --variable=completionsdir bash-completion`"
+       AS_IF([test "x$BASH_COMPLETION_DIR" = "x"], [
+               [BASH_COMPLETION_DIR="$datadir/bash-completion/completions"]
+       ])
+], [
+       BASH_COMPLETION_DIR="$with_bash_completion_dir"
+])
+AC_SUBST([BASH_COMPLETION_DIR])
+AC_MSG_RESULT([$BASH_COMPLETION_DIR])
 ]) # LC_CONFIGURE
 
 #
@@ -3529,7 +2724,6 @@ AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
-AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
@@ -3537,7 +2731,11 @@ AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
 AM_CONDITIONAL(GSS_SSK, test x$enable_ssk = xyes)
 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
 AM_CONDITIONAL(HAVE_SYSTEMD, test "x$with_systemdsystemunitdir" != "xno")
+AM_CONDITIONAL(ENABLE_BASH_COMPLETION, test "x$with_bash_completion_dir" != "xno")
 AM_CONDITIONAL(XATTR_HANDLER, test "x$lb_cv_compile_xattr_handler_flags" = xyes)
+AM_CONDITIONAL(SELINUX, test "$SELINUX" = "-lselinux")
+AM_CONDITIONAL(GETSEPOL, test x$enable_getsepol = xyes)
+AM_CONDITIONAL(LLCRYPT, test x$enable_llcrypt = xyes)
 ]) # LC_CONDITIONALS
 
 #
@@ -3557,26 +2755,22 @@ lustre/doc/Makefile
 lustre/include/Makefile
 lustre/include/lustre/Makefile
 lustre/include/uapi/linux/lustre/Makefile
+lustre/kernel_patches/targets/4.18-rhel8.1.target
+lustre/kernel_patches/targets/4.18-rhel8.target
+lustre/kernel_patches/targets/3.10-rhel7.8.target
+lustre/kernel_patches/targets/3.10-rhel7.7.target
 lustre/kernel_patches/targets/3.10-rhel7.6.target
 lustre/kernel_patches/targets/3.10-rhel7.5.target
 lustre/kernel_patches/targets/4.14-rhel7.5.target
 lustre/kernel_patches/targets/4.14-rhel7.6.target
-lustre/kernel_patches/targets/2.6-rhel6.9.target
-lustre/kernel_patches/targets/2.6-rhel6.8.target
-lustre/kernel_patches/targets/2.6-rhel6.7.target
-lustre/kernel_patches/targets/2.6-rhel6.6.target
-lustre/kernel_patches/targets/2.6-rhel6.target
-lustre/kernel_patches/targets/2.6-rhel5.target
-lustre/kernel_patches/targets/2.6-sles11.target
 lustre/kernel_patches/targets/3.0-sles11.target
 lustre/kernel_patches/targets/3.0-sles11sp3.target
 lustre/kernel_patches/targets/3.0-sles11sp4.target
 lustre/kernel_patches/targets/3.12-sles12.target
 lustre/kernel_patches/targets/4.4-sles12.target
 lustre/kernel_patches/targets/4.4-sles12sp3.target
-lustre/kernel_patches/targets/2.6-fc11.target
-lustre/kernel_patches/targets/2.6-fc12.target
-lustre/kernel_patches/targets/2.6-fc15.target
+lustre/kernel_patches/targets/4.12-sles12sp4.target
+lustre/kernel_patches/targets/4.12-sles15sp1.target
 lustre/kernel_patches/targets/3.x-fc18.target
 lustre/ldlm/Makefile
 lustre/fid/Makefile