Whamcloud - gitweb
LU-249 Allow the user to set the upper limit to the thread count on the MDS
[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.31
1976
1977 # 2.6.31 replaces blk_queue_hardsect_size by blk_queue_logical_block_size function
1978 AC_DEFUN([LC_BLK_QUEUE_LOG_BLK_SIZE],
1979 [AC_MSG_CHECKING([if blk_queue_logical_block_size is defined])
1980 LB_LINUX_TRY_COMPILE([
1981         #include <linux/blkdev.h>
1982 ],[
1983         blk_queue_logical_block_size(NULL, 0);
1984 ],[
1985         AC_MSG_RESULT(yes)
1986         AC_DEFINE(HAVE_BLK_QUEUE_LOG_BLK_SIZE, 1,
1987                   [blk_queue_logical_block_size is defined])
1988 ],[
1989         AC_MSG_RESULT(no)
1990 ])
1991 ])
1992
1993 # 2.6.32
1994
1995 # 2.6.32 add a limits member in struct request_queue.
1996 AC_DEFUN([LC_REQUEST_QUEUE_LIMITS],
1997 [AC_MSG_CHECKING([if request_queue has a limits field])
1998 LB_LINUX_TRY_COMPILE([
1999         #include <linux/blkdev.h>
2000 ],[
2001         struct request_queue rq;
2002         rq.limits.io_min = 0;
2003 ],[
2004         AC_MSG_RESULT(yes)
2005         AC_DEFINE(HAVE_REQUEST_QUEUE_LIMITS, 1,
2006                   [request_queue has a limits field])
2007 ],[
2008         AC_MSG_RESULT(no)
2009 ])
2010 ])
2011
2012 # 2.6.32 has bdi_register() functions.
2013 AC_DEFUN([LC_EXPORT_BDI_REGISTER],
2014 [LB_CHECK_SYMBOL_EXPORT([bdi_register],
2015 [mm/backing-dev.c],[
2016         AC_DEFINE(HAVE_BDI_REGISTER, 1,
2017                 [bdi_register function is present])
2018 ],[
2019 ])
2020 ])
2021
2022 # 2.6.32 add s_bdi for super block
2023 AC_DEFUN([LC_SB_BDI],
2024 [AC_MSG_CHECKING([if super_block has s_bdi field])
2025 LB_LINUX_TRY_COMPILE([
2026         #include <linux/fs.h>
2027 ],[
2028         struct super_block sb;
2029         sb.s_bdi = NULL;
2030 ],[
2031         AC_MSG_RESULT(yes)
2032         AC_DEFINE(HAVE_SB_BDI, 1,
2033                   [super_block has s_bdi field])
2034 ],[
2035         AC_MSG_RESULT(no)
2036 ])
2037 ])
2038
2039 # 2.6.32 removes blk_queue_max_sectors and add blk_queue_max_hw_sectors
2040 # check blk_queue_max_sectors and use it until disappear.
2041 AC_DEFUN([LC_BLK_QUEUE_MAX_SECTORS],
2042 [AC_MSG_CHECKING([if blk_queue_max_sectors is defined])
2043 LB_LINUX_TRY_COMPILE([
2044         #include <linux/blkdev.h>
2045 ],[
2046         blk_queue_max_sectors(NULL, 0);
2047 ],[
2048         AC_MSG_RESULT(yes)
2049         AC_DEFINE(HAVE_BLK_QUEUE_MAX_SECTORS, 1,
2050                   [blk_queue_max_sectors is defined])
2051 ],[
2052         AC_MSG_RESULT(no)
2053 ])
2054 ])
2055
2056 # 2.6.32 replaces 2 functions blk_queue_max_phys_segments and blk_queue_max_hw_segments by blk_queue_max_segments
2057 AC_DEFUN([LC_BLK_QUEUE_MAX_SEGMENTS],
2058 [AC_MSG_CHECKING([if blk_queue_max_segments is defined])
2059 LB_LINUX_TRY_COMPILE([
2060         #include <linux/blkdev.h>
2061 ],[
2062         blk_queue_max_segments(NULL, 0);
2063 ],[
2064         AC_MSG_RESULT(yes)
2065         AC_DEFINE(HAVE_BLK_QUEUE_MAX_SEGMENTS, 1,
2066                   [blk_queue_max_segments is defined])
2067 ],[
2068         AC_MSG_RESULT(no)
2069 ])
2070 ])
2071
2072 #
2073 # LC_EXT4_SINGLEDATA_TRANS_BLOCKS_SB
2074 #
2075 AC_DEFUN([LC_EXT4_SINGLEDATA_TRANS_BLOCKS_SB],
2076 [AC_MSG_CHECKING([if EXT4_SINGLEDATA_TRANS_BLOCKS takes the sb as argument])
2077 tmp_flags="$EXTRA_KCFLAGS"
2078 EXTRA_KCFLAGS="-I$LINUX/fs"
2079 LB_LINUX_TRY_COMPILE([
2080         #include <ext4/ext4.h>
2081         #include <ext4/ext4_jbd2.h>
2082 ],[
2083         struct super_block sb;
2084         EXT4_SINGLEDATA_TRANS_BLOCKS(&sb);
2085 ],[
2086         AC_MSG_RESULT(yes)
2087         AC_DEFINE(LDISKFS_SINGLEDATA_TRANS_BLOCKS_HAS_SB, 1,
2088                   [EXT4_SINGLEDATA_TRANS_BLOCKS takes sb as argument])
2089 ],[
2090         AC_MSG_RESULT(no)
2091 ])
2092 EXTRA_KCFLAGS="$tmp_flags"
2093 ])
2094
2095 #
2096 # LC_WALK_SPACE_HAS_DATA_SEM
2097 #
2098 # 2.6.32 ext4_ext_walk_space() takes i_data_sem internally.
2099 #
2100 AC_DEFUN([LC_WALK_SPACE_HAS_DATA_SEM],
2101 [AC_MSG_CHECKING([if ext4_ext_walk_space() takes i_data_sem])
2102 WALK_SPACE_DATA_SEM="$(awk 'BEGIN { in_walk_space = 0 }                                 \
2103                             /^int ext4_ext_walk_space\(/ { in_walk_space = 1 }          \
2104                             /^}/ { if (in_walk_space) in_walk_space = 0 }               \
2105                             /i_data_sem/ { if (in_walk_space) { print("yes"); exit } }' \
2106                        $LINUX/fs/ext4/extents.c)"
2107 if test x"$WALK_SPACE_DATA_SEM" == xyes ; then
2108        AC_DEFINE(WALK_SPACE_HAS_DATA_SEM, 1,
2109                  [ext4_ext_walk_space takes i_data_sem])
2110        AC_MSG_RESULT([yes])
2111 else
2112        AC_MSG_RESULT([no])
2113 fi
2114 ])
2115
2116 #
2117 # LC_QUOTA64
2118 #
2119 # Check if kernel has been patched for 64-bit quota limits support.
2120 # The upstream version of this patch in RHEL6 2.6.32 kernels introduces
2121 # the constant QFMT_VFS_V1 in include/linux/quota.h, so we can check for
2122 # that in the absence of quotaio_v1.h in the kernel headers.
2123 #
2124 AC_DEFUN([LC_QUOTA64],[
2125         AC_MSG_CHECKING([if kernel has 64-bit quota limits support])
2126 tmp_flags="$EXTRA_KCFLAGS"
2127 EXTRA_KCFLAGS="-I$LINUX/fs"
2128         LB_LINUX_TRY_COMPILE([
2129                 #include <linux/kernel.h>
2130                 #include <linux/fs.h>
2131                 #ifdef HAVE_QUOTAIO_H
2132                 # include <linux/quotaio_v2.h>
2133                 int versions[] = V2_INITQVERSIONS_R1;
2134                 struct v2_disk_dqblk_r1 dqblk_r1;
2135                 #elif defined(HAVE_FS_QUOTA_QUOTAIO_H)
2136                 # include <quota/quotaio_v2.h>
2137                 struct v2r1_disk_dqblk dqblk_r1;
2138                 #elif defined(HAVE_FS_QUOTAIO_H)
2139                 # include <quotaio_v2.h>
2140                 struct v2r1_disk_dqblk dqblk_r1;
2141                 #else
2142                 #include <linux/quota.h>
2143                 int ver = QFMT_VFS_V1;
2144                 #endif
2145         ],[],[
2146                 AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
2147                 AC_MSG_RESULT([yes])
2148         ],[
2149                 LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
2150                         AC_MSG_ERROR([You have got no 64-bit kernel quota support.])
2151                 ],[])
2152                 AC_MSG_RESULT([no])
2153         ])
2154 EXTRA_KCFLAGS=$tmp_flags
2155 ])
2156
2157 #
2158 # LC_D_OBTAIN_ALIAS
2159 # starting from 2.6.28 kernel replaces d_alloc_anon() with
2160 # d_obtain_alias() for getting anonymous dentries
2161 #
2162 AC_DEFUN([LC_D_OBTAIN_ALIAS],
2163 [AC_MSG_CHECKING([d_obtain_alias exist in kernel])
2164 LB_LINUX_TRY_COMPILE([
2165         #include <linux/dcache.h>
2166 ],[
2167         d_obtain_alias(NULL);
2168 ],[
2169         AC_DEFINE(HAVE_D_OBTAIN_ALIAS, 1,
2170                 [d_obtain_alias exist in kernel])
2171         AC_MSG_RESULT([yes])
2172 ],[
2173         AC_MSG_RESULT([no])
2174 ])
2175 ])
2176
2177
2178 #
2179 # LC_PROG_LINUX
2180 #
2181 # Lustre linux kernel checks
2182 #
2183 AC_DEFUN([LC_PROG_LINUX],
2184          [LC_LUSTRE_VERSION_H
2185          LC_CONFIG_PINGER
2186          LC_CONFIG_CHECKSUM
2187          LC_CONFIG_LIBLUSTRE_RECOVERY
2188          LC_CONFIG_HEALTH_CHECK_WRITE
2189          LC_CONFIG_LRU_RESIZE
2190          LC_QUOTA_MODULE
2191          LC_LLITE_LLOOP_MODULE
2192
2193          # RHEL4 patches
2194          LC_EXPORT_TRUNCATE_COMPLETE
2195          LC_EXPORT_TRUNCATE_RANGE
2196          LC_EXPORT_D_REHASH_COND
2197          LC_EXPORT___D_REHASH
2198          LC_EXPORT_NODE_TO_CPUMASK
2199
2200          LC_HEADER_LDISKFS_XATTR
2201          LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
2202          LC_STRUCT_STATFS
2203          LC_FILEMAP_POPULATE
2204          LC_D_ADD_UNIQUE
2205          LC_BIT_SPINLOCK_H
2206
2207          LC_XATTR_ACL
2208          LC_POSIX_ACL_XATTR_H
2209          LC_CONST_ACL_SIZE
2210
2211          LC_STRUCT_INTENT_FILE
2212
2213          LC_CAPA_CRYPTO
2214          LC_CONFIG_RMTCLIENT
2215          LC_CONFIG_GSS
2216          LC_FUNC_HAVE_CAN_SLEEP_ARG
2217          LC_FUNC_F_OP_FLOCK
2218          LC_QUOTA_READ
2219          LC_COOKIE_FOLLOW_LINK
2220          LC_FUNC_RCU
2221          LC_PERCPU_COUNTER
2222          LC_TASK_CLENV_STORE
2223
2224          # ~2.6.11
2225          LC_S_TIME_GRAN
2226          LC_SB_TIME_GRAN
2227
2228          # 2.6.12
2229          LC_RW_TREE_LOCK
2230          LC_EXPORT_SYNCHRONIZE_RCU
2231
2232          # 2.6.15
2233          LC_INODE_I_MUTEX
2234
2235          # 2.6.16
2236          LC_SECURITY_PLUG  # for SLES10 SP2
2237
2238          # 2.6.17
2239          LC_INODE_IPRIVATE
2240          LC_DQUOTOFF_MUTEX
2241
2242          # 2.6.18
2243          LC_NR_PAGECACHE
2244          LC_STATFS_DENTRY_PARAM
2245          LC_VFS_KERN_MOUNT
2246          LC_INVALIDATEPAGE_RETURN_INT
2247          LC_UMOUNTBEGIN_HAS_VFSMOUNT
2248          LC_SEQ_LOCK
2249          LC_EXPORT_FILEMAP_FDATAWRITE_RANGE
2250          LC_FLUSH_OWNER_ID
2251          if test x$enable_server = xyes ; then
2252                 LC_EXPORT_INVALIDATE_MAPPING_PAGES
2253          fi
2254          LC_EXT4_DISCARD_PREALLOCATIONS
2255          LC_EXT_INSERT_EXTENT_WITH_5ARGS
2256
2257          #2.6.18 + RHEL5 (fc6)
2258          LC_PG_FS_MISC
2259          LC_PAGE_CHECKED
2260          LC_LINUX_FIEMAP_H
2261
2262          # 2.6.19
2263          LC_INODE_BLKSIZE
2264          LC_VFS_READDIR_U64_INO
2265          LC_FILE_WRITEV
2266          LC_FILE_READV
2267
2268          # 2.6.20
2269          LC_CANCEL_DIRTY_PAGE
2270
2271          # raid5-zerocopy patch
2272          LC_PAGE_CONSTANT
2273
2274          # 2.6.22
2275          LC_INVALIDATE_BDEV_2ARG
2276          LC_ASYNC_BLOCK_CIPHER
2277          LC_STRUCT_HASH_DESC
2278          LC_STRUCT_BLKCIPHER_DESC
2279          LC_FS_RENAME_DOES_D_MOVE
2280
2281          # 2.6.23
2282          LC_UNREGISTER_BLKDEV_RETURN_INT
2283          LC_KERNEL_SPLICE_READ
2284          LC_KERNEL_SENDFILE
2285          LC_HAVE_EXPORTFS_H
2286          LC_VM_OP_FAULT
2287          LC_PROCFS_USERS
2288          LC_EXPORTFS_DECODE_FH
2289   
2290          # 2.6.24
2291          LC_HAVE_MMTYPES_H
2292          LC_BIO_ENDIO_2ARG
2293          LC_FH_TO_DENTRY
2294          LC_PROCFS_DELETED
2295          LC_EXPORT_BDI_INIT
2296
2297          #2.6.25
2298          LC_MAPPING_CAP_WRITEBACK_DIRTY
2299   
2300          # 2.6.26
2301          LC_FS_STRUCT_USE_PATH
2302
2303          # 2.6.27
2304          LC_INODE_PERMISION_2ARGS
2305          LC_FILE_REMOVE_SUID
2306          LC_TRYLOCKPAGE
2307          LC_READ_INODE_IN_SBOPS
2308          LC_EXPORT_INODE_PERMISSION
2309          LC_QUOTA_ON_5ARGS
2310          LC_QUOTA_OFF_3ARGS
2311          LC_VFS_DQ_OFF
2312          LC_LOCK_MAP_ACQUIRE
2313
2314          # 2.6.27.15-2 sles11
2315          LC_BI_HW_SEGMENTS
2316          LC_HAVE_QUOTAIO_H
2317          LC_VFS_SYMLINK_5ARGS
2318          LC_SB_ANY_QUOTA_ACTIVE
2319          LC_SB_HAS_QUOTA_ACTIVE
2320
2321          # 2.6.31
2322          LC_BLK_QUEUE_LOG_BLK_SIZE
2323
2324          # 2.6.32
2325          LC_REQUEST_QUEUE_LIMITS
2326          LC_EXPORT_BDI_REGISTER
2327          LC_SB_BDI
2328          LC_BLK_QUEUE_MAX_SECTORS
2329          LC_BLK_QUEUE_MAX_SEGMENTS
2330          LC_EXT4_SINGLEDATA_TRANS_BLOCKS_SB
2331          LC_WALK_SPACE_HAS_DATA_SEM
2332
2333          #
2334          if test x$enable_server = xyes ; then
2335              AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
2336              LC_FUNC_DEV_SET_RDONLY
2337              LC_STACK_SIZE
2338              LC_CONFIG_BACKINGFS
2339              LC_QUOTA64
2340          fi
2341 ])
2342
2343 #
2344 # LC_CONFIG_CLIENT_SERVER
2345 #
2346 # Build client/server sides of Lustre
2347 #
2348 AC_DEFUN([LC_CONFIG_CLIENT_SERVER],
2349 [AC_MSG_CHECKING([whether to build Lustre server support])
2350 AC_ARG_ENABLE([server],
2351         AC_HELP_STRING([--disable-server],
2352                         [disable Lustre server support]),
2353         [],[enable_server='yes'])
2354 AC_MSG_RESULT([$enable_server])
2355
2356 AC_MSG_CHECKING([whether to build Lustre client support])
2357 AC_ARG_ENABLE([client],
2358         AC_HELP_STRING([--disable-client],
2359                         [disable Lustre client support]),
2360         [],[enable_client='yes'])
2361 AC_MSG_RESULT([$enable_client])])
2362
2363 #
2364 # LC_CONFIG_LIBLUSTRE
2365 #
2366 # whether to build liblustre
2367 #
2368 AC_DEFUN([LC_CONFIG_LIBLUSTRE],
2369 [AC_MSG_CHECKING([whether to build Lustre library])
2370 AC_ARG_ENABLE([liblustre],
2371         AC_HELP_STRING([--disable-liblustre],
2372                         [disable building of Lustre library]),
2373         [],[enable_liblustre=$with_sysio])
2374 AC_MSG_RESULT([$enable_liblustre])
2375 # only build sysio if liblustre is built
2376 with_sysio="$enable_liblustre"
2377
2378 AC_MSG_CHECKING([whether to build liblustre tests])
2379 AC_ARG_ENABLE([liblustre-tests],
2380         AC_HELP_STRING([--enable-liblustre-tests],
2381                         [enable liblustre tests, if --disable-tests is used]),
2382         [],[enable_liblustre_tests=$enable_tests])
2383 if test x$enable_liblustre != xyes ; then
2384    enable_liblustre_tests='no'
2385 fi
2386 AC_MSG_RESULT([$enable_liblustre_tests])
2387
2388 AC_MSG_CHECKING([whether to enable liblustre acl])
2389 AC_ARG_ENABLE([liblustre-acl],
2390         AC_HELP_STRING([--disable-liblustre-acl],
2391                         [disable ACL support for liblustre]),
2392         [],[enable_liblustre_acl=yes])
2393 AC_MSG_RESULT([$enable_liblustre_acl])
2394 if test x$enable_liblustre_acl = xyes ; then
2395   AC_DEFINE(LIBLUSTRE_POSIX_ACL, 1, Liblustre Support ACL-enabled MDS)
2396 fi
2397
2398 # 2.6.29 change prepare/commit_write to write_begin/end
2399 AC_DEFUN([LC_WRITE_BEGIN_END],
2400 [AC_MSG_CHECKING([if kernel has .write_begin/end])
2401 LB_LINUX_TRY_COMPILE([
2402         #include <linux/fs.h>
2403         #include <linux/pagemap.h>
2404 #ifdef HAVE_LINUX_MMTYPES_H
2405         #include <linux/mm_types.h>
2406 #endif
2407 ],[
2408         struct address_space_operations aops;
2409         struct page *page;
2410
2411         aops.write_begin = NULL;
2412         aops.write_end = NULL;
2413         page = grab_cache_page_write_begin(NULL, 0, 0);
2414 ], [
2415         AC_MSG_RESULT([yes])
2416         AC_DEFINE(HAVE_KERNEL_WRITE_BEGIN_END, 1,
2417                 [kernel has .write_begin/end])
2418 ],[
2419         AC_MSG_RESULT([no])
2420 ])
2421 ])
2422
2423 # 2.6.29 blkdev_put has 2 arguments
2424 AC_DEFUN([LC_BLKDEV_PUT_2ARGS],
2425 [AC_MSG_CHECKING([blkdev_put needs 2 parameters])
2426 LB_LINUX_TRY_COMPILE([
2427         #include <linux/fs.h>
2428 ],[
2429         blkdev_put(NULL, 0);
2430 ],[
2431         AC_DEFINE(HAVE_BLKDEV_PUT_2ARGS, 1,
2432                 [blkdev_put needs 2 paramters])
2433         AC_MSG_RESULT([yes])
2434 ],[
2435         AC_MSG_RESULT([no])
2436 ])
2437 ])
2438
2439 # 2.6.29 dentry_open has 4 arguments
2440 AC_DEFUN([LC_DENTRY_OPEN_4ARGS],
2441 [AC_MSG_CHECKING([dentry_open needs 4 parameters])
2442 LB_LINUX_TRY_COMPILE([
2443         #include <linux/fs.h>
2444 ],[
2445         dentry_open(NULL, NULL, 0, NULL);
2446 ],[
2447         AC_DEFINE(HAVE_DENTRY_OPEN_4ARGS, 1,
2448                 [dentry_open needs 4 paramters])
2449         AC_MSG_RESULT([yes])
2450 ],[
2451         AC_MSG_RESULT([no])
2452 ])
2453 ])
2454
2455 #
2456 # --enable-mpitest
2457 #
2458 AC_ARG_ENABLE(mpitests,
2459         AC_HELP_STRING([--enable-mpitests=yes|no|mpicc wrapper],
2460                            [include mpi tests]),
2461         [
2462          enable_mpitests=yes
2463          case $enableval in
2464          yes)
2465                 MPICC_WRAPPER=mpicc
2466                 ;;
2467          no)
2468                 enable_mpitests=no
2469                 ;;
2470          *)
2471                 MPICC_WRAPPER=$enableval
2472                  ;;
2473          esac
2474         ],
2475         [
2476         MPICC_WRAPPER=mpicc
2477         enable_mpitests=yes
2478         ]
2479 )
2480
2481 if test x$enable_mpitests != xno; then
2482         AC_MSG_CHECKING([whether mpitests can be built])
2483         oldcc=$CC
2484         CC=$MPICC_WRAPPER
2485         AC_LINK_IFELSE(
2486             [AC_LANG_PROGRAM([[
2487                     #include <mpi.h>
2488                 ]],[[
2489                     int flag;
2490                     MPI_Initialized(&flag);
2491                 ]])],
2492             [
2493                     AC_MSG_RESULT([yes])
2494             ],[
2495                     AC_MSG_RESULT([no])
2496                     enable_mpitests=no
2497         ])
2498         CC=$oldcc
2499 fi
2500 AC_SUBST(MPICC_WRAPPER)
2501
2502 AC_MSG_NOTICE([Enabling Lustre configure options for libsysio])
2503 ac_configure_args="$ac_configure_args --with-lustre-hack --with-sockets"
2504
2505 LC_CONFIG_PINGER
2506 LC_CONFIG_LIBLUSTRE_RECOVERY
2507 ])
2508
2509 #
2510 # LC_CONFIG_QUOTA
2511 #
2512 # whether to enable quota support global control
2513 #
2514 AC_DEFUN([LC_CONFIG_QUOTA],
2515 [AC_ARG_ENABLE([quota],
2516         AC_HELP_STRING([--enable-quota],
2517                         [enable quota support]),
2518         [],[enable_quota='yes'])
2519 ])
2520
2521 AC_DEFUN([LC_QUOTA],
2522 [#check global
2523 LC_CONFIG_QUOTA
2524 #check for utils
2525 AC_CHECK_HEADER(sys/quota.h,
2526                 [AC_DEFINE(HAVE_SYS_QUOTA_H, 1, [Define to 1 if you have <sys/quota.h>.])],
2527                 [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
2528 ])
2529
2530 #
2531 # LC_CONFIG_SPLIT
2532 #
2533 # whether to enable split support
2534 #
2535 AC_DEFUN([LC_CONFIG_SPLIT],
2536 [AC_MSG_CHECKING([whether to enable split support])
2537 AC_ARG_ENABLE([split],
2538         AC_HELP_STRING([--enable-split],
2539                         [enable split support]),
2540         [],[enable_split='no'])
2541 AC_MSG_RESULT([$enable_split])
2542 if test x$enable_split != xno; then
2543    AC_DEFINE(HAVE_SPLIT_SUPPORT, 1, [enable split support])
2544 fi
2545 ])
2546
2547 AC_DEFUN([LC_TASK_CLENV_TUX_INFO],
2548 [AC_MSG_CHECKING([tux_info])
2549 LB_LINUX_TRY_COMPILE([
2550         #include <linux/sched.h>
2551 ],[
2552         struct task_struct task;
2553         &task.tux_info;
2554 ],[
2555         AC_MSG_RESULT([yes])
2556         AC_DEFINE(LL_TASK_CL_ENV, tux_info, [have tux_info])
2557         have_task_clenv_store='yes'
2558 ],[
2559         AC_MSG_RESULT([no])
2560 ])
2561 ])
2562
2563 #
2564 # LC_LLITE_LLOOP_MODULE
2565 # lloop_llite.ko does not currently work with page sizes
2566 # of 64k or larger.
2567 #
2568 AC_DEFUN([LC_LLITE_LLOOP_MODULE],
2569 [AC_MSG_CHECKING([whether to enable llite_lloop module])
2570 LB_LINUX_TRY_COMPILE([
2571         #include <asm/page.h>
2572 ],[
2573         #if PAGE_SIZE >= 65536
2574         #error "PAGE_SIZE >= 65536"
2575         #endif
2576 ],[
2577         enable_llite_lloop_module='yes'
2578         AC_MSG_RESULT([yes])
2579 ],[
2580         enable_llite_lloop_module='no'
2581         AC_MSG_RESULT([no])
2582 ])
2583 ])
2584
2585 #
2586 # LC_CONFIGURE
2587 #
2588 # other configure checks
2589 #
2590 AC_DEFUN([LC_CONFIGURE],
2591 [LC_CONFIG_OBD_BUFFER_SIZE
2592
2593 if test $target_cpu == "i686" -o $target_cpu == "x86_64"; then
2594         CFLAGS="$CFLAGS -Werror"
2595 fi
2596
2597 # maximum MDS thread count
2598 LC_MDS_MAX_THREADS
2599
2600 # include/liblustre.h
2601 AC_CHECK_HEADERS([sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
2602
2603 # liblustre/llite_lib.h
2604 AC_CHECK_HEADERS([xtio.h file.h])
2605
2606 # liblustre/dir.c
2607 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
2608
2609 # liblustre/lutil.c
2610 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h catamount/data.h])
2611 AC_CHECK_FUNCS([inet_ntoa])
2612
2613 # libsysio/src/readlink.c
2614 LC_READLINK_SSIZE_T
2615
2616 # lvfs/prng.c - depends on linux/types.h from liblustre/dir.c
2617 AC_CHECK_HEADERS([linux/random.h], [], [],
2618                  [#ifdef HAVE_LINUX_TYPES_H
2619                   # include <linux/types.h>
2620                   #endif
2621                  ])
2622
2623 # utils/llverfs.c
2624 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
2625
2626 # check for -lz support
2627 ZLIB=""
2628 AC_CHECK_LIB([z],
2629              [adler32],
2630              [AC_CHECK_HEADERS([zlib.h],
2631                                [ZLIB="-lz"
2632                                 AC_DEFINE([HAVE_ADLER], 1,
2633                                           [support alder32 checksum type])],
2634                                [AC_MSG_WARN([No zlib-devel package found,
2635                                              unable to use adler32 checksum])])],
2636              [AC_MSG_WARN([No zlib package found, unable to use adler32 checksum])]
2637 )
2638 AC_SUBST(ZLIB)
2639
2640 # Super safe df
2641 AC_ARG_ENABLE([mindf],
2642       AC_HELP_STRING([--enable-mindf],
2643                       [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
2644       [],[])
2645 if test "$enable_mindf" = "yes" ;  then
2646       AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])
2647 fi
2648
2649 AC_ARG_ENABLE([fail_alloc],
2650         AC_HELP_STRING([--disable-fail-alloc],
2651                 [disable randomly alloc failure]),
2652         [],[enable_fail_alloc=yes])
2653 AC_MSG_CHECKING([whether to randomly failing memory alloc])
2654 AC_MSG_RESULT([$enable_fail_alloc])
2655 if test x$enable_fail_alloc != xno ; then
2656         AC_DEFINE([RANDOM_FAIL_ALLOC], 1, [enable randomly alloc failure])
2657 fi
2658
2659 AC_ARG_ENABLE([invariants],
2660         AC_HELP_STRING([--enable-invariants],
2661                 [enable invariant checking (cpu intensive)]),
2662         [],[])
2663 AC_MSG_CHECKING([whether to check invariants (expensive cpu-wise)])
2664 AC_MSG_RESULT([$enable_invariants])
2665 if test x$enable_invariants = xyes ; then
2666         AC_DEFINE([INVARIANT_CHECK], 1, [enable invariant checking])
2667 fi
2668
2669 AC_ARG_ENABLE([lu_ref],
2670         AC_HELP_STRING([--enable-lu_ref],
2671                 [enable lu_ref reference tracking code]),
2672         [],[])
2673 AC_MSG_CHECKING([whether to track references with lu_ref])
2674 AC_MSG_RESULT([$enable_lu_ref])
2675 if test x$enable_lu_ref = xyes ; then
2676         AC_DEFINE([USE_LU_REF], 1, [enable lu_ref reference tracking code])
2677 fi
2678
2679 AC_ARG_ENABLE([pgstate-track],
2680               AC_HELP_STRING([--enable-pgstate-track],
2681                              [enable page state tracking]),
2682               [enable_pgstat_track='yes'],[])
2683 AC_MSG_CHECKING([whether to enable page state tracking])
2684 AC_MSG_RESULT([$enable_pgstat_track])
2685 if test x$enable_pgstat_track = xyes ; then
2686         AC_DEFINE([LUSTRE_PAGESTATE_TRACKING], 1,
2687                   [enable page state tracking code])
2688 fi
2689
2690          #2.6.29
2691          LC_WRITE_BEGIN_END
2692          LC_D_OBTAIN_ALIAS
2693          LC_BLKDEV_PUT_2ARGS
2694          LC_DENTRY_OPEN_4ARGS
2695
2696 ])
2697
2698 #
2699 # LC_CONDITIONALS
2700 #
2701 # AM_CONDITIONALS for lustre
2702 #
2703 AC_DEFUN([LC_CONDITIONALS],
2704 [AM_CONDITIONAL(LIBLUSTRE, test x$enable_liblustre = xyes)
2705 AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
2706 AM_CONDITIONAL(LIBLUSTRE_TESTS, test x$enable_liblustre_tests = xyes)
2707 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
2708 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
2709 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
2710 AM_CONDITIONAL(QUOTA, test x$enable_quota_module = xyes)
2711 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
2712 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
2713 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
2714 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
2715 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
2716 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
2717 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
2718 AM_CONDITIONAL(LLITE_LLOOP, test x$enable_llite_lloop_module = xyes)
2719 ])
2720
2721 #
2722 # LC_CONFIG_FILES
2723 #
2724 # files that should be generated with AC_OUTPUT
2725 #
2726 AC_DEFUN([LC_CONFIG_FILES],
2727 [AC_CONFIG_FILES([
2728 lustre/Makefile
2729 lustre/autoMakefile
2730 lustre/autoconf/Makefile
2731 lustre/conf/Makefile
2732 lustre/contrib/Makefile
2733 lustre/doc/Makefile
2734 lustre/include/Makefile
2735 lustre/include/lustre_ver.h
2736 lustre/include/linux/Makefile
2737 lustre/include/lustre/Makefile
2738 lustre/kernel_patches/targets/2.6-rhel6.target
2739 lustre/kernel_patches/targets/2.6-rhel5.target
2740 lustre/kernel_patches/targets/2.6-sles10.target
2741 lustre/kernel_patches/targets/2.6-sles11.target
2742 lustre/kernel_patches/targets/2.6-oel5.target
2743 lustre/kernel_patches/targets/2.6-fc11.target
2744 lustre/kernel_patches/targets/2.6-fc12.target
2745 lustre/ldlm/Makefile
2746 lustre/fid/Makefile
2747 lustre/fid/autoMakefile
2748 lustre/liblustre/Makefile
2749 lustre/liblustre/tests/Makefile
2750 lustre/liblustre/tests/mpi/Makefile
2751 lustre/llite/Makefile
2752 lustre/llite/autoMakefile
2753 lustre/lclient/Makefile
2754 lustre/lov/Makefile
2755 lustre/lov/autoMakefile
2756 lustre/lvfs/Makefile
2757 lustre/lvfs/autoMakefile
2758 lustre/mdc/Makefile
2759 lustre/mdc/autoMakefile
2760 lustre/lmv/Makefile
2761 lustre/lmv/autoMakefile
2762 lustre/mds/Makefile
2763 lustre/mds/autoMakefile
2764 lustre/mdt/Makefile
2765 lustre/mdt/autoMakefile
2766 lustre/cmm/Makefile
2767 lustre/cmm/autoMakefile
2768 lustre/mdd/Makefile
2769 lustre/mdd/autoMakefile
2770 lustre/fld/Makefile
2771 lustre/fld/autoMakefile
2772 lustre/obdclass/Makefile
2773 lustre/obdclass/autoMakefile
2774 lustre/obdclass/linux/Makefile
2775 lustre/obdecho/Makefile
2776 lustre/obdecho/autoMakefile
2777 lustre/obdfilter/Makefile
2778 lustre/obdfilter/autoMakefile
2779 lustre/osc/Makefile
2780 lustre/osc/autoMakefile
2781 lustre/ost/Makefile
2782 lustre/ost/autoMakefile
2783 lustre/osd-ldiskfs/Makefile
2784 lustre/osd-ldiskfs/autoMakefile
2785 lustre/mgc/Makefile
2786 lustre/mgc/autoMakefile
2787 lustre/mgs/Makefile
2788 lustre/mgs/autoMakefile
2789 lustre/ptlrpc/Makefile
2790 lustre/ptlrpc/autoMakefile
2791 lustre/ptlrpc/gss/Makefile
2792 lustre/ptlrpc/gss/autoMakefile
2793 lustre/quota/Makefile
2794 lustre/quota/autoMakefile
2795 lustre/scripts/Makefile
2796 lustre/tests/Makefile
2797 lustre/tests/mpi/Makefile
2798 lustre/utils/Makefile
2799 lustre/utils/gss/Makefile
2800 lustre/obdclass/darwin/Makefile
2801 ])
2802 ])