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