Whamcloud - gitweb
38d3fa0eb10ae85cc7d9fb1f49f945d351d13ed4
[fs/lustre-release.git] / lustre / autoconf / lustre-core.m4
1 #* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 #* vim:expandtab:shiftwidth=8:tabstop=8:
3 #
4 # LC_CONFIG_SRCDIR
5 #
6 # Wrapper for AC_CONFIG_SUBDIR
7 #
8 AC_DEFUN([LC_CONFIG_SRCDIR],
9 [AC_CONFIG_SRCDIR([lustre/obdclass/obdo.c])
10 libcfs_is_module=yes
11 ldiskfs_is_ext4=yes
12 ])
13
14 #
15 # LC_PATH_DEFAULTS
16 #
17 # lustre specific paths
18 #
19 AC_DEFUN([LC_PATH_DEFAULTS],
20 [# ptlrpc kernel build requires this
21 LUSTRE="$PWD/lustre"
22 AC_SUBST(LUSTRE)
23
24 # mount.lustre
25 rootsbindir='/sbin'
26 AC_SUBST(rootsbindir)
27
28 demodir='$(docdir)/demo'
29 AC_SUBST(demodir)
30
31 pkgexampledir='${pkgdatadir}/examples'
32 AC_SUBST(pkgexampledir)
33 ])
34
35 #
36 # LC_TARGET_SUPPORTED
37 #
38 # is the target os supported?
39 #
40 AC_DEFUN([LC_TARGET_SUPPORTED],
41 [case $target_os in
42         linux* | darwin*)
43 $1
44                 ;;
45         *)
46 $2
47                 ;;
48 esac
49 ])
50
51 #
52 # LC_CONFIG_OBD_BUFFER_SIZE
53 #
54 # the maximum buffer size of lctl ioctls
55 #
56 AC_DEFUN([LC_CONFIG_OBD_BUFFER_SIZE],
57 [AC_MSG_CHECKING([maximum OBD ioctl size])
58 AC_ARG_WITH([obd-buffer-size],
59         AC_HELP_STRING([--with-obd-buffer-size=[size]],
60                         [set lctl ioctl maximum bytes (default=8192)]),
61         [
62                 OBD_BUFFER_SIZE=$with_obd_buffer_size
63         ],[
64                 OBD_BUFFER_SIZE=8192
65         ])
66 AC_MSG_RESULT([$OBD_BUFFER_SIZE bytes])
67 AC_DEFINE_UNQUOTED(OBD_MAX_IOCTL_BUFFER, $OBD_BUFFER_SIZE, [IOCTL Buffer Size])
68 ])
69
70 #
71 # LC_READLINK_SSIZE_T
72 #
73 AC_DEFUN([LC_READLINK_SSIZE_T],
74 [AC_MSG_CHECKING([if readlink returns ssize_t])
75 AC_TRY_COMPILE([
76         #include <unistd.h>
77 ],[
78         ssize_t readlink(const char *, char *, size_t);
79 ],[
80         AC_MSG_RESULT([yes])
81         AC_DEFINE(HAVE_POSIX_1003_READLINK, 1, [readlink returns ssize_t])
82 ],[
83         AC_MSG_RESULT([no])
84 ])
85 ])
86
87 #
88 # only for Lustre-patched kernels
89 #
90 AC_DEFUN([LC_LUSTRE_VERSION_H],
91 [LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
92         rm -f "$LUSTRE/include/linux/lustre_version.h"
93 ],[
94         touch "$LUSTRE/include/linux/lustre_version.h"
95         if test x$enable_server = xyes ; then
96                 AC_MSG_WARN([Unpatched kernel detected.])
97                 AC_MSG_WARN([Lustre servers cannot be built with an unpatched kernel;])
98                 AC_MSG_WARN([disabling server build])
99                 enable_server='no'
100         fi
101 ])
102 ])
103
104 #
105 # LC_FUNC_DEV_SET_RDONLY
106 #
107 # check whether dev_set_rdonly is exported.  This is needed until we
108 # have another mechanism to fence IO from the underlying device.
109 #
110 AC_DEFUN([LC_FUNC_DEV_SET_RDONLY],
111 [LB_CHECK_SYMBOL_EXPORT([dev_set_rdonly],
112 [block/ll_rw_block.c,block/blk-core.c],[
113         AC_DEFINE(HAVE_DEV_SET_RDONLY, 1, [kernel exports dev_set_rdonly])
114 ],[
115         AC_MSG_WARN([kernel missing dev_set_rdonly patch for testing])
116 ])
117 ])
118
119 #
120 # Ensure stack size big than 8k in Lustre server (all kernels)
121 #
122 AC_DEFUN([LC_STACK_SIZE],
123 [AC_MSG_CHECKING([stack size big than 8k])
124 LB_LINUX_TRY_COMPILE([
125         #include <linux/thread_info.h>
126 ],[
127         #if THREAD_SIZE < 8192
128         #error "stack size < 8192"
129         #endif
130 ],[
131         AC_MSG_RESULT(yes)
132 ],[
133         AC_MSG_ERROR([Lustre requires that Linux is configured with at least a 8KB stack.])
134 ])
135 ])
136
137 #
138 # Allow the user to set the MDS thread upper limit
139 #
140 AC_DEFUN([LC_MDS_MAX_THREADS],
141 [
142         AC_ARG_WITH([mds_max_threads],
143         AC_HELP_STRING([--with-mds-max-threads=size],
144                         [define the maximum number of threads available on the MDS: (default=512)]),
145         [
146                 MDS_THREAD_COUNT=$with_mds_max_threads
147                 AC_DEFINE_UNQUOTED(MDT_MAX_THREADS, $MDS_THREAD_COUNT, [maximum number of mdt threads])
148         ])
149 ])
150
151 #
152 # LC_CONFIG_PINGER
153 #
154 # the pinger is temporary, until we have the recovery node in place
155 #
156 AC_DEFUN([LC_CONFIG_PINGER],
157 [AC_MSG_CHECKING([whether to enable pinger support])
158 AC_ARG_ENABLE([pinger],
159         AC_HELP_STRING([--disable-pinger],
160                         [disable recovery pinger support]),
161         [],[enable_pinger='yes'])
162 AC_MSG_RESULT([$enable_pinger])
163 if test x$enable_pinger != xno ; then
164   AC_DEFINE(ENABLE_PINGER, 1, Use the Pinger)
165 fi
166 ])
167
168 #
169 # LC_CONFIG_CHECKSUM
170 #
171 # do checksum of bulk data between client and OST
172 #
173 AC_DEFUN([LC_CONFIG_CHECKSUM],
174 [AC_MSG_CHECKING([whether to enable data checksum support])
175 AC_ARG_ENABLE([checksum],
176        AC_HELP_STRING([--disable-checksum],
177                        [disable data checksum support]),
178        [],[enable_checksum='yes'])
179 AC_MSG_RESULT([$enable_checksum])
180 if test x$enable_checksum != xno ; then
181   AC_DEFINE(ENABLE_CHECKSUM, 1, do data checksums)
182 fi
183 ])
184
185 #
186 # LC_CONFIG_LIBLUSTRE_RECOVERY
187 #
188 AC_DEFUN([LC_CONFIG_LIBLUSTRE_RECOVERY],
189 [AC_MSG_CHECKING([whether to enable liblustre recovery support])
190 AC_ARG_ENABLE([liblustre-recovery],
191         AC_HELP_STRING([--disable-liblustre-recovery],
192                         [disable liblustre recovery support]),
193         [],[enable_liblustre_recovery='yes'])
194 AC_MSG_RESULT([$enable_liblustre_recovery])
195 if test x$enable_liblustre_recovery != xno ; then
196   AC_DEFINE(ENABLE_LIBLUSTRE_RECOVERY, 1, Liblustre Can Recover)
197 fi
198 ])
199
200 #
201 # LC_CONFIG_HEALTH_CHECK_WRITE
202 #
203 # Turn off the actual write to the disk
204 #
205 AC_DEFUN([LC_CONFIG_HEALTH_CHECK_WRITE],
206 [AC_MSG_CHECKING([whether to enable a write with the health check])
207 AC_ARG_ENABLE([health_write],
208         AC_HELP_STRING([--enable-health_write],
209                         [enable disk writes when doing health check]),
210         [],[enable_health_write='no'])
211 AC_MSG_RESULT([$enable_health_write])
212 if test x$enable_health_write != xno ; then
213   AC_DEFINE(USE_HEALTH_CHECK_WRITE, 1, Write when Checking Health)
214 fi
215 ])
216
217 AC_DEFUN([LC_CONFIG_LRU_RESIZE],
218 [AC_MSG_CHECKING([whether to enable lru self-adjusting])
219 AC_ARG_ENABLE([lru_resize],
220         AC_HELP_STRING([--enable-lru-resize],
221                         [enable lru resize support]),
222         [],[enable_lru_resize='yes'])
223 AC_MSG_RESULT([$enable_lru_resize])
224 if test x$enable_lru_resize != xno; then
225    AC_DEFINE(HAVE_LRU_RESIZE_SUPPORT, 1, [Enable lru resize support])
226 fi
227 ])
228
229 # whether to enable quota support(kernel modules)
230 AC_DEFUN([LC_QUOTA_MODULE],
231 [if test x$enable_quota != xno; then
232     LB_LINUX_CONFIG([QUOTA],[
233         enable_quota_module='yes'
234         AC_DEFINE(HAVE_QUOTA_SUPPORT, 1, [Enable quota support])
235     ],[
236         enable_quota_module='no'
237         AC_MSG_WARN([quota is not enabled because the kernel - lacks quota support])
238     ])
239 fi
240 ])
241
242 # truncate_complete_page() was exported from RHEL5/SLES10, but not in SLES11 SP0 (2.6.27)
243 # remove_from_page_cache() was exported between 2.6.35 and 2.6.38
244 # delete_from_page_cache() is exported from 2.6.39
245 AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE],
246          [LB_CHECK_SYMBOL_EXPORT([truncate_complete_page],
247                                  [mm/truncate.c],
248                                  [AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
249                                             [kernel export truncate_complete_page])])
250           LB_CHECK_SYMBOL_EXPORT([remove_from_page_cache],
251                                  [mm/filemap.c],
252                                  [AC_DEFINE(HAVE_REMOVE_FROM_PAGE_CACHE, 1,
253                                             [kernel export remove_from_page_cache])])
254           LB_CHECK_SYMBOL_EXPORT([delete_from_page_cache],
255                                  [mm/filemap.c],
256                                  [AC_DEFINE(HAVE_DELETE_FROM_PAGE_CACHE, 1,
257                                             [kernel export delete_from_page_cache])])
258          ])
259
260 AC_DEFUN([LC_EXPORT_D_REHASH_COND],
261 [LB_CHECK_SYMBOL_EXPORT([d_rehash_cond],
262 [fs/dcache.c],[
263 AC_DEFINE(HAVE_D_REHASH_COND, 1,
264             [d_rehash_cond is exported by the kernel])
265 ],[
266 ])
267 ])
268
269 AC_DEFUN([LC_EXPORT___D_REHASH],
270 [LB_CHECK_SYMBOL_EXPORT([__d_rehash],
271 [fs/dcache.c],[
272 AC_DEFINE(HAVE___D_REHASH, 1,
273             [__d_rehash is exported by the kernel])
274 ],[
275 ])
276 ])
277
278 # The actual symbol exported varies among architectures, so we need
279 # to check many symbols (but only in the current architecture.)  No
280 # matter what symbol is exported, the kernel #defines node_to_cpumask
281 # to the appropriate function and that's what we use.
282 AC_DEFUN([LC_EXPORT_NODE_TO_CPUMASK],
283          [LB_CHECK_SYMBOL_EXPORT([node_to_cpumask],
284                                  [arch/$LINUX_ARCH/mm/numa.c],
285                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
286                                             [node_to_cpumask is exported by
287                                              the kernel])]) # x86_64
288           LB_CHECK_SYMBOL_EXPORT([node_to_cpu_mask],
289                                  [arch/$LINUX_ARCH/kernel/smpboot.c],
290                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
291                                             [node_to_cpumask is exported by
292                                              the kernel])]) # ia64
293           LB_CHECK_SYMBOL_EXPORT([node_2_cpu_mask],
294                                  [arch/$LINUX_ARCH/kernel/smpboot.c],
295                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
296                                             [node_to_cpumask is exported by
297                                              the kernel])]) # i386
298           ])
299
300 #
301 #
302 # between 2.6.5 - 2.6.22 filemap_populate is exported in some kernels
303 #
304 AC_DEFUN([LC_FILEMAP_POPULATE],
305 [AC_MSG_CHECKING([for exported filemap_populate])
306 LB_LINUX_TRY_COMPILE([
307         #include <asm/page.h>
308         #include <linux/mm.h>
309 ],[
310        filemap_populate(NULL, 0, 0, __pgprot(0), 0, 0);
311 ],[
312         AC_MSG_RESULT([yes])
313         AC_DEFINE(HAVE_FILEMAP_POPULATE, 1, [Kernel exports filemap_populate])
314 ],[
315         AC_MSG_RESULT([no])
316 ])
317 ])
318
319 #
320 # added in 2.6.17
321 #
322 AC_DEFUN([LC_BIT_SPINLOCK_H],
323 [LB_CHECK_FILE([$LINUX/include/linux/bit_spinlock.h],[
324         AC_MSG_CHECKING([if bit_spinlock.h can be compiled])
325         LB_LINUX_TRY_COMPILE([
326                 #include <asm/processor.h>
327                 #include <linux/spinlock.h>
328                 #include <linux/bit_spinlock.h>
329         ],[],[
330                 AC_MSG_RESULT([yes])
331                 AC_DEFINE(HAVE_BIT_SPINLOCK_H, 1, [Kernel has bit_spinlock.h])
332         ],[
333                 AC_MSG_RESULT([no])
334         ])
335 ],
336 [])
337 ])
338
339 #
340 # LC_CONST_ACL_SIZE
341 #
342 AC_DEFUN([LC_CONST_ACL_SIZE],
343 [AC_MSG_CHECKING([calc acl size])
344 tmp_flags="$CFLAGS"
345 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"
346 AC_TRY_RUN([
347         #define __KERNEL__
348         #include <linux/types.h>
349         #undef __KERNEL__
350         // block include
351         #define __LINUX_POSIX_ACL_H
352
353         #ifdef CONFIG_FS_POSIX_ACL
354         # include <linux/posix_acl_xattr.h>
355         #endif
356
357         #include <stdio.h>
358
359         int main(void)
360         {
361                 /* LUSTRE_POSIX_ACL_MAX_ENTRIES  = 32 */
362             int size = posix_acl_xattr_size(32);
363             FILE *f = fopen("acl.size","w+");
364             fprintf(f,"%d", size);
365             fclose(f);
366
367             return 0;
368         }
369 ],[
370         acl_size=`cat acl.size`
371         AC_MSG_RESULT([ACL size $acl_size])
372         AC_DEFINE_UNQUOTED(XATTR_ACL_SIZE, AS_TR_SH([$acl_size]), [size of xattr acl])
373 ],[
374         AC_ERROR([ACL size can't be computed])
375 ],[
376         AC_MSG_RESULT([can't check ACL size, make it 260])
377         AC_DEFINE_UNQUOTED(XATTR_ACL_SIZE,260)
378 ])
379 CFLAGS="$tmp_flags"
380 ])
381
382 #
383 # LC_CAPA_CRYPTO
384 #
385 AC_DEFUN([LC_CAPA_CRYPTO],
386 [LB_LINUX_CONFIG_IM([CRYPTO],[],[
387         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO is enabled in your kernel.])
388 ])
389 LB_LINUX_CONFIG_IM([CRYPTO_HMAC],[],[
390         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO_HMAC is enabled in your kernel.])
391 ])
392 LB_LINUX_CONFIG_IM([CRYPTO_SHA1],[],[
393         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO_SHA1 is enabled in your kernel.])
394 ])
395 ])
396
397 #
398 # LC_CONFIG_RMTCLIENT
399 #
400 dnl FIXME
401 dnl the AES symbol usually tied with arch, e.g. CRYPTO_AES_586
402 dnl FIXME
403 AC_DEFUN([LC_CONFIG_RMTCLIENT],
404 [LB_LINUX_CONFIG_IM([CRYPTO_AES],[],[
405         AC_MSG_WARN([Lustre remote client require that CONFIG_CRYPTO_AES is enabled in your kernel.])
406 ])
407 ])
408
409 #
410 # LC_CONFIG_GSS_KEYRING (default enabled, if gss is enabled)
411 #
412 AC_DEFUN([LC_CONFIG_GSS_KEYRING],
413 [AC_MSG_CHECKING([whether to enable gss keyring backend])
414  AC_ARG_ENABLE([gss_keyring],
415                [AC_HELP_STRING([--disable-gss-keyring],
416                                [disable gss keyring backend])],
417                [],[enable_gss_keyring='yes'])
418  AC_MSG_RESULT([$enable_gss_keyring])
419
420  if test x$enable_gss_keyring != xno; then
421         LB_LINUX_CONFIG_IM([KEYS],[],
422                            [AC_MSG_ERROR([GSS keyring backend require that CONFIG_KEYS be enabled in your kernel.])])
423
424         AC_CHECK_LIB([keyutils], [keyctl_search], [],
425                      [AC_MSG_ERROR([libkeyutils is not found, which is required by gss keyring backend])],)
426
427         AC_DEFINE([HAVE_GSS_KEYRING], [1],
428                   [Define this if you enable gss keyring backend])
429  fi
430 ])
431
432 AC_DEFUN([LC_CONFIG_SUNRPC],
433 [LB_LINUX_CONFIG_IM([SUNRPC],[],
434                     [AC_MSG_ERROR([kernel SUNRPC support is required by using GSS.])])
435 ])
436
437 #
438 # LC_CONFIG_GSS (default disabled)
439 #
440 # Build gss and related tools of Lustre. Currently both kernel and user space
441 # parts are depend on linux platform.
442 #
443 AC_DEFUN([LC_CONFIG_GSS],
444 [AC_MSG_CHECKING([whether to enable gss/krb5 support])
445  AC_ARG_ENABLE([gss],
446                [AC_HELP_STRING([--enable-gss], [enable gss/krb5 support])],
447                [],[enable_gss='no'])
448  AC_MSG_RESULT([$enable_gss])
449
450  if test x$enable_gss == xyes; then
451         LC_CONFIG_GSS_KEYRING
452         LC_CONFIG_SUNRPC
453
454         AC_DEFINE([HAVE_GSS], [1], [Define this if you enable gss])
455
456         LB_LINUX_CONFIG_IM([CRYPTO_MD5],[],
457                            [AC_MSG_WARN([kernel MD5 support is recommended by using GSS.])])
458         LB_LINUX_CONFIG_IM([CRYPTO_SHA1],[],
459                            [AC_MSG_WARN([kernel SHA1 support is recommended by using GSS.])])
460         LB_LINUX_CONFIG_IM([CRYPTO_SHA256],[],
461                            [AC_MSG_WARN([kernel SHA256 support is recommended by using GSS.])])
462         LB_LINUX_CONFIG_IM([CRYPTO_SHA512],[],
463                            [AC_MSG_WARN([kernel SHA512 support is recommended by using GSS.])])
464
465         AC_CHECK_LIB([gssapi], [gss_init_sec_context],
466                      [GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssapi"],
467                      [AC_CHECK_LIB([gssglue], [gss_init_sec_context],
468                                    [GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssglue"],
469                                    [AC_MSG_ERROR([libgssapi or libgssglue is not found, which is required by GSS.])])],)
470
471         AC_SUBST(GSSAPI_LIBS)
472
473         AC_KERBEROS_V5
474  fi
475 ])
476
477 AC_DEFUN([LC_QUOTA_READ],
478 [AC_MSG_CHECKING([if kernel supports quota_read])
479 LB_LINUX_TRY_COMPILE([
480         #include <linux/fs.h>
481 ],[
482         struct super_operations sp;
483         void *i = (void *)sp.quota_read;
484 ],[
485         AC_MSG_RESULT([yes])
486         AC_DEFINE(KERNEL_SUPPORTS_QUOTA_READ, 1, [quota_read found])
487 ],[
488         AC_MSG_RESULT([no])
489 ])
490 ])
491
492 #
493 # LC_COOKIE_FOLLOW_LINK
494 #
495 # kernel 2.6.13+ ->follow_link returns a cookie
496 #
497 AC_DEFUN([LC_COOKIE_FOLLOW_LINK],
498 [AC_MSG_CHECKING([if inode_operations->follow_link returns a cookie])
499 LB_LINUX_TRY_COMPILE([
500         #include <linux/fs.h>
501         #include <linux/namei.h>
502 ],[
503         struct dentry *dentry = NULL;
504         struct nameidata nd;
505
506         dentry->d_inode->i_op->put_link(dentry, &nd, NULL);
507 ],[
508         AC_DEFINE(HAVE_COOKIE_FOLLOW_LINK, 1, [inode_operations->follow_link returns a cookie])
509         AC_MSG_RESULT([yes])
510 ],[
511         AC_MSG_RESULT([no])
512 ])
513 ])
514
515 #
516 # LC_FUNC_RCU
517 #
518 # kernels prior than 2.6.0(?) have no RCU supported; in kernel 2.6.5(SUSE),
519 # call_rcu takes three parameters.
520 #
521 AC_DEFUN([LC_FUNC_RCU],
522 [AC_MSG_CHECKING([if kernel have RCU supported])
523 LB_LINUX_TRY_COMPILE([
524         #include <linux/rcupdate.h>
525 ],[],[
526         AC_DEFINE(HAVE_RCU, 1, [have RCU defined])
527         AC_MSG_RESULT([yes])
528
529         AC_MSG_CHECKING([if call_rcu takes three parameters])
530         LB_LINUX_TRY_COMPILE([
531                 #include <linux/rcupdate.h>
532         ],[
533                 struct rcu_head rh;
534                 call_rcu(&rh, (void (*)(struct rcu_head *))1, NULL);
535         ],[
536                 AC_DEFINE(HAVE_CALL_RCU_PARAM, 1, [call_rcu takes three parameters])
537                 AC_MSG_RESULT([yes])
538         ],[
539                 AC_MSG_RESULT([no])
540         ])
541
542 ],[
543         AC_MSG_RESULT([no])
544 ])
545 ])
546
547 AC_DEFUN([LC_PERCPU_COUNTER],
548 [AC_MSG_CHECKING([if have struct percpu_counter defined])
549 LB_LINUX_TRY_COMPILE([
550         #include <linux/percpu_counter.h>
551 ],[],[
552         AC_DEFINE(HAVE_PERCPU_COUNTER, 1, [percpu_counter found])
553         AC_MSG_RESULT([yes])
554
555         AC_MSG_CHECKING([if percpu_counter_inc takes the 2nd argument])
556         LB_LINUX_TRY_COMPILE([
557                 #include <linux/percpu_counter.h>
558         ],[
559                 struct percpu_counter c;
560                 percpu_counter_init(&c, 0);
561         ],[
562                 AC_DEFINE(HAVE_PERCPU_2ND_ARG, 1, [percpu_counter_init has two
563                                                    arguments])
564                 AC_MSG_RESULT([yes])
565         ],[
566                 AC_MSG_RESULT([no])
567         ])
568 ],[
569         AC_MSG_RESULT([no])
570 ])
571 ])
572
573 AC_DEFUN([LC_TASK_CLENV_STORE],
574 [
575         AC_MSG_CHECKING([if we can store cl_env in task_struct])
576         if test x$have_task_clenv_store != xyes ; then
577                 LC_TASK_CLENV_TUX_INFO
578         fi
579 ])
580
581 # ~2.6.11
582
583 AC_DEFUN([LC_S_TIME_GRAN],
584 [AC_MSG_CHECKING([if super block has s_time_gran member])
585 LB_LINUX_TRY_COMPILE([
586         #include <linux/fs.h>
587 ],[
588         struct super_block *sb = NULL;
589
590         return sb->s_time_gran;
591 ],[
592         AC_MSG_RESULT([yes])
593         AC_DEFINE(HAVE_S_TIME_GRAN, 1, [super block has s_time_gran member])
594 ],[
595         AC_MSG_RESULT([no])
596 ])
597 ])
598
599 AC_DEFUN([LC_SB_TIME_GRAN],
600 [AC_MSG_CHECKING([if kernel has old get_sb_time_gran])
601 LB_LINUX_TRY_COMPILE([
602         #include <linux/fs.h>
603 ],[
604         return get_sb_time_gran(NULL);
605 ],[
606         AC_MSG_RESULT([yes])
607         AC_DEFINE(HAVE_SB_TIME_GRAN, 1, [kernel has old get_sb_time_gran])
608 ],[
609         AC_MSG_RESULT([no])
610 ])
611 ])
612
613 # 2.6.12
614
615 # ~2.6.12 merge patch from oracle to convert tree_lock from spinlock to rwlock
616 AC_DEFUN([LC_RW_TREE_LOCK],
617 [AC_MSG_CHECKING([if kernel has tree_lock as rwlock])
618 tmp_flags="$EXTRA_KCFLAGS"
619 EXTRA_KCFLAGS="-Werror"
620 LB_LINUX_TRY_COMPILE([
621         #include <linux/fs.h>
622 ],[
623         struct address_space a;
624
625         write_lock(&a.tree_lock);
626 ],[
627         AC_MSG_RESULT([yes])
628         AC_DEFINE(HAVE_RW_TREE_LOCK, 1, [kernel has tree_lock as rw_lock])
629 ],[
630         AC_MSG_RESULT([no])
631 ])
632 EXTRA_KCFLAGS="$tmp_flags"
633 ])
634
635 # 2.6.15
636
637 # LC_INODE_I_MUTEX
638 # after 2.6.15 inode have i_mutex intead of i_sem
639 AC_DEFUN([LC_INODE_I_MUTEX],
640 [AC_MSG_CHECKING([if inode has i_mutex ])
641 LB_LINUX_TRY_COMPILE([
642         #include <linux/mutex.h>
643         #include <linux/fs.h>
644         #undef i_mutex
645 ],[
646         struct inode i;
647
648         mutex_unlock(&i.i_mutex);
649 ],[
650         AC_MSG_RESULT(yes)
651         AC_DEFINE(HAVE_INODE_I_MUTEX, 1,
652                 [after 2.6.15 inode have i_mutex intead of i_sem])
653 ],[
654         AC_MSG_RESULT(no)
655 ])
656 ])
657
658 # 2.6.16
659
660 # LC_SECURITY_PLUG  # for SLES10 SP2
661 # check security plug in sles10 sp2 kernel
662 AC_DEFUN([LC_SECURITY_PLUG],
663 [AC_MSG_CHECKING([If kernel has security plug support])
664 LB_LINUX_TRY_COMPILE([
665         #include <linux/fs.h>
666         #include <linux/stddef.h>
667 ],[
668         notify_change(NULL, NULL, NULL);
669 ],[
670         AC_MSG_RESULT(yes)
671         AC_DEFINE(HAVE_SECURITY_PLUG, 1,
672                 [SLES10 SP2 use extra parameter in vfs])
673 ],[
674         AC_MSG_RESULT(no)
675 ])
676 ])
677
678 # 2.6.17
679
680 # inode have i_private field since 2.6.17
681 AC_DEFUN([LC_INODE_IPRIVATE],
682 [AC_MSG_CHECKING([if inode has a i_private field])
683 LB_LINUX_TRY_COMPILE([
684 #include <linux/fs.h>
685 ],[
686         struct inode i;
687         i.i_private = NULL; 
688 ],[
689         AC_MSG_RESULT(yes)
690         AC_DEFINE(HAVE_INODE_IPRIVATE, 1,
691                 [struct inode has i_private field])
692 ],[
693         AC_MSG_RESULT(no)
694 ])
695 ])
696
697 # LC_DQUOTOFF_MUTEX
698 # after 2.6.17 dquote use mutex instead if semaphore
699 AC_DEFUN([LC_DQUOTOFF_MUTEX],
700 [AC_MSG_CHECKING([use dqonoff_mutex])
701 LB_LINUX_TRY_COMPILE([
702         #include <linux/mutex.h>
703         #include <linux/fs.h>
704         #include <linux/quota.h>
705 ],[
706         struct quota_info dq;
707
708         mutex_unlock(&dq.dqonoff_mutex);
709 ],[
710         AC_MSG_RESULT(yes)
711         AC_DEFINE(HAVE_DQUOTOFF_MUTEX, 1,
712                 [after 2.6.17 dquote use mutex instead if semaphore])
713 ],[
714         AC_MSG_RESULT(no)
715 ])
716 ])
717
718 # 2.6.18
719
720 # LC_NR_PAGECACHE
721 # 2.6.18 don't export nr_pagecahe
722 AC_DEFUN([LC_NR_PAGECACHE],
723 [AC_MSG_CHECKING([kernel export nr_pagecache])
724 LB_LINUX_TRY_COMPILE([
725         #include <linux/pagemap.h>
726 ],[
727         return atomic_read(&nr_pagecache);
728 ],[
729         AC_MSG_RESULT(yes)
730         AC_DEFINE(HAVE_NR_PAGECACHE, 1,
731                 [is kernel export nr_pagecache])
732 ],[
733         AC_MSG_RESULT(no)
734 ])
735 ])
736
737 #
738 # LC_STATFS_DENTRY_PARAM
739 # starting from 2.6.18 linux kernel uses dentry instead of super_block
740 # for the first parameter of the super_operations->statfs() callback.
741 #
742 #
743 AC_DEFUN([LC_STATFS_DENTRY_PARAM],
744 [AC_MSG_CHECKING([if super_ops.statfs() first parameter is dentry])
745 tmp_flags="$EXTRA_KCFLAGS"
746 EXTRA_KCFLAGS="-Werror"
747 LB_LINUX_TRY_COMPILE([
748         #include <linux/fs.h>
749 ],[
750         ((struct super_operations *)0)->statfs((struct dentry *)0, (struct kstatfs*)0);
751 ],[
752         AC_DEFINE(HAVE_STATFS_DENTRY_PARAM, 1,
753                   [super_ops.statfs() first parameter is dentry])
754         AC_MSG_RESULT([yes])
755 ],[
756         AC_MSG_RESULT([no])
757 ])
758 EXTRA_KCFLAGS="$tmp_flags"
759 ])
760
761 # LC_UMOUNTBEGIN_HAS_VFSMOUNT
762 # 2.6.18~2.6.25 umount_begin has different parameters
763 AC_DEFUN([LC_UMOUNTBEGIN_HAS_VFSMOUNT],
764 [AC_MSG_CHECKING([if umount_begin needs vfsmount parameter instead of super_block])
765 tmp_flags="$EXTRA_KCFLAGS"
766 EXTRA_KCFLAGS="-Werror"
767 LB_LINUX_TRY_COMPILE([
768         #include <linux/fs.h>
769
770         struct vfsmount;
771         static void cfg_umount_begin (struct vfsmount *v, int flags)
772         {
773                 ;
774         }
775
776         static struct super_operations cfg_super_operations = {
777                 .umount_begin   = cfg_umount_begin,
778         };
779 ],[
780         cfg_super_operations.umount_begin(NULL,0);
781 ],[
782         AC_MSG_RESULT(yes)
783         AC_DEFINE(HAVE_UMOUNTBEGIN_VFSMOUNT, 1,
784                 [Define umount_begin need second argument])
785 ],[
786         AC_MSG_RESULT(no)
787 ])
788 EXTRA_KCFLAGS="$tmp_flags"
789 ])
790
791 # LC_FLUSH_OWNER_ID
792 # starting from 2.6.18 the file_operations .flush
793 # method has a new "fl_owner_t id" parameter
794 #
795 AC_DEFUN([LC_FLUSH_OWNER_ID],
796 [AC_MSG_CHECKING([if file_operations .flush has an fl_owner_t id])
797 LB_LINUX_TRY_COMPILE([
798         #include <linux/fs.h>
799 ],[
800         struct file_operations *fops = NULL;
801         fl_owner_t id = NULL;
802         int i;
803
804         i = fops->flush(NULL, id);
805 ],[
806         AC_DEFINE(HAVE_FLUSH_OWNER_ID, 1,
807                 [file_operations .flush method has an fl_owner_t id])
808         AC_MSG_RESULT([yes])
809 ],[
810         AC_MSG_RESULT([no])
811 ])
812 ])
813
814 #
815 # LC_EXPORT_INVALIDATE_MAPPING_PAGES
816 #
817 # SLES9, RHEL4, RHEL5, vanilla 2.6.24 export invalidate_mapping_pages() but
818 # SLES10 2.6.16 does not, for some reason.  For filter cache invalidation.
819 #
820 AC_DEFUN([LC_EXPORT_INVALIDATE_MAPPING_PAGES],
821     [LB_CHECK_SYMBOL_EXPORT([invalidate_mapping_pages], [mm/truncate.c], [
822          AC_DEFINE(HAVE_INVALIDATE_MAPPING_PAGES, 1,
823                         [exported invalidate_mapping_pages])],
824     [LB_CHECK_SYMBOL_EXPORT([invalidate_inode_pages], [mm/truncate.c], [
825          AC_DEFINE(HAVE_INVALIDATE_INODE_PAGES, 1,
826                         [exported invalidate_inode_pages])], [
827        AC_MSG_ERROR([no way to invalidate pages])
828   ])
829     ],[])
830 ])
831
832 #2.6.18 + RHEL5 (fc6)
833
834 # RHEL5 in FS-cache patch rename PG_checked flag into PG_fs_misc
835 AC_DEFUN([LC_PG_FS_MISC],
836 [AC_MSG_CHECKING([kernel has PG_fs_misc])
837 LB_LINUX_TRY_COMPILE([
838         #include <linux/mm.h>
839         #include <linux/page-flags.h>
840 ],[
841         #ifndef PG_fs_misc
842         #error PG_fs_misc not defined in kernel
843         #endif
844 ],[
845         AC_MSG_RESULT(yes)
846         AC_DEFINE(HAVE_PG_FS_MISC, 1,
847                   [is kernel have PG_fs_misc])
848 ],[
849         AC_MSG_RESULT(no)
850 ])
851 ])
852
853 # RHEL5 PageChecked and SetPageChecked defined
854 AC_DEFUN([LC_PAGE_CHECKED],
855 [AC_MSG_CHECKING([kernel has PageChecked and SetPageChecked])
856 LB_LINUX_TRY_COMPILE([
857         #include <linux/mm.h>
858 #ifdef HAVE_LINUX_MMTYPES_H
859         #include <linux/mm_types.h>
860 #endif
861         #include <linux/page-flags.h>
862 ],[
863         struct page *p = NULL;
864
865         /* before 2.6.26 this define*/
866         #ifndef PageChecked     
867         /* 2.6.26 use function instead of define for it */
868         SetPageChecked(p);
869         PageChecked(p);
870         #endif
871 ],[
872         AC_MSG_RESULT(yes)
873         AC_DEFINE(HAVE_PAGE_CHECKED, 1,
874                   [does kernel have PageChecked and SetPageChecked])
875 ],[
876         AC_MSG_RESULT(no)
877 ])
878 ])
879
880 #
881 # LC_LINUX_FIEMAP_H
882 #
883 # If we have fiemap.h
884 # after 2.6.27 use fiemap.h in include/linux
885 #
886 AC_DEFUN([LC_LINUX_FIEMAP_H],
887 [LB_CHECK_FILE([$LINUX/include/linux/fiemap.h],[
888         AC_MSG_CHECKING([if fiemap.h can be compiled])
889         LB_LINUX_TRY_COMPILE([
890                 #include <linux/types.h>
891                 #include <linux/fiemap.h>
892         ],[],[
893                 AC_MSG_RESULT([yes])
894                 AC_DEFINE(HAVE_LINUX_FIEMAP_H, 1, [Kernel has fiemap.h])
895         ],[
896                 AC_MSG_RESULT([no])
897         ])
898 ],
899 [])
900 ])
901
902 # 2.6.19
903
904 # 2.6.19 API changes
905 # inode don't have i_blksize field
906 AC_DEFUN([LC_INODE_BLKSIZE],
907 [AC_MSG_CHECKING([inode has i_blksize field])
908 LB_LINUX_TRY_COMPILE([
909 #include <linux/fs.h>
910 ],[
911         struct inode i;
912         i.i_blksize = 0;
913 ],[
914         AC_MSG_RESULT(yes)
915         AC_DEFINE(HAVE_INODE_BLKSIZE, 1,
916                 [struct inode has i_blksize field])
917 ],[
918         AC_MSG_RESULT(no)
919 ])
920 ])
921
922 # LC_FILE_WRITEV
923 # 2.6.19 replaced writev with aio_write
924 AC_DEFUN([LC_FILE_WRITEV],
925 [AC_MSG_CHECKING([writev in fops])
926 LB_LINUX_TRY_COMPILE([
927         #include <linux/fs.h>
928 ],[
929         struct file_operations *fops = NULL;
930         fops->writev = NULL;
931 ],[
932         AC_MSG_RESULT(yes)
933         AC_DEFINE(HAVE_FILE_WRITEV, 1,
934                 [use fops->writev])
935 ],[
936         AC_MSG_RESULT(no)
937 ])
938 ])
939
940 # LC_FILE_READV
941 # 2.6.19 replaced readv with aio_read
942 AC_DEFUN([LC_FILE_READV],
943 [AC_MSG_CHECKING([readv in fops])
944 LB_LINUX_TRY_COMPILE([
945         #include <linux/fs.h>
946 ],[
947         struct file_operations *fops = NULL;
948         fops->readv = NULL;
949 ],[
950         AC_MSG_RESULT(yes)
951         AC_DEFINE(HAVE_FILE_READV, 1,
952                 [use fops->readv])
953 ],[
954         AC_MSG_RESULT(no)
955 ])
956 ])
957
958 # 2.6.20
959
960 # LC_CANCEL_DIRTY_PAGE
961 # 2.6.20 introduced cancel_dirty_page instead of clear_page_dirty.
962 AC_DEFUN([LC_CANCEL_DIRTY_PAGE],
963         [AC_MSG_CHECKING([kernel has cancel_dirty_page])
964         # the implementation of cancel_dirty_page in OFED 1.4.1's SLES10 SP2
965         # backport is broken, so ignore it
966         if test -f $OFED_BACKPORT_PATH/linux/mm.h &&
967            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
968                 AC_MSG_RESULT(no)
969         else
970                 LB_LINUX_TRY_COMPILE([
971                         #include <linux/mm.h>
972                         #include <linux/page-flags.h>
973 ],[
974                         cancel_dirty_page(NULL, 0);
975 ],[
976                         AC_MSG_RESULT(yes)
977                         AC_DEFINE(HAVE_CANCEL_DIRTY_PAGE, 1,
978                                   [kernel has cancel_dirty_page instead of clear_page_dirty])
979 ],[
980                         AC_MSG_RESULT(no)
981 ])
982         fi
983 ])
984
985 # raid5-zerocopy patch
986
987 #
988 # LC_PAGE_CONSTANT
989 #
990 # In order to support raid5 zerocopy patch, we have to patch the kernel to make
991 # it support constant page, which means the page won't be modified during the
992 # IO.
993 #
994 AC_DEFUN([LC_PAGE_CONSTANT],
995 [AC_MSG_CHECKING([if kernel have PageConstant defined])
996 LB_LINUX_TRY_COMPILE([
997         #include <linux/mm.h>
998         #include <linux/page-flags.h>
999 ],[
1000         #ifndef PG_constant
1001         #error "Have no raid5 zcopy patch"
1002         #endif
1003 ],[
1004         AC_MSG_RESULT(yes)
1005         AC_DEFINE(HAVE_PAGE_CONSTANT, 1, [kernel have PageConstant supported])
1006 ],[
1007         AC_MSG_RESULT(no);
1008 ])
1009 ])
1010
1011 # 2.6.22
1012
1013 # 2.6.22 lost second parameter for invalidate_bdev
1014 AC_DEFUN([LC_INVALIDATE_BDEV_2ARG],
1015 [AC_MSG_CHECKING([if invalidate_bdev has second argument])
1016 LB_LINUX_TRY_COMPILE([
1017         #include <linux/buffer_head.h>
1018 ],[
1019         invalidate_bdev(NULL,0);
1020 ],[
1021         AC_MSG_RESULT([yes])
1022         AC_DEFINE(HAVE_INVALIDATE_BDEV_2ARG, 1,
1023                 [invalidate_bdev has second argument])
1024 ],[
1025         AC_MSG_RESULT([no])
1026 ])
1027 ])
1028
1029 #
1030 # check for crypto API
1031 #
1032 AC_DEFUN([LC_ASYNC_BLOCK_CIPHER],
1033 [AC_MSG_CHECKING([if kernel has block cipher support])
1034 LB_LINUX_TRY_COMPILE([
1035         #include <linux/err.h>
1036         #include <linux/crypto.h>
1037 ],[
1038         struct crypto_blkcipher *tfm;
1039         tfm = crypto_alloc_blkcipher("aes", 0, sizeof(tfm) );
1040 ],[
1041         AC_MSG_RESULT([yes])
1042         AC_DEFINE(HAVE_ASYNC_BLOCK_CIPHER, 1, [kernel has block cipher support])
1043 ],[
1044         AC_MSG_RESULT([no])
1045 ])
1046 ])
1047
1048 #
1049 # check for struct hash_desc
1050 #
1051 AC_DEFUN([LC_STRUCT_HASH_DESC],
1052 [AC_MSG_CHECKING([if kernel has struct hash_desc])
1053 LB_LINUX_TRY_COMPILE([
1054         #include <linux/err.h>
1055         #include <linux/crypto.h>
1056 ],[
1057         struct hash_desc foo __attribute__ ((unused));
1058 ],[
1059         AC_MSG_RESULT([yes])
1060         AC_DEFINE(HAVE_STRUCT_HASH_DESC, 1, [kernel has struct hash_desc])
1061 ],[
1062         AC_MSG_RESULT([no])
1063 ])
1064 ])
1065
1066 #
1067 # check for struct blkcipher_desc
1068 #
1069 AC_DEFUN([LC_STRUCT_BLKCIPHER_DESC],
1070 [AC_MSG_CHECKING([if kernel has struct blkcipher_desc])
1071 LB_LINUX_TRY_COMPILE([
1072         #include <linux/err.h>
1073         #include <linux/crypto.h>
1074 ],[
1075         struct blkcipher_desc foo __attribute__ ((unused));
1076 ],[
1077         AC_MSG_RESULT([yes])
1078         AC_DEFINE(HAVE_STRUCT_BLKCIPHER_DESC, 1, [kernel has struct blkcipher_desc])
1079 ],[
1080         AC_MSG_RESULT([no])
1081 ])
1082 ])
1083
1084 #
1085 # 2.6.19 check for FS_RENAME_DOES_D_MOVE flag
1086 #
1087 AC_DEFUN([LC_FS_RENAME_DOES_D_MOVE],
1088 [AC_MSG_CHECKING([if kernel has FS_RENAME_DOES_D_MOVE flag])
1089 LB_LINUX_TRY_COMPILE([
1090         #include <linux/fs.h>
1091 ],[
1092         int v __attribute__ ((unused));
1093         v = FS_RENAME_DOES_D_MOVE;
1094 ],[
1095         AC_MSG_RESULT([yes])
1096         AC_DEFINE(HAVE_FS_RENAME_DOES_D_MOVE, 1, [kernel has FS_RENAME_DOES_D_MOVE flag])
1097 ],[
1098         AC_MSG_RESULT([no])
1099 ])
1100 ])
1101
1102 # 2.6.23
1103
1104 # 2.6.23 have return type 'void' for unregister_blkdev
1105 AC_DEFUN([LC_UNREGISTER_BLKDEV_RETURN_INT],
1106 [AC_MSG_CHECKING([if unregister_blkdev return int])
1107 LB_LINUX_TRY_COMPILE([
1108         #include <linux/fs.h>
1109 ],[
1110         int i __attribute__ ((unused));
1111         i = unregister_blkdev(0,NULL);
1112 ],[
1113         AC_MSG_RESULT([yes])
1114         AC_DEFINE(HAVE_UNREGISTER_BLKDEV_RETURN_INT, 1,
1115                 [unregister_blkdev return int])
1116 ],[
1117         AC_MSG_RESULT([no])
1118 ])
1119 ])
1120
1121 # 2.6.23 change .sendfile to .splice_read
1122 AC_DEFUN([LC_KERNEL_SPLICE_READ],
1123 [AC_MSG_CHECKING([if kernel has .splice_read])
1124 LB_LINUX_TRY_COMPILE([
1125         #include <linux/fs.h>
1126 ],[
1127         struct file_operations file;
1128
1129         file.splice_read = NULL;
1130 ], [
1131         AC_MSG_RESULT([yes])
1132         AC_DEFINE(HAVE_KERNEL_SPLICE_READ, 1,
1133                 [kernel has .slice_read])
1134 ],[
1135         AC_MSG_RESULT([no])
1136 ])
1137 ])
1138
1139 # 2.6.23 change .sendfile to .splice_read
1140 # RHEL4 (-92 kernel) have both sendfile and .splice_read API
1141 AC_DEFUN([LC_KERNEL_SENDFILE],
1142 [AC_MSG_CHECKING([if kernel has .sendfile])
1143 LB_LINUX_TRY_COMPILE([
1144         #include <linux/fs.h>
1145 ],[
1146         struct file_operations file;
1147
1148         file.sendfile = NULL;
1149 ], [
1150         AC_MSG_RESULT([yes])
1151         AC_DEFINE(HAVE_KERNEL_SENDFILE, 1,
1152                 [kernel has .sendfile])
1153 ],[
1154         AC_MSG_RESULT([no])
1155 ])
1156 ])
1157
1158 # 2.6.23 extract nfs export related data into exportfs.h
1159 AC_DEFUN([LC_HAVE_EXPORTFS_H],
1160 [LB_CHECK_FILE([$LINUX/include/linux/exportfs.h], [
1161         AC_DEFINE(HAVE_LINUX_EXPORTFS_H, 1,
1162                 [kernel has include/exportfs.h])
1163 ],[
1164         AC_MSG_RESULT([no])
1165 ])
1166 ])
1167
1168 # 2.6.23 has new page fault handling API
1169 AC_DEFUN([LC_VM_OP_FAULT],
1170 [AC_MSG_CHECKING([kernel has .fault in vm_operation_struct])
1171 LB_LINUX_TRY_COMPILE([
1172         #include <linux/mm.h>
1173 ],[
1174         struct vm_operations_struct op;
1175
1176         op.fault = NULL;
1177 ], [
1178         AC_MSG_RESULT([yes])
1179         AC_DEFINE(HAVE_VM_OP_FAULT, 1,
1180                 [kernel has .fault in vm_operation_struct])
1181 ],[
1182         AC_MSG_RESULT([no])
1183 ])
1184 ])
1185
1186 # 2.6.23 add code to wait other users to complete before removing procfs entry
1187 AC_DEFUN([LC_PROCFS_USERS],
1188 [AC_MSG_CHECKING([if kernel has pde_users member in procfs entry struct])
1189 LB_LINUX_TRY_COMPILE([
1190         #include <linux/proc_fs.h>
1191 ],[
1192         struct proc_dir_entry pde;
1193
1194         pde.pde_users   = 0;
1195 ],[
1196         AC_MSG_RESULT([yes])
1197         AC_DEFINE(HAVE_PROCFS_USERS, 1,
1198                 [kernel has pde_users member in procfs entry struct])
1199 ],[
1200         AC_MSG_RESULT([no])
1201 ])
1202 ])
1203
1204 # 2.6.23 exports exportfs_decode_fh
1205 AC_DEFUN([LC_EXPORTFS_DECODE_FH],
1206 [LB_CHECK_SYMBOL_EXPORT([exportfs_decode_fh],
1207 [fs/exportfs/expfs.c],[
1208         AC_DEFINE(HAVE_EXPORTFS_DECODE_FH, 1,
1209                 [exportfs_decode_fh has been export])
1210 ],[
1211 ])
1212 ])
1213
1214 # 2.6.24
1215
1216 # 2.6.24 need linux/mm_types.h included
1217 AC_DEFUN([LC_HAVE_MMTYPES_H],
1218 [LB_CHECK_FILE([$LINUX/include/linux/mm_types.h], [
1219         AC_DEFINE(HAVE_LINUX_MMTYPES_H, 1,
1220                 [kernel has include/mm_types.h])
1221 ],[
1222         AC_MSG_RESULT([no])
1223 ])
1224 ])
1225
1226 # 2.6.24 has bio_endio with 2 args
1227 AC_DEFUN([LC_BIO_ENDIO_2ARG],
1228 [AC_MSG_CHECKING([if kernel has bio_endio with 2 args])
1229 LB_LINUX_TRY_COMPILE([
1230         #include <linux/bio.h>
1231 ],[
1232         bio_endio(NULL, 0);
1233 ], [
1234         AC_MSG_RESULT([yes])
1235         AC_DEFINE(HAVE_BIO_ENDIO_2ARG, 1,
1236                 [kernel has bio_endio with 2 args])
1237 ],[
1238         AC_MSG_RESULT([no])
1239 ])
1240 ])
1241
1242 # 2.6.24 has new members in exports struct.
1243 AC_DEFUN([LC_FH_TO_DENTRY],
1244 [AC_MSG_CHECKING([if kernel has .fh_to_dentry member in export_operations struct])
1245 LB_LINUX_TRY_COMPILE([
1246         #include <linux/fs.h>
1247 #ifdef HAVE_LINUX_EXPORTFS_H
1248         #include <linux/exportfs.h>
1249 #endif
1250 ],[
1251         do{ }while(sizeof(((struct export_operations *)0)->fh_to_dentry));
1252 ], [
1253         AC_MSG_RESULT([yes])
1254         AC_DEFINE(HAVE_FH_TO_DENTRY, 1,
1255                 [kernel has .fh_to_dentry member in export_operations struct])
1256 ],[
1257         AC_MSG_RESULT([no])
1258 ])
1259 ])
1260
1261 # 2.6.24 removes long aged procfs entry -> deleted member
1262 AC_DEFUN([LC_PROCFS_DELETED],
1263 [AC_MSG_CHECKING([if kernel has deleted member in procfs entry struct])
1264 LB_LINUX_TRY_COMPILE([
1265         #include <linux/proc_fs.h>
1266 ],[
1267         struct proc_dir_entry pde;
1268
1269         pde.deleted = sizeof(pde);
1270 ], [
1271         AC_MSG_RESULT([yes])
1272         AC_DEFINE(HAVE_PROCFS_DELETED, 1,
1273                 [kernel has deleted member in procfs entry struct])
1274 ],[
1275         AC_MSG_RESULT([no])
1276 ])
1277 ])
1278
1279 # 2.6.24 has bdi_init()/bdi_destroy() functions.
1280 AC_DEFUN([LC_EXPORT_BDI_INIT],
1281 [LB_CHECK_SYMBOL_EXPORT([bdi_init],
1282 [mm/backing-dev.c],[
1283         AC_DEFINE(HAVE_BDI_INIT, 1,
1284                 [bdi_init/bdi_destroy functions are present])
1285 ],[
1286 ])
1287 ])
1288
1289 # 2.6.26
1290
1291 # 2.6.26 isn't export set_fs_pwd and change paramter in fs struct
1292 AC_DEFUN([LC_FS_STRUCT_USE_PATH],
1293 [AC_MSG_CHECKING([fs_struct use path structure])
1294 LB_LINUX_TRY_COMPILE([
1295         #include <asm/atomic.h>
1296         #include <linux/spinlock.h>
1297         #include <linux/fs_struct.h>
1298 ],[
1299         struct fs_struct fs;
1300
1301         fs.pwd = *((struct path *)sizeof(fs));
1302 ], [
1303         AC_MSG_RESULT([yes])
1304         AC_DEFINE(HAVE_FS_STRUCT_USE_PATH, 1,
1305                 [fs_struct use path structure])
1306 ],[
1307         AC_MSG_RESULT([no])
1308 ])
1309 ])
1310
1311
1312 #
1313 # 2.6.27
1314 #
1315 AC_DEFUN([LC_PGMKWRITE_USE_VMFAULT],
1316 [AC_MSG_CHECKING([kernel .page_mkwrite uses struct vm_fault *])
1317 tmp_flags="$EXTRA_KCFLAGS"
1318 EXTRA_KCFLAGS="-Werror"
1319 LB_LINUX_TRY_COMPILE([
1320         #include <linux/mm.h>
1321 ],[
1322         ((struct vm_operations_struct *)0)->page_mkwrite((struct vm_area_struct *)0, (struct vm_fault *)0);
1323 ], [
1324         AC_MSG_RESULT([yes])
1325         AC_DEFINE(HAVE_PGMKWRITE_USE_VMFAULT, 1,
1326                 [kernel vm_operation_struct.page_mkwrite uses struct vm_fault * as second parameter])
1327 ],[
1328         AC_MSG_RESULT([no])
1329 ])
1330 EXTRA_KCFLAGS="$tmp_flags"
1331 ])
1332
1333 AC_DEFUN([LC_INODE_PERMISION_2ARGS],
1334 [AC_MSG_CHECKING([inode_operations->permission has two args])
1335 LB_LINUX_TRY_COMPILE([
1336         #include <linux/fs.h>
1337 ],[
1338         struct inode *inode __attribute__ ((unused));
1339
1340         inode = NULL;
1341         inode->i_op->permission(NULL, 0);
1342 ],[
1343         AC_DEFINE(HAVE_INODE_PERMISION_2ARGS, 1,
1344                   [inode_operations->permission has two args])
1345         AC_MSG_RESULT([yes])
1346 ],[
1347         AC_MSG_RESULT([no])
1348 ])
1349 ])
1350
1351 # 2.6.27 has file_remove_suid instead of remove_suid
1352 AC_DEFUN([LC_FILE_REMOVE_SUID],
1353 [AC_MSG_CHECKING([kernel has file_remove_suid])
1354 LB_LINUX_TRY_COMPILE([
1355         #include <linux/fs.h>
1356 ],[
1357         file_remove_suid(NULL);
1358 ],[
1359         AC_DEFINE(HAVE_FILE_REMOVE_SUID, 1,
1360                   [kernel have file_remove_suid])
1361         AC_MSG_RESULT([yes])
1362 ],[
1363         AC_MSG_RESULT([no])
1364 ])
1365 ])
1366
1367 # 2.6.27 have new page locking API
1368 AC_DEFUN([LC_TRYLOCKPAGE],
1369 [AC_MSG_CHECKING([kernel uses trylock_page for page lock])
1370 LB_LINUX_TRY_COMPILE([
1371         #include <linux/pagemap.h>
1372 ],[
1373         trylock_page(NULL);
1374 ],[
1375         AC_DEFINE(HAVE_TRYLOCK_PAGE, 1,
1376                   [kernel uses trylock_page for page lock])
1377         AC_MSG_RESULT([yes])
1378 ],[
1379         AC_MSG_RESULT([no])
1380 ])
1381 ])
1382
1383 # 2.6.27 removed the read_inode from super_operations.
1384 AC_DEFUN([LC_READ_INODE_IN_SBOPS],
1385 [AC_MSG_CHECKING([super_operations has a read_inode field])
1386 LB_LINUX_TRY_COMPILE([
1387         #include <linux/fs.h>
1388 ],[
1389         struct super_operations *sop;
1390         sop->read_inode(NULL);
1391 ],[
1392         AC_DEFINE(HAVE_READ_INODE_IN_SBOPS, 1,
1393                 [super_operations has a read_inode])
1394         AC_MSG_RESULT([yes])
1395 ],[
1396         AC_MSG_RESULT([no])
1397 ])
1398 ])
1399
1400 # 2.6.27 has inode_permission instead of permisson
1401 AC_DEFUN([LC_EXPORT_INODE_PERMISSION],
1402 [LB_CHECK_SYMBOL_EXPORT([inode_permission],
1403 [fs/namei.c],[
1404 AC_DEFINE(HAVE_EXPORT_INODE_PERMISSION, 1,
1405             [inode_permission is exported by the kernel])
1406 ],[
1407 ])
1408 ])
1409
1410 # 2.6.27 use 5th parameter in quota_on for remount.
1411 AC_DEFUN([LC_QUOTA_ON_5ARGS],
1412 [AC_MSG_CHECKING([quota_on needs 5 parameters])
1413 LB_LINUX_TRY_COMPILE([
1414         #include <linux/fs.h>
1415         #include <linux/quota.h>
1416 ],[
1417         struct quotactl_ops *qop = NULL;
1418         qop->quota_on(NULL, 0, 0, NULL, 0);
1419 ],[
1420         AC_DEFINE(HAVE_QUOTA_ON_5ARGS, 1,
1421                 [quota_on needs 5 paramters])
1422         AC_MSG_RESULT([yes])
1423 ],[
1424         AC_MSG_RESULT([no])
1425 ])
1426 ])
1427
1428 # 2.6.27 use 3th parameter in quota_off for remount.
1429 AC_DEFUN([LC_QUOTA_OFF_3ARGS],
1430 [AC_MSG_CHECKING([quota_off needs 3 parameters])
1431 LB_LINUX_TRY_COMPILE([
1432         #include <linux/fs.h>
1433         #include <linux/quota.h>
1434 ],[
1435         struct quotactl_ops *qop = NULL;
1436         qop->quota_off(NULL, 0, 0);
1437 ],[
1438         AC_DEFINE(HAVE_QUOTA_OFF_3ARGS, 1,
1439                 [quota_off needs 3 paramters])
1440         AC_MSG_RESULT([yes])
1441 ],[
1442         AC_MSG_RESULT([no])
1443 ])
1444 ])
1445
1446 # 2.6.27 has vfs_dq_off inline function.
1447 AC_DEFUN([LC_VFS_DQ_OFF],
1448 [AC_MSG_CHECKING([vfs_dq_off is defined])
1449 LB_LINUX_TRY_COMPILE([
1450         #include <linux/quotaops.h>
1451 ],[
1452         vfs_dq_off(NULL, 0);
1453 ],[
1454         AC_DEFINE(HAVE_VFS_DQ_OFF, 1, [vfs_dq_off is defined])
1455         AC_MSG_RESULT([yes])
1456 ],[
1457         AC_MSG_RESULT([no])
1458 ])
1459 ])
1460
1461 # LC_LOCK_MAP_ACQUIRE
1462 # after 2.6.27 lock_map_acquire replaces lock_acquire
1463 AC_DEFUN([LC_LOCK_MAP_ACQUIRE],
1464 [AC_MSG_CHECKING([if lock_map_acquire is defined])
1465 LB_LINUX_TRY_COMPILE([
1466         #include <linux/lockdep.h>
1467 ],[
1468         lock_map_acquire(NULL);
1469 ],[
1470         AC_MSG_RESULT(yes)
1471         AC_DEFINE(HAVE_LOCK_MAP_ACQUIRE, 1,
1472                 [lock_map_acquire is defined])
1473 ],[
1474         AC_MSG_RESULT(no)
1475 ])
1476 ])
1477
1478 # 2.6.27.15-2 sles11
1479
1480 # 2.6.27 sles11 remove the bi_hw_segments
1481 AC_DEFUN([LC_BI_HW_SEGMENTS],
1482 [AC_MSG_CHECKING([struct bio has a bi_hw_segments field])
1483 LB_LINUX_TRY_COMPILE([
1484         #include <linux/bio.h>
1485 ],[
1486         struct bio io;
1487         io.bi_hw_segments = sizeof(io);
1488 ],[
1489         AC_DEFINE(HAVE_BI_HW_SEGMENTS, 1,
1490                 [struct bio has a bi_hw_segments field])
1491         AC_MSG_RESULT([yes])
1492 ],[
1493         AC_MSG_RESULT([no])
1494 ])
1495 ])
1496
1497 #
1498 # 2.6.27 sles11 move the quotaio_v1{2}.h from include/linux to fs
1499 # 2.6.32 move the quotaio_v1{2}.h from fs to fs/quota
1500 AC_DEFUN([LC_HAVE_QUOTAIO_H],
1501 [LB_CHECK_FILE([$LINUX/include/linux/quotaio_v2.h],[
1502         AC_DEFINE(HAVE_QUOTAIO_H, 1,
1503                 [kernel has include/linux/quotaio_v2.h])
1504 ],[LB_CHECK_FILE([$LINUX/fs/quotaio_v2.h],[
1505                AC_DEFINE(HAVE_FS_QUOTAIO_H, 1,
1506                 [kernel has fs/quotaio_v1.h])
1507 ],[LB_CHECK_FILE([$LINUX/fs/quota/quotaio_v2.h],[
1508                AC_DEFINE(HAVE_FS_QUOTA_QUOTAIO_H, 1,
1509                 [kernel has fs/quota/quotaio_v2.h])
1510 ],[
1511         AC_MSG_RESULT([no])
1512 ])
1513 ])
1514 ])
1515 ])
1516
1517 # 2.6.27 sles11 has sb_any_quota_active
1518 AC_DEFUN([LC_SB_ANY_QUOTA_ACTIVE],
1519 [AC_MSG_CHECKING([Kernel has sb_any_quota_active])
1520 LB_LINUX_TRY_COMPILE([
1521         #include <linux/quotaops.h>
1522 ],[
1523         sb_any_quota_active(NULL);
1524 ],[
1525         AC_DEFINE(HAVE_SB_ANY_QUOTA_ACTIVE, 1,
1526                 [Kernel has a sb_any_quota_active])
1527         AC_MSG_RESULT([yes])
1528 ],[
1529         AC_MSG_RESULT([no])
1530 ])
1531 ])
1532
1533 # 2.6.27 sles11 has sb_has_quota_active
1534 AC_DEFUN([LC_SB_HAS_QUOTA_ACTIVE],
1535 [AC_MSG_CHECKING([Kernel has sb_has_quota_active])
1536 LB_LINUX_TRY_COMPILE([
1537         #include <linux/quotaops.h>
1538 ],[
1539         sb_has_quota_active(NULL, 0);
1540 ],[
1541         AC_DEFINE(HAVE_SB_HAS_QUOTA_ACTIVE, 1,
1542                 [Kernel has a sb_has_quota_active])
1543         AC_MSG_RESULT([yes])
1544 ],[
1545         AC_MSG_RESULT([no])
1546 ])
1547 ])
1548
1549 # 2.6.27 exported add_to_page_cache_lru.
1550 AC_DEFUN([LC_EXPORT_ADD_TO_PAGE_CACHE_LRU],
1551 [LB_CHECK_SYMBOL_EXPORT([add_to_page_cache_lru],
1552 [mm/filemap.c],[
1553         AC_DEFINE(HAVE_ADD_TO_PAGE_CACHE_LRU, 1,
1554                 [add_to_page_cache_lru functions are present])
1555 ],[
1556 ])
1557 ])
1558
1559 #
1560 # 2.6.29 introduce sb_any_quota_loaded.
1561 #
1562 AC_DEFUN([LC_SB_ANY_QUOTA_LOADED],
1563 [AC_MSG_CHECKING([Kernel has sb_any_quota_loaded])
1564 LB_LINUX_TRY_COMPILE([
1565         #include <linux/quotaops.h>
1566 ],[
1567         sb_any_quota_loaded(NULL);
1568 ],[
1569         AC_DEFINE(HAVE_SB_ANY_QUOTA_LOADED, 1,
1570                 [Kernel has a sb_any_quota_loaded])
1571         AC_MSG_RESULT([yes])
1572 ],[
1573         AC_MSG_RESULT([no])
1574 ])
1575 ])
1576
1577 # 2.6.30 x86 node_to_cpumask has been removed. must use cpumask_of_node
1578 AC_DEFUN([LC_EXPORT_CPUMASK_OF_NODE],
1579          [LB_CHECK_SYMBOL_EXPORT([node_to_cpumask_map],
1580                                  [arch/$LINUX_ARCH/mm/numa.c],
1581                                  [AC_DEFINE(HAVE_CPUMASK_OF_NODE, 1,
1582                                             [node_to_cpumask_map is exported by
1583                                              the kernel])]) # x86_64
1584          ])
1585
1586 # 2.6.31 replaces blk_queue_hardsect_size by blk_queue_logical_block_size function
1587 AC_DEFUN([LC_BLK_QUEUE_LOG_BLK_SIZE],
1588 [AC_MSG_CHECKING([if blk_queue_logical_block_size is defined])
1589 LB_LINUX_TRY_COMPILE([
1590         #include <linux/blkdev.h>
1591 ],[
1592         blk_queue_logical_block_size(NULL, 0);
1593 ],[
1594         AC_MSG_RESULT(yes)
1595         AC_DEFINE(HAVE_BLK_QUEUE_LOG_BLK_SIZE, 1,
1596                   [blk_queue_logical_block_size is defined])
1597 ],[
1598         AC_MSG_RESULT(no)
1599 ])
1600 ])
1601
1602 # 2.6.32
1603
1604 # 2.6.32 changes cache_detail's member cache_request to cache_upcall
1605 # in kernel commit bc74b4f5e63a09fb78e245794a0de1e5a2716bbe
1606 AC_DEFUN([LC_CACHE_UPCALL],
1607 [AC_MSG_CHECKING([if cache_detail has cache_upcall field])
1608         LB_LINUX_TRY_COMPILE([
1609                 #include <linux/sunrpc/cache.h>
1610         ],[
1611                 struct cache_detail cd;
1612                 cd.cache_upcall = NULL;
1613         ],[
1614                 AC_MSG_RESULT(yes)
1615                 AC_DEFINE(HAVE_CACHE_UPCALL, 1,
1616                           [cache_detail has cache_upcall field])
1617         ],[
1618                 AC_MSG_RESULT(no)
1619         ])
1620 ])
1621
1622 # 2.6.32 add a limits member in struct request_queue.
1623 AC_DEFUN([LC_REQUEST_QUEUE_LIMITS],
1624 [AC_MSG_CHECKING([if request_queue has a limits field])
1625 LB_LINUX_TRY_COMPILE([
1626         #include <linux/blkdev.h>
1627 ],[
1628         struct request_queue rq;
1629         rq.limits.io_min = 0;
1630 ],[
1631         AC_MSG_RESULT(yes)
1632         AC_DEFINE(HAVE_REQUEST_QUEUE_LIMITS, 1,
1633                   [request_queue has a limits field])
1634 ],[
1635         AC_MSG_RESULT(no)
1636 ])
1637 ])
1638
1639 # 2.6.32 has bdi_register() functions.
1640 AC_DEFUN([LC_EXPORT_BDI_REGISTER],
1641 [LB_CHECK_SYMBOL_EXPORT([bdi_register],
1642 [mm/backing-dev.c],[
1643         AC_DEFINE(HAVE_BDI_REGISTER, 1,
1644                 [bdi_register function is present])
1645 ],[
1646 ])
1647 ])
1648
1649 # 2.6.32 add s_bdi for super block
1650 AC_DEFUN([LC_SB_BDI],
1651 [AC_MSG_CHECKING([if super_block has s_bdi field])
1652 LB_LINUX_TRY_COMPILE([
1653         #include <linux/fs.h>
1654 ],[
1655         struct super_block sb;
1656         sb.s_bdi = NULL;
1657 ],[
1658         AC_MSG_RESULT(yes)
1659         AC_DEFINE(HAVE_SB_BDI, 1,
1660                   [super_block has s_bdi field])
1661 ],[
1662         AC_MSG_RESULT(no)
1663 ])
1664 ])
1665
1666 #  2.6.27.15-2 SuSE 11 sp0 kernels lack the name field for BDI
1667 AC_DEFUN([LC_BDI_NAME],
1668 [AC_MSG_CHECKING([if backing_device_info has name field])
1669 LB_LINUX_TRY_COMPILE([
1670         #include <linux/blkkdev.h>
1671 ],[
1672         struct backing_dev_info bdi;
1673         bdi.name = NULL;
1674 ],[
1675         AC_MSG_RESULT(yes)
1676         AC_DEFINE(HAVE_BDI_NAME, 1,
1677                   [backing_device_info has name field])
1678 ],[
1679         AC_MSG_RESULT(no)
1680 ])
1681 ])  
1682
1683 # 2.6.32 removes blk_queue_max_sectors and add blk_queue_max_hw_sectors
1684 # check blk_queue_max_sectors and use it until disappear.
1685 AC_DEFUN([LC_BLK_QUEUE_MAX_SECTORS],
1686 [AC_MSG_CHECKING([if blk_queue_max_sectors is defined])
1687 LB_LINUX_TRY_COMPILE([
1688         #include <linux/blkdev.h>
1689 ],[
1690         blk_queue_max_sectors(NULL, 0);
1691 ],[
1692         AC_MSG_RESULT(yes)
1693         AC_DEFINE(HAVE_BLK_QUEUE_MAX_SECTORS, 1,
1694                   [blk_queue_max_sectors is defined])
1695 ],[
1696         AC_MSG_RESULT(no)
1697 ])
1698 ])
1699
1700 # 2.6.32 replaces 2 functions blk_queue_max_phys_segments and blk_queue_max_hw_segments by blk_queue_max_segments
1701 AC_DEFUN([LC_BLK_QUEUE_MAX_SEGMENTS],
1702 [AC_MSG_CHECKING([if blk_queue_max_segments is defined])
1703 LB_LINUX_TRY_COMPILE([
1704         #include <linux/blkdev.h>
1705 ],[
1706         blk_queue_max_segments(NULL, 0);
1707 ],[
1708         AC_MSG_RESULT(yes)
1709         AC_DEFINE(HAVE_BLK_QUEUE_MAX_SEGMENTS, 1,
1710                   [blk_queue_max_segments is defined])
1711 ],[
1712         AC_MSG_RESULT(no)
1713 ])
1714 ])
1715
1716 #
1717 # LC_QUOTA64
1718 #
1719 # Check if kernel has been patched for 64-bit quota limits support.
1720 # The upstream version of this patch in RHEL6 2.6.32 kernels introduces
1721 # the constant QFMT_VFS_V1 in include/linux/quota.h, so we can check for
1722 # that in the absence of quotaio_v1.h in the kernel headers.
1723 #
1724 AC_DEFUN([LC_QUOTA64],[
1725         AC_MSG_CHECKING([if kernel has 64-bit quota limits support])
1726 tmp_flags="$EXTRA_KCFLAGS"
1727 EXTRA_KCFLAGS="-I$LINUX/fs"
1728         LB_LINUX_TRY_COMPILE([
1729                 #include <linux/kernel.h>
1730                 #include <linux/fs.h>
1731                 #ifdef HAVE_QUOTAIO_H
1732                 # include <linux/quotaio_v2.h>
1733                 int versions[] = V2_INITQVERSIONS_R1;
1734                 struct v2_disk_dqblk_r1 dqblk_r1;
1735                 #elif defined(HAVE_FS_QUOTA_QUOTAIO_H)
1736                 # include <quota/quotaio_v2.h>
1737                 struct v2r1_disk_dqblk dqblk_r1;
1738                 #elif defined(HAVE_FS_QUOTAIO_H)
1739                 # include <quotaio_v2.h>
1740                 struct v2r1_disk_dqblk dqblk_r1;
1741                 #else
1742                 #include <linux/quota.h>
1743                 int ver = QFMT_VFS_V1;
1744                 #endif
1745         ],[],[
1746                 AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
1747                 AC_MSG_RESULT([yes])
1748         ],[
1749                 LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
1750                         AC_MSG_ERROR([You have got no 64-bit kernel quota support.])
1751                 ],[])
1752                 AC_MSG_RESULT([no])
1753         ])
1754 EXTRA_KCFLAGS=$tmp_flags
1755 ])
1756
1757 # 2.6.32 set_cpus_allowed is no more defined if CONFIG_CPUMASK_OFFSTACK=yes
1758 AC_DEFUN([LC_SET_CPUS_ALLOWED],
1759          [AC_MSG_CHECKING([if kernel defines set_cpus_allowed])
1760           LB_LINUX_TRY_COMPILE(
1761                 [#include <linux/sched.h>],
1762                 [struct task_struct *p = NULL;
1763                  cpumask_t mask = { { 0 } };
1764                  (void) set_cpus_allowed(p, mask);],
1765                 [AC_MSG_RESULT([yes])
1766                  AC_DEFINE(HAVE_SET_CPUS_ALLOWED, 1,
1767                            [set_cpus_allowed is exported by the kernel])],
1768                 [AC_MSG_RESULT([no])] )])
1769
1770 # 2.6.32 introduces selinux_is_enabled()
1771 AC_DEFUN([LC_SELINUX_IS_ENABLED],
1772 [AC_MSG_CHECKING([if selinux_is_enabled is available])
1773 LB_LINUX_TRY_COMPILE([
1774         #include <linux/selinux.h>
1775 ],[
1776         selinux_is_enabled();
1777 ],[
1778         AC_MSG_RESULT([yes])
1779         AC_DEFINE(HAVE_SELINUX_IS_ENABLED, 1,
1780                 [selinux_is_enabled is defined])
1781 ],[
1782         AC_MSG_RESULT([no])
1783 ])
1784 ])
1785
1786 #
1787 # LC_D_OBTAIN_ALIAS
1788 # starting from 2.6.28 kernel replaces d_alloc_anon() with
1789 # d_obtain_alias() for getting anonymous dentries
1790 # RHEL5(2.6.18) has d_obtain_alias but SLES11SP0(2.6.27) not
1791 #
1792 AC_DEFUN([LC_D_OBTAIN_ALIAS],
1793 [AC_MSG_CHECKING([d_obtain_alias exist in kernel])
1794 LB_LINUX_TRY_COMPILE([
1795         #include <linux/dcache.h>
1796 ],[
1797         d_obtain_alias(NULL);
1798 ],[
1799         AC_DEFINE(HAVE_D_OBTAIN_ALIAS, 1,
1800                 [d_obtain_alias exist in kernel])
1801         AC_MSG_RESULT([yes])
1802 ],[
1803         AC_MSG_RESULT([no])
1804 ])
1805 ])
1806
1807 #
1808 # LC_EXPORT_GENERIC_ERROR_REMOVE_PAGE
1809 #
1810 AC_DEFUN([LC_EXPORT_GENERIC_ERROR_REMOVE_PAGE],
1811          [LB_CHECK_SYMBOL_EXPORT(
1812                         [generic_error_remove_page],
1813                         [mm/truncate.c],
1814                         [AC_DEFINE(HAS_GENERIC_ERROR_REMOVE_PAGE, 1,
1815                                 [kernel export generic_error_remove_page])],
1816                         [])
1817          ]
1818 )
1819
1820 #
1821 # 2.6.36 fs_struct.lock use spinlock instead of rwlock.
1822 #
1823 AC_DEFUN([LC_FS_STRUCT_RWLOCK],
1824 [AC_MSG_CHECKING([if fs_struct.lock use rwlock])
1825 LB_LINUX_TRY_COMPILE([
1826         #include <asm/atomic.h>
1827         #include <linux/spinlock.h>
1828         #include <linux/fs_struct.h>
1829 ],[
1830         ((struct fs_struct *)0)->lock = (rwlock_t){ 0 };
1831 ],[
1832         AC_DEFINE(HAVE_FS_STRUCT_RWLOCK, 1,
1833                   [fs_struct.lock use rwlock])
1834         AC_MSG_RESULT([yes])
1835 ],[
1836         AC_MSG_RESULT([no])
1837 ])
1838 ])
1839
1840 #
1841 # 2.6.36 super_operations add evict_inode method. it hybird of
1842 # delete_inode & clear_inode.
1843 #
1844 AC_DEFUN([LC_SBOPS_EVICT_INODE],
1845 [AC_MSG_CHECKING([if super_operations.evict_inode exist])
1846 LB_LINUX_TRY_COMPILE([
1847         #include <linux/fs.h>
1848 ],[
1849         ((struct super_operations *)0)->evict_inode(NULL);
1850 ],[
1851         AC_DEFINE(HAVE_SBOPS_EVICT_INODE, 1,
1852                 [super_operations.evict_inode() is exist in kernel])
1853         AC_MSG_RESULT([yes])
1854 ],[
1855         AC_MSG_RESULT([no])
1856 ])
1857 ])
1858
1859 #
1860 # 2.6.35 file_operations.fsync taken 2 arguments.
1861 # 3.0.0 file_operations.fsync takes 4 arguments.
1862 #
1863 AC_DEFUN([LC_FILE_FSYNC],
1864 [AC_MSG_CHECKING([if file_operations.fsync takes 4 or 2 arguments])
1865 LB_LINUX_TRY_COMPILE([
1866         #include <linux/fs.h>
1867 ],[
1868         ((struct file_operations *)0)->fsync(NULL, 0, 0, 0);
1869 ],[
1870         AC_DEFINE(HAVE_FILE_FSYNC_4ARGS, 1,
1871                 [file_operations.fsync takes 4 arguments])
1872         AC_MSG_RESULT([yes, 4 args])
1873 ],[
1874         LB_LINUX_TRY_COMPILE([
1875                 #include <linux/fs.h>
1876         ],[
1877            ((struct file_operations *)0)->fsync(NULL, 0);
1878         ],[
1879                 AC_DEFINE(HAVE_FILE_FSYNC_2ARGS, 1,
1880                         [file_operations.fsync takes 2 arguments])
1881                 AC_MSG_RESULT([yes, 2 args])
1882         ],[
1883                 AC_MSG_RESULT([no])
1884         ])
1885 ])
1886 ])
1887
1888 #
1889 # 2.6.38 export blkdev_get_by_dev
1890 #
1891 AC_DEFUN([LC_BLKDEV_GET_BY_DEV],
1892 [LB_CHECK_SYMBOL_EXPORT([blkdev_get_by_dev],
1893 [fs/block_dev.c],[
1894 AC_DEFINE(HAVE_BLKDEV_GET_BY_DEV, 1,
1895             [blkdev_get_by_dev is exported by the kernel])
1896 ],[
1897 ])
1898 ])
1899
1900 #
1901 # 2.6.38 vfsmount.mnt_count doesn't use atomic_t
1902 #
1903 AC_DEFUN([LC_ATOMIC_MNT_COUNT],
1904 [AC_MSG_CHECKING([if vfsmount.mnt_count is atomic_t])
1905 LB_LINUX_TRY_COMPILE([
1906         #include <asm/atomic.h>
1907         #include <linux/fs.h>
1908         #include <linux/mount.h>
1909 ],[
1910         ((struct vfsmount *)0)->mnt_count = ((atomic_t) { 0 });
1911 ],[
1912         AC_DEFINE(HAVE_ATOMIC_MNT_COUNT, 1,
1913                 [vfsmount.mnt_count is atomic_t])
1914         AC_MSG_RESULT([yes])
1915 ],[
1916         AC_MSG_RESULT([no])
1917 ])
1918 ])
1919
1920 #
1921 # 2.6.38 use path as 4th parameter in quota_on.
1922 #
1923 AC_DEFUN([LC_QUOTA_ON_USE_PATH],
1924 [AC_MSG_CHECKING([quota_on use path as parameter])
1925 tmp_flags="$EXTRA_KCFLAGS"
1926 EXTRA_KCFLAGS="-Werror"
1927 LB_LINUX_TRY_COMPILE([
1928         #include <linux/fs.h>
1929         #include <linux/quota.h>
1930 ],[
1931         ((struct quotactl_ops *)0)->quota_on(NULL, 0, 0, ((struct path*)0));
1932 ],[
1933         AC_DEFINE(HAVE_QUOTA_ON_USE_PATH, 1,
1934                 [quota_on use path as 4th paramter])
1935         AC_MSG_RESULT([yes])
1936 ],[
1937         AC_MSG_RESULT([no])
1938 ])
1939 EXTRA_KCFLAGS="$tmp_flags"
1940 ])
1941
1942 #
1943 # 2.6.39 remove unplug_fn from request_queue.
1944 #
1945 AC_DEFUN([LC_REQUEST_QUEUE_UNPLUG_FN],
1946 [AC_MSG_CHECKING([if request_queue has unplug_fn field])
1947 LB_LINUX_TRY_COMPILE([
1948         #include <linux/blkdev.h>
1949 ],[
1950         do{ }while(sizeof(((struct request_queue *)0)->unplug_fn));
1951 ],[
1952         AC_DEFINE(HAVE_REQUEST_QUEUE_UNPLUG_FN, 1,
1953                   [request_queue has unplug_fn field])
1954         AC_MSG_RESULT([yes])
1955 ],[
1956         AC_MSG_RESULT([no])
1957 ])
1958 ])
1959
1960 #
1961 # 2.6.38 generic_permission taken 4 paremater.
1962 # in fact, it means rcu-walk aware permission bring.
1963 #
1964 AC_DEFUN([LC_GENERIC_PERMISSION],
1965 [AC_MSG_CHECKING([if generic_permission take 4 arguments])
1966 LB_LINUX_TRY_COMPILE([
1967         #include <linux/fs.h>
1968 ],[
1969         generic_permission(NULL, 0, 0, NULL);
1970 ],[
1971         AC_DEFINE(HAVE_GENERIC_PERMISSION_4ARGS, 1,
1972                   [generic_permission taken 4 arguments])
1973         AC_MSG_RESULT([yes])
1974 ],[
1975         AC_MSG_RESULT([no])
1976 ])
1977 ])
1978
1979 #
1980 # 2.6.38 export simple_setattr
1981 #
1982 AC_DEFUN([LC_EXPORT_SIMPLE_SETATTR],
1983 [LB_CHECK_SYMBOL_EXPORT([simple_setattr],
1984 [fs/libfs.c],[
1985 AC_DEFINE(HAVE_SIMPLE_SETATTR, 1,
1986             [simple_setattr is exported by the kernel])
1987 ],[
1988 ])
1989 ])
1990
1991 #
1992 # LC_PROG_LINUX
1993 #
1994 # Lustre linux kernel checks
1995 #
1996 AC_DEFUN([LC_PROG_LINUX],
1997          [LC_LUSTRE_VERSION_H
1998          LC_CONFIG_PINGER
1999          LC_CONFIG_CHECKSUM
2000          LC_CONFIG_LIBLUSTRE_RECOVERY
2001          LC_CONFIG_HEALTH_CHECK_WRITE
2002          LC_CONFIG_LRU_RESIZE
2003          LC_QUOTA_MODULE
2004          LC_LLITE_LLOOP_MODULE
2005
2006          # RHEL4 patches
2007          LC_EXPORT_TRUNCATE_COMPLETE
2008          LC_EXPORT_D_REHASH_COND
2009          LC_EXPORT___D_REHASH
2010          LC_EXPORT_NODE_TO_CPUMASK
2011
2012          LC_FILEMAP_POPULATE
2013          LC_BIT_SPINLOCK_H
2014
2015          LC_CONST_ACL_SIZE
2016
2017          LC_CAPA_CRYPTO
2018          LC_CONFIG_RMTCLIENT
2019          LC_CONFIG_GSS
2020          LC_QUOTA_READ
2021          LC_COOKIE_FOLLOW_LINK
2022          LC_FUNC_RCU
2023          LC_PERCPU_COUNTER
2024          LC_TASK_CLENV_STORE
2025
2026          # ~2.6.11
2027          LC_S_TIME_GRAN
2028          LC_SB_TIME_GRAN
2029
2030          # 2.6.12
2031          LC_RW_TREE_LOCK
2032
2033          # 2.6.15
2034          LC_INODE_I_MUTEX
2035
2036          # 2.6.16
2037          LC_SECURITY_PLUG  # for SLES10 SP2
2038
2039          # 2.6.17
2040          LC_INODE_IPRIVATE
2041          LC_DQUOTOFF_MUTEX
2042
2043          # 2.6.18
2044          LC_NR_PAGECACHE
2045          LC_STATFS_DENTRY_PARAM
2046          LC_UMOUNTBEGIN_HAS_VFSMOUNT
2047          LC_FLUSH_OWNER_ID
2048          if test x$enable_server = xyes ; then
2049                 LC_EXPORT_INVALIDATE_MAPPING_PAGES
2050          fi
2051
2052          #2.6.18 + RHEL5 (fc6)
2053          LC_PG_FS_MISC
2054          LC_PAGE_CHECKED
2055          LC_LINUX_FIEMAP_H
2056
2057          # 2.6.19
2058          LC_INODE_BLKSIZE
2059          LC_FILE_WRITEV
2060          LC_FILE_READV
2061
2062          # 2.6.20
2063          LC_CANCEL_DIRTY_PAGE
2064
2065          # raid5-zerocopy patch
2066          LC_PAGE_CONSTANT
2067
2068          # 2.6.22
2069          LC_INVALIDATE_BDEV_2ARG
2070          LC_ASYNC_BLOCK_CIPHER
2071          LC_STRUCT_HASH_DESC
2072          LC_STRUCT_BLKCIPHER_DESC
2073          LC_FS_RENAME_DOES_D_MOVE
2074
2075          # 2.6.23
2076          LC_UNREGISTER_BLKDEV_RETURN_INT
2077          LC_KERNEL_SPLICE_READ
2078          LC_KERNEL_SENDFILE
2079          LC_HAVE_EXPORTFS_H
2080          LC_VM_OP_FAULT
2081          LC_PROCFS_USERS
2082          LC_EXPORTFS_DECODE_FH
2083
2084          # 2.6.24
2085          LC_HAVE_MMTYPES_H
2086          LC_BIO_ENDIO_2ARG
2087          LC_FH_TO_DENTRY
2088          LC_PROCFS_DELETED
2089          LC_EXPORT_BDI_INIT
2090
2091          # 2.6.26
2092          LC_FS_STRUCT_USE_PATH
2093
2094          # 2.6.27
2095          LC_PGMKWRITE_USE_VMFAULT
2096          LC_INODE_PERMISION_2ARGS
2097          LC_FILE_REMOVE_SUID
2098          LC_TRYLOCKPAGE
2099          LC_READ_INODE_IN_SBOPS
2100          LC_EXPORT_INODE_PERMISSION
2101          LC_QUOTA_ON_5ARGS
2102          LC_QUOTA_OFF_3ARGS
2103          LC_VFS_DQ_OFF
2104          LC_LOCK_MAP_ACQUIRE
2105
2106          # 2.6.27.15-2 sles11
2107          LC_BI_HW_SEGMENTS
2108          LC_HAVE_QUOTAIO_H
2109          LC_BDI_NAME
2110          LC_SB_ANY_QUOTA_ACTIVE
2111          LC_SB_HAS_QUOTA_ACTIVE
2112          LC_EXPORT_ADD_TO_PAGE_CACHE_LRU
2113
2114          # 2.6.29
2115          LC_SB_ANY_QUOTA_LOADED
2116
2117          # 2.6.30
2118          LC_EXPORT_CPUMASK_OF_NODE
2119
2120          # 2.6.31
2121          LC_BLK_QUEUE_LOG_BLK_SIZE
2122
2123          # 2.6.32
2124          LC_REQUEST_QUEUE_LIMITS
2125          LC_EXPORT_BDI_REGISTER
2126          LC_SB_BDI
2127          LC_BLK_QUEUE_MAX_SECTORS
2128          LC_BLK_QUEUE_MAX_SEGMENTS
2129          LC_SET_CPUS_ALLOWED
2130          LC_CACHE_UPCALL
2131          LC_EXPORT_GENERIC_ERROR_REMOVE_PAGE
2132          LC_SELINUX_IS_ENABLED
2133
2134          # 2.6.35, 3.0.0
2135          LC_FILE_FSYNC
2136          LC_EXPORT_SIMPLE_SETATTR
2137
2138          # 2.6.36
2139          LC_FS_STRUCT_RWLOCK
2140          LC_SBOPS_EVICT_INODE
2141
2142          # 2.6.38
2143          LC_ATOMIC_MNT_COUNT
2144          LC_BLKDEV_GET_BY_DEV
2145          LC_GENERIC_PERMISSION
2146          LC_QUOTA_ON_USE_PATH
2147
2148          # 2.6.39
2149          LC_REQUEST_QUEUE_UNPLUG_FN
2150
2151          #
2152          if test x$enable_server = xyes ; then
2153              AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
2154              LC_FUNC_DEV_SET_RDONLY
2155              LC_STACK_SIZE
2156              LC_QUOTA64
2157          fi
2158 ])
2159
2160 #
2161 # LC_CONFIG_CLIENT_SERVER
2162 #
2163 # Build client/server sides of Lustre
2164 #
2165 AC_DEFUN([LC_CONFIG_CLIENT_SERVER],
2166 [AC_MSG_CHECKING([whether to build Lustre server support])
2167 AC_ARG_ENABLE([server],
2168         AC_HELP_STRING([--disable-server],
2169                         [disable Lustre server support]),
2170         [],[enable_server='yes'])
2171 AC_MSG_RESULT([$enable_server])
2172
2173 AC_MSG_CHECKING([whether to build Lustre client support])
2174 AC_ARG_ENABLE([client],
2175         AC_HELP_STRING([--disable-client],
2176                         [disable Lustre client support]),
2177         [],[enable_client='yes'])
2178 AC_MSG_RESULT([$enable_client])])
2179
2180 #
2181 # LC_CONFIG_LIBLUSTRE
2182 #
2183 # whether to build liblustre
2184 #
2185 AC_DEFUN([LC_CONFIG_LIBLUSTRE],
2186 [AC_MSG_CHECKING([whether to build Lustre library])
2187 AC_ARG_ENABLE([liblustre],
2188         AC_HELP_STRING([--disable-liblustre],
2189                         [disable building of Lustre library]),
2190         [],[enable_liblustre=$with_sysio])
2191 AC_MSG_RESULT([$enable_liblustre])
2192 # only build sysio if liblustre is built
2193 with_sysio="$enable_liblustre"
2194
2195 AC_MSG_CHECKING([whether to build liblustre tests])
2196 AC_ARG_ENABLE([liblustre-tests],
2197         AC_HELP_STRING([--enable-liblustre-tests],
2198                         [enable liblustre tests, if --disable-tests is used]),
2199         [],[enable_liblustre_tests=$enable_tests])
2200 if test x$enable_liblustre != xyes ; then
2201    enable_liblustre_tests='no'
2202 fi
2203 AC_MSG_RESULT([$enable_liblustre_tests])
2204
2205 AC_MSG_CHECKING([whether to enable liblustre acl])
2206 AC_ARG_ENABLE([liblustre-acl],
2207         AC_HELP_STRING([--disable-liblustre-acl],
2208                         [disable ACL support for liblustre]),
2209         [],[enable_liblustre_acl=yes])
2210 AC_MSG_RESULT([$enable_liblustre_acl])
2211 if test x$enable_liblustre_acl = xyes ; then
2212   AC_DEFINE(LIBLUSTRE_POSIX_ACL, 1, Liblustre Support ACL-enabled MDS)
2213 fi
2214
2215 # 2.6.29 change prepare/commit_write to write_begin/end
2216 AC_DEFUN([LC_WRITE_BEGIN_END],
2217 [AC_MSG_CHECKING([if kernel has .write_begin/end])
2218 LB_LINUX_TRY_COMPILE([
2219         #include <linux/fs.h>
2220         #include <linux/pagemap.h>
2221 #ifdef HAVE_LINUX_MMTYPES_H
2222         #include <linux/mm_types.h>
2223 #endif
2224 ],[
2225         struct address_space_operations aops;
2226         struct page *page;
2227
2228         aops.write_begin = NULL;
2229         aops.write_end = NULL;
2230         page = grab_cache_page_write_begin(NULL, 0, 0);
2231 ], [
2232         AC_MSG_RESULT([yes])
2233         AC_DEFINE(HAVE_KERNEL_WRITE_BEGIN_END, 1,
2234                 [kernel has .write_begin/end])
2235 ],[
2236         AC_MSG_RESULT([no])
2237 ])
2238 ])
2239
2240 # 2.6.29 blkdev_put has 2 arguments
2241 AC_DEFUN([LC_BLKDEV_PUT_2ARGS],
2242 [AC_MSG_CHECKING([blkdev_put needs 2 parameters])
2243 LB_LINUX_TRY_COMPILE([
2244         #include <linux/fs.h>
2245 ],[
2246         blkdev_put(NULL, 0);
2247 ],[
2248         AC_DEFINE(HAVE_BLKDEV_PUT_2ARGS, 1,
2249                 [blkdev_put needs 2 paramters])
2250         AC_MSG_RESULT([yes])
2251 ],[
2252         AC_MSG_RESULT([no])
2253 ])
2254 ])
2255
2256 # 2.6.29 dentry_open has 4 arguments
2257 AC_DEFUN([LC_DENTRY_OPEN_4ARGS],
2258 [AC_MSG_CHECKING([dentry_open needs 4 parameters])
2259 LB_LINUX_TRY_COMPILE([
2260         #include <linux/fs.h>
2261 ],[
2262         dentry_open(NULL, NULL, 0, NULL);
2263 ],[
2264         AC_DEFINE(HAVE_DENTRY_OPEN_4ARGS, 1,
2265                 [dentry_open needs 4 paramters])
2266         AC_MSG_RESULT([yes])
2267 ],[
2268         AC_MSG_RESULT([no])
2269 ])
2270 ])
2271
2272 # 2.6.29 split file and anonymous page queues
2273 AC_DEFUN([LC_PAGEVEC_LRU_ADD_FILE],
2274 [AC_MSG_CHECKING([if kernel has .pagevec_lru_add_file])
2275 LB_LINUX_TRY_COMPILE([
2276         #include <linux/mm.h>
2277         #include <linux/pagevec.h>
2278 ],[
2279         struct pagevec lru_pagevec;
2280
2281         pagevec_init(&lru_pagevec, 0);
2282         pagevec_lru_add_file(&lru_pagevec);
2283 ],[
2284         AC_MSG_RESULT([yes])
2285         AC_DEFINE(HAVE_PAGEVEC_LRU_ADD_FILE, 1,
2286                 [kernel has .pagevec_lru_add_file])
2287 ],[
2288         AC_MSG_RESULT([no])
2289 ])
2290 ])
2291
2292 #
2293 # --enable-mpitest
2294 #
2295 AC_ARG_ENABLE(mpitests,
2296         AC_HELP_STRING([--enable-mpitests=yes|no|mpicc wrapper],
2297                            [include mpi tests]),
2298         [
2299          enable_mpitests=yes
2300          case $enableval in
2301          yes)
2302                 MPICC_WRAPPER=mpicc
2303                 ;;
2304          no)
2305                 enable_mpitests=no
2306                 ;;
2307          *)
2308                 MPICC_WRAPPER=$enableval
2309                  ;;
2310          esac
2311         ],
2312         [
2313         MPICC_WRAPPER=mpicc
2314         enable_mpitests=yes
2315         ]
2316 )
2317
2318 if test x$enable_mpitests != xno; then
2319         AC_MSG_CHECKING([whether mpitests can be built])
2320         oldcc=$CC
2321         CC=$MPICC_WRAPPER
2322         AC_LINK_IFELSE(
2323             [AC_LANG_PROGRAM([[
2324                     #include <mpi.h>
2325                 ]],[[
2326                     int flag;
2327                     MPI_Initialized(&flag);
2328                 ]])],
2329             [
2330                     AC_MSG_RESULT([yes])
2331             ],[
2332                     AC_MSG_RESULT([no])
2333                     enable_mpitests=no
2334         ])
2335         CC=$oldcc
2336 fi
2337 AC_SUBST(MPICC_WRAPPER)
2338
2339 AC_MSG_NOTICE([Enabling Lustre configure options for libsysio])
2340 ac_configure_args="$ac_configure_args --with-lustre-hack --with-sockets"
2341
2342 LC_CONFIG_PINGER
2343 LC_CONFIG_LIBLUSTRE_RECOVERY
2344 ])
2345
2346 #
2347 # LC_CONFIG_QUOTA
2348 #
2349 # whether to enable quota support global control
2350 #
2351 AC_DEFUN([LC_CONFIG_QUOTA],
2352 [AC_ARG_ENABLE([quota],
2353         AC_HELP_STRING([--enable-quota],
2354                         [enable quota support]),
2355         [],[enable_quota='yes'])
2356 ])
2357
2358 AC_DEFUN([LC_QUOTA],
2359 [#check global
2360 LC_CONFIG_QUOTA
2361 #check for utils
2362 AC_CHECK_HEADER(sys/quota.h,
2363                 [AC_DEFINE(HAVE_SYS_QUOTA_H, 1, [Define to 1 if you have <sys/quota.h>.])],
2364                 [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
2365 ])
2366
2367 #
2368 # LC_CONFIG_SPLIT
2369 #
2370 # whether to enable split support
2371 #
2372 AC_DEFUN([LC_CONFIG_SPLIT],
2373 [AC_MSG_CHECKING([whether to enable split support])
2374 AC_ARG_ENABLE([split],
2375         AC_HELP_STRING([--enable-split],
2376                         [enable split support]),
2377         [],[enable_split='no'])
2378 AC_MSG_RESULT([$enable_split])
2379 if test x$enable_split != xno; then
2380    AC_DEFINE(HAVE_SPLIT_SUPPORT, 1, [enable split support])
2381 fi
2382 ])
2383
2384 # RHEL5(2.6.18) has tux_info
2385 AC_DEFUN([LC_TASK_CLENV_TUX_INFO],
2386 [AC_MSG_CHECKING([tux_info])
2387 LB_LINUX_TRY_COMPILE([
2388         #include <linux/sched.h>
2389 ],[
2390         struct task_struct task;
2391         &task.tux_info;
2392 ],[
2393         AC_MSG_RESULT([yes])
2394         AC_DEFINE(LL_TASK_CL_ENV, tux_info, [have tux_info])
2395         have_task_clenv_store='yes'
2396 ],[
2397         AC_MSG_RESULT([no])
2398 ])
2399 ])
2400
2401 #
2402 # LC_LLITE_LLOOP_MODULE
2403 # lloop_llite.ko does not currently work with page sizes
2404 # of 64k or larger.
2405 #
2406 AC_DEFUN([LC_LLITE_LLOOP_MODULE],
2407 [AC_MSG_CHECKING([whether to enable llite_lloop module])
2408 LB_LINUX_TRY_COMPILE([
2409         #include <asm/page.h>
2410 ],[
2411         #if PAGE_SIZE >= 65536
2412         #error "PAGE_SIZE >= 65536"
2413         #endif
2414 ],[
2415         enable_llite_lloop_module='yes'
2416         AC_MSG_RESULT([yes])
2417 ],[
2418         enable_llite_lloop_module='no'
2419         AC_MSG_RESULT([no])
2420 ])
2421 ])
2422
2423 #
2424 # LC_CONFIGURE
2425 #
2426 # other configure checks
2427 #
2428 AC_DEFUN([LC_CONFIGURE],
2429 [LC_CONFIG_OBD_BUFFER_SIZE
2430
2431 if test $target_cpu == "i686" -o $target_cpu == "x86_64"; then
2432         CFLAGS="$CFLAGS -Werror"
2433 fi
2434
2435 # maximum MDS thread count
2436 LC_MDS_MAX_THREADS
2437
2438 # include/liblustre.h
2439 AC_CHECK_HEADERS([sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
2440
2441 # liblustre/llite_lib.h
2442 AC_CHECK_HEADERS([xtio.h file.h])
2443
2444 # liblustre/dir.c
2445 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
2446
2447 # liblustre/lutil.c
2448 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h catamount/data.h])
2449 AC_CHECK_FUNCS([inet_ntoa])
2450
2451 # libsysio/src/readlink.c
2452 LC_READLINK_SSIZE_T
2453
2454 # lvfs/prng.c - depends on linux/types.h from liblustre/dir.c
2455 AC_CHECK_HEADERS([linux/random.h], [], [],
2456                  [#ifdef HAVE_LINUX_TYPES_H
2457                   # include <linux/types.h>
2458                   #endif
2459                  ])
2460
2461 # utils/llverfs.c
2462 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
2463
2464 # check for -lz support
2465 ZLIB=""
2466 AC_CHECK_LIB([z],
2467              [adler32],
2468              [AC_CHECK_HEADERS([zlib.h],
2469                                [ZLIB="-lz"
2470                                 AC_DEFINE([HAVE_ADLER], 1,
2471                                           [support alder32 checksum type])],
2472                                [AC_MSG_WARN([No zlib-devel package found,
2473                                              unable to use adler32 checksum])])],
2474              [AC_MSG_WARN([No zlib package found, unable to use adler32 checksum])]
2475 )
2476 AC_SUBST(ZLIB)
2477
2478 # Super safe df
2479 AC_ARG_ENABLE([mindf],
2480       AC_HELP_STRING([--enable-mindf],
2481                       [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
2482       [],[])
2483 if test "$enable_mindf" = "yes" ;  then
2484       AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])
2485 fi
2486
2487 AC_ARG_ENABLE([fail_alloc],
2488         AC_HELP_STRING([--disable-fail-alloc],
2489                 [disable randomly alloc failure]),
2490         [],[enable_fail_alloc=yes])
2491 AC_MSG_CHECKING([whether to randomly failing memory alloc])
2492 AC_MSG_RESULT([$enable_fail_alloc])
2493 if test x$enable_fail_alloc != xno ; then
2494         AC_DEFINE([RANDOM_FAIL_ALLOC], 1, [enable randomly alloc failure])
2495 fi
2496
2497 AC_ARG_ENABLE([invariants],
2498         AC_HELP_STRING([--enable-invariants],
2499                 [enable invariant checking (cpu intensive)]),
2500         [],[])
2501 AC_MSG_CHECKING([whether to check invariants (expensive cpu-wise)])
2502 AC_MSG_RESULT([$enable_invariants])
2503 if test x$enable_invariants = xyes ; then
2504         AC_DEFINE([INVARIANT_CHECK], 1, [enable invariant checking])
2505 fi
2506
2507 AC_ARG_ENABLE([lu_ref],
2508         AC_HELP_STRING([--enable-lu_ref],
2509                 [enable lu_ref reference tracking code]),
2510         [],[])
2511 AC_MSG_CHECKING([whether to track references with lu_ref])
2512 AC_MSG_RESULT([$enable_lu_ref])
2513 if test x$enable_lu_ref = xyes ; then
2514         AC_DEFINE([USE_LU_REF], 1, [enable lu_ref reference tracking code])
2515 fi
2516
2517 AC_ARG_ENABLE([pgstate-track],
2518               AC_HELP_STRING([--enable-pgstate-track],
2519                              [enable page state tracking]),
2520               [enable_pgstat_track='yes'],[])
2521 AC_MSG_CHECKING([whether to enable page state tracking])
2522 AC_MSG_RESULT([$enable_pgstat_track])
2523 if test x$enable_pgstat_track = xyes ; then
2524         AC_DEFINE([LUSTRE_PAGESTATE_TRACKING], 1,
2525                   [enable page state tracking code])
2526 fi
2527
2528          #2.6.29
2529          LC_WRITE_BEGIN_END
2530          LC_D_OBTAIN_ALIAS
2531          LC_BLKDEV_PUT_2ARGS
2532          LC_DENTRY_OPEN_4ARGS
2533          LC_PAGEVEC_LRU_ADD_FILE
2534
2535 ])
2536
2537 #
2538 # LC_CONDITIONALS
2539 #
2540 # AM_CONDITIONALS for lustre
2541 #
2542 AC_DEFUN([LC_CONDITIONALS],
2543 [AM_CONDITIONAL(LIBLUSTRE, test x$enable_liblustre = xyes)
2544 AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
2545 AM_CONDITIONAL(LIBLUSTRE_TESTS, test x$enable_liblustre_tests = xyes)
2546 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
2547 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
2548 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
2549 AM_CONDITIONAL(QUOTA, test x$enable_quota_module = xyes)
2550 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
2551 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
2552 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
2553 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
2554 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
2555 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
2556 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
2557 AM_CONDITIONAL(LLITE_LLOOP, test x$enable_llite_lloop_module = xyes)
2558 ])
2559
2560 #
2561 # LC_CONFIG_FILES
2562 #
2563 # files that should be generated with AC_OUTPUT
2564 #
2565 AC_DEFUN([LC_CONFIG_FILES],
2566 [AC_CONFIG_FILES([
2567 lustre/Makefile
2568 lustre/autoMakefile
2569 lustre/autoconf/Makefile
2570 lustre/conf/Makefile
2571 lustre/contrib/Makefile
2572 lustre/doc/Makefile
2573 lustre/include/Makefile
2574 lustre/include/lustre_ver.h
2575 lustre/include/linux/Makefile
2576 lustre/include/darwin/Makefile
2577 lustre/include/lustre/Makefile
2578 lustre/kernel_patches/targets/2.6-rhel6.target
2579 lustre/kernel_patches/targets/2.6-rhel5.target
2580 lustre/kernel_patches/targets/2.6-sles10.target
2581 lustre/kernel_patches/targets/2.6-sles11.target
2582 lustre/kernel_patches/targets/2.6-oel5.target
2583 lustre/kernel_patches/targets/2.6-fc11.target
2584 lustre/kernel_patches/targets/2.6-fc12.target
2585 lustre/ldlm/Makefile
2586 lustre/fid/Makefile
2587 lustre/fid/autoMakefile
2588 lustre/liblustre/Makefile
2589 lustre/liblustre/tests/Makefile
2590 lustre/liblustre/tests/mpi/Makefile
2591 lustre/llite/Makefile
2592 lustre/llite/autoMakefile
2593 lustre/lclient/Makefile
2594 lustre/lov/Makefile
2595 lustre/lov/autoMakefile
2596 lustre/lvfs/Makefile
2597 lustre/lvfs/autoMakefile
2598 lustre/mdc/Makefile
2599 lustre/mdc/autoMakefile
2600 lustre/lmv/Makefile
2601 lustre/lmv/autoMakefile
2602 lustre/mds/Makefile
2603 lustre/mds/autoMakefile
2604 lustre/mdt/Makefile
2605 lustre/mdt/autoMakefile
2606 lustre/cmm/Makefile
2607 lustre/cmm/autoMakefile
2608 lustre/mdd/Makefile
2609 lustre/mdd/autoMakefile
2610 lustre/fld/Makefile
2611 lustre/fld/autoMakefile
2612 lustre/obdclass/Makefile
2613 lustre/obdclass/autoMakefile
2614 lustre/obdclass/linux/Makefile
2615 lustre/obdecho/Makefile
2616 lustre/obdecho/autoMakefile
2617 lustre/obdfilter/Makefile
2618 lustre/obdfilter/autoMakefile
2619 lustre/osc/Makefile
2620 lustre/osc/autoMakefile
2621 lustre/ost/Makefile
2622 lustre/ost/autoMakefile
2623 lustre/osd-ldiskfs/Makefile
2624 lustre/osd-ldiskfs/autoMakefile
2625 lustre/mgc/Makefile
2626 lustre/mgc/autoMakefile
2627 lustre/mgs/Makefile
2628 lustre/mgs/autoMakefile
2629 lustre/ptlrpc/Makefile
2630 lustre/ptlrpc/autoMakefile
2631 lustre/ptlrpc/gss/Makefile
2632 lustre/ptlrpc/gss/autoMakefile
2633 lustre/quota/Makefile
2634 lustre/quota/autoMakefile
2635 lustre/scripts/Makefile
2636 lustre/tests/Makefile
2637 lustre/tests/mpi/Makefile
2638 lustre/utils/Makefile
2639 lustre/utils/gss/Makefile
2640 lustre/obdclass/darwin/Makefile
2641 ])
2642 ])