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