Whamcloud - gitweb
LU-4287 autoconf: Improve test for proc write and read functions
[fs/lustre-release.git] / lustre / autoconf / lustre-core.m4
index dbe3f2a..f47bc5f 100644 (file)
@@ -356,46 +356,6 @@ AC_DEFUN([LC_CONFIG_GSS],
  fi
 ])
 
-# 2.6.24
-
-# 2.6.24 has bio_endio with 2 args
-AC_DEFUN([LC_BIO_ENDIO_2ARG],
-[AC_MSG_CHECKING([if kernel has bio_endio with 2 args])
-LB_LINUX_TRY_COMPILE([
-        #include <linux/bio.h>
-],[
-        bio_endio(NULL, 0);
-], [
-        AC_MSG_RESULT([yes])
-        AC_DEFINE(HAVE_BIO_ENDIO_2ARG, 1,
-                [kernel has bio_endio with 2 args])
-],[
-        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])
-LB_LINUX_TRY_COMPILE([
-       #include <linux/proc_fs.h>
-],[
-        struct proc_dir_entry pde;
-
-        pde.deleted = sizeof(pde);
-], [
-        AC_MSG_RESULT([yes])
-        AC_DEFINE(HAVE_PROCFS_DELETED, 1,
-                [kernel has deleted member in procfs entry struct])
-],[
-        AC_MSG_RESULT([no])
-])
-])
-
-#
-# 2.6.27
-#
-
 # 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)
@@ -418,6 +378,22 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+# 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/blkdev.h>
+],[
+       blk_queue_max_segments(NULL, 0);
+],[
+       AC_MSG_RESULT(yes)
+       AC_DEFINE(HAVE_BLK_QUEUE_MAX_SEGMENTS, 1,
+                 [blk_queue_max_segments is defined])
+],[
+       AC_MSG_RESULT(no)
+])
+])
+
 # 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"
@@ -427,14 +403,26 @@ LB_LINUX_TRY_COMPILE([
        #include <linux/fs.h>
        #include <linux/quota.h>
 ],[
-       struct quotactl_ops qops = {};
-       struct fs_disk_quota fdq;
-       qops.set_dqblk(NULL, 0, 0, &fdq);
+       ((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])
        AC_MSG_RESULT([yes])
 ],[
        AC_MSG_RESULT([no])
+       AC_MSG_CHECKING([if quotactl_ops.set_dqblk takes struct kqid & fs_disk_quota])
+       LB_LINUX_TRY_COMPILE([
+               #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])
+               AC_MSG_RESULT([yes])
+       ],[
+               AC_MSG_RESULT([no])
+               AC_MSG_CHECKING([if quotactl_ops.set_dqblk takes struct kqid&fs_disk_quota])
+       ])
 ])
 EXTRA_KCFLAGS="$tmp_flags"
 ])
@@ -455,44 +443,6 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
-# 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.32
-
-# 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/blkdev.h>
-],[
-        blk_queue_max_segments(NULL, 0);
-],[
-        AC_MSG_RESULT(yes)
-        AC_DEFINE(HAVE_BLK_QUEUE_MAX_SEGMENTS, 1,
-                  [blk_queue_max_segments is defined])
-],[
-        AC_MSG_RESULT(no)
-])
-])
-
-#
 # LC_QUOTA64
 #
 # Check if kernel has been patched for 64-bit quota limits support.
@@ -716,6 +666,24 @@ AC_DEFINE(HAVE_SIMPLE_SETATTR, 1,
 ])
 
 #
+# truncate callback removed since 2.6.39
+#
+AC_DEFUN([LC_IOP_TRUNCATE],
+[AC_MSG_CHECKING([inode_operations has .truncate member function])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        ((struct inode_operations *)0)->truncate(NULL);
+],[
+        AC_DEFINE(HAVE_INODEOPS_TRUNCATE, 1,
+                  [inode_operations has .truncate member function])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+#
 # 2.6.39 remove unplug_fn from request_queue.
 #
 AC_DEFUN([LC_REQUEST_QUEUE_UNPLUG_FN],
@@ -1283,6 +1251,61 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
+# 3.10+ only supports procfs seq_files handling
+#
+AC_DEFUN([LC_HAVE_ONLY_PROCFS_SEQ],
+[AC_MSG_CHECKING([if procfs only supports using seq_files])
+LB_LINUX_TRY_COMPILE([
+       #include <linux/proc_fs.h>
+],[
+       ((struct proc_dir_entry *)0)->write_proc(NULL, NULL, 0, NULL);
+],[
+       AC_MSG_RESULT([no])
+],[
+       AC_DEFINE(HAVE_ONLY_PROCFS_SEQ, 1, [only seq_files supported])
+       AC_MSG_RESULT([yes])
+])
+])
+
+# 3.10 release for block device doesn't return int
+AC_DEFUN([LC_BLKDEV_RELEASE_RETURN_INT],
+[AC_MSG_CHECKING([if block_device_operations release returns int])
+LB_LINUX_TRY_COMPILE([
+       #include <linux/blkdev.h>
+],[
+       struct block_device_operations fops;
+       int i __attribute__ ((unused));
+
+       i = fops.release(NULL,0);
+],[
+       AC_MSG_RESULT([yes])
+       AC_DEFINE(HAVE_BLKDEV_RELEASE_RETURN_INT, 1,
+                 [block device release returns int])
+],[
+       AC_MSG_RESULT([no])
+])
+])
+
+#
+# 3.11 need to access d_count to get dentry reference count
+#
+AC_DEFUN([LC_HAVE_DCOUNT],
+[AC_MSG_CHECKING([if d_count exist])
+LB_LINUX_TRY_COMPILE([
+       #include <linux/dcache.h>
+],[
+       struct dentry de;
+
+       d_count(&de);
+],[
+       AC_DEFINE(HAVE_D_COUNT, 1, [d_count exist])
+       AC_MSG_RESULT([yes])
+],[
+       AC_MSG_RESULT([no])
+])
+])
+
+#
 # LC_PROG_LINUX
 #
 # Lustre linux kernel checks
@@ -1300,15 +1323,8 @@ AC_DEFUN([LC_PROG_LINUX],
          LC_CONFIG_RMTCLIENT
          LC_CONFIG_GSS
 
-         # 2.6.24
-         LC_BIO_ENDIO_2ARG
-         LC_PROCFS_DELETED
-
-         # 2.6.27.15-2 sles11
-         LC_HAVE_QUOTAIO_H
-
-         # 2.6.32
-         LC_BLK_QUEUE_MAX_SEGMENTS
+        # 2.6.32
+        LC_BLK_QUEUE_MAX_SEGMENTS
 
         # 2.6.34
         LC_HAVE_DQUOT_FS_DISK_QUOTA
@@ -1337,6 +1353,7 @@ AC_DEFUN([LC_PROG_LINUX],
          # 2.6.39
          LC_REQUEST_QUEUE_UNPLUG_FN
         LC_HAVE_FSTYPE_MOUNT
+        LC_IOP_TRUNCATE
 
         # 3.0
         LC_DIRTY_INODE_WITH_FLAG
@@ -1383,6 +1400,13 @@ AC_DEFUN([LC_PROG_LINUX],
         LC_HAVE_HLIST_FOR_EACH_3ARG
         LC_HAVE_F_PATH_MNT
 
+        # 3.10
+        LC_HAVE_ONLY_PROCFS_SEQ
+        LC_BLKDEV_RELEASE_RETURN_INT
+
+        # 3.11
+        LC_HAVE_DCOUNT
+
         #
         if test x$enable_server != xno ; then
                LC_FUNC_DEV_SET_RDONLY