Whamcloud - gitweb
583c6c5c2667fa7fa090e5d04b2a1e09c212afd7
[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 ])
12
13 #
14 # LC_PATH_DEFAULTS
15 #
16 # lustre specific paths
17 #
18 AC_DEFUN([LC_PATH_DEFAULTS],
19 [# ptlrpc kernel build requires this
20 LUSTRE="$PWD/lustre"
21 AC_SUBST(LUSTRE)
22
23 # mount.lustre
24 rootsbindir='/sbin'
25 AC_SUBST(rootsbindir)
26
27 demodir='$(docdir)/demo'
28 AC_SUBST(demodir)
29
30 pkgexampledir='${pkgdatadir}/examples'
31 AC_SUBST(pkgexampledir)
32 ])
33
34 #
35 # LC_TARGET_SUPPORTED
36 #
37 # is the target os supported?
38 #
39 AC_DEFUN([LC_TARGET_SUPPORTED],
40 [case $target_os in
41         linux* | darwin*)
42 $1
43                 ;;
44         *)
45 $2
46                 ;;
47 esac
48 ])
49
50 #
51 # LC_CONFIG_EXT3
52 #
53 # that ext3 is enabled in the kernel
54 #
55 AC_DEFUN([LC_CONFIG_EXT3],
56 [LB_LINUX_CONFIG([EXT3_FS],[],[
57         LB_LINUX_CONFIG([EXT3_FS_MODULE],[],[$2])
58 ])
59 LB_LINUX_CONFIG([EXT3_FS_XATTR],[$1],[$3])
60 ])
61
62 #
63 # LC_FSHOOKS
64 #
65 # If we have (and can build) fshooks.h
66 #
67 AC_DEFUN([LC_FSHOOKS],
68 [LB_CHECK_FILE([$LINUX/include/linux/fshooks.h],[
69         AC_MSG_CHECKING([if fshooks.h can be compiled])
70         LB_LINUX_TRY_COMPILE([
71                 #include <linux/fshooks.h>
72         ],[],[
73                 AC_MSG_RESULT([yes])
74         ],[
75                 AC_MSG_RESULT([no])
76                 AC_MSG_WARN([You might have better luck with gcc 3.3.x.])
77                 AC_MSG_WARN([You can set CC=gcc33 before running configure.])
78                 AC_MSG_ERROR([Your compiler cannot build fshooks.h.])
79         ])
80 $1
81 ],[
82 $2
83 ])
84 ])
85
86 #
87 # LC_FUNC_RELEASEPAGE_WITH_INT
88 #
89 # if ->releasepage() takes an int arg in 2.6.9
90 # This kernel defines gfp_t (HAS_GFP_T) but doesn't use it for this function,
91 # while others either don't have gfp_t or pass gfp_t as the parameter.
92 #
93 AC_DEFUN([LC_FUNC_RELEASEPAGE_WITH_INT],
94 [AC_MSG_CHECKING([if releasepage has a int parameter])
95 RELEASEPAGE_WITH_INT="`grep -c 'releasepage.*int' $LINUX/include/linux/fs.h`"
96 if test "$RELEASEPAGE_WITH_INT" != 0 ; then
97         AC_DEFINE(HAVE_RELEASEPAGE_WITH_INT, 1,
98                   [releasepage with int parameter])
99         AC_MSG_RESULT([yes])
100 else
101         AC_MSG_RESULT([no])
102 fi
103 ])
104
105 #
106 # LC_FUNC_FILEMAP_FDATASYNC
107 #
108 # if filemap_fdatasync() exists
109 #
110 AC_DEFUN([LC_FUNC_FILEMAP_FDATAWRITE],
111 [AC_MSG_CHECKING([whether filemap_fdatawrite() is defined])
112 LB_LINUX_TRY_COMPILE([
113         #include <linux/fs.h>
114 ],[
115         int (*foo)(struct address_space *)= filemap_fdatawrite;
116 ],[
117         AC_MSG_RESULT([yes])
118         AC_DEFINE(HAVE_FILEMAP_FDATAWRITE, 1, [filemap_fdatawrite() found])
119 ],[
120         AC_MSG_RESULT([no])
121 ])
122 ])
123
124 #
125 # LC_HEADER_MM_INLINE
126 #
127 # RHEL kernels define page_count in mm_inline.h
128 #
129 AC_DEFUN([LC_HEADER_MM_INLINE],
130 [AC_MSG_CHECKING([if kernel has mm_inline.h header])
131 LB_LINUX_TRY_COMPILE([
132         #include <linux/mm_inline.h>
133 ],[
134         #ifndef page_count
135         #error mm_inline.h does not define page_count
136         #endif
137 ],[
138         AC_MSG_RESULT([yes])
139         AC_DEFINE(HAVE_MM_INLINE, 1, [mm_inline found])
140 ],[
141         AC_MSG_RESULT([no])
142 ])
143 ])
144
145 #
146 # LC_STRUCT_INODE
147 #
148 # if inode->i_alloc_sem exists
149 #
150 AC_DEFUN([LC_STRUCT_INODE],
151 [AC_MSG_CHECKING([if struct inode has i_alloc_sem])
152 LB_LINUX_TRY_COMPILE([
153         #include <linux/fs.h>
154         #include <linux/version.h>
155 ],[
156         #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24))
157         #error "down_read_trylock broken before 2.4.24"
158         #endif
159         struct inode i;
160         return (char *)&i.i_alloc_sem - (char *)&i;
161 ],[
162         AC_MSG_RESULT([yes])
163         AC_DEFINE(HAVE_I_ALLOC_SEM, 1, [struct inode has i_alloc_sem])
164 ],[
165         AC_MSG_RESULT([no])
166 ])
167 ])
168
169 #
170 # LC_FUNC_REGISTER_CACHE
171 #
172 # if register_cache() is defined by kernel
173 #
174 # There are two ways to shrink one customized cache in linux kernels. For the
175 # kernels are prior than 2.6.5(?), register_cache() is used, and for latest
176 # kernels, set_shrinker() is used instead.
177 #
178 AC_DEFUN([LC_FUNC_REGISTER_CACHE],
179 [AC_MSG_CHECKING([if kernel defines cache pressure hook])
180 LB_LINUX_TRY_COMPILE([
181         #include <linux/mm.h>
182 ],[
183         shrinker_t shrinker;
184
185         set_shrinker(1, shrinker);
186 ],[
187         AC_MSG_RESULT([set_shrinker])
188         AC_DEFINE(HAVE_SHRINKER_CACHE, 1, [shrinker_cache found])
189         AC_DEFINE(HAVE_CACHE_RETURN_INT, 1, [shrinkers should return int])
190 ],[
191         LB_LINUX_TRY_COMPILE([
192                 #include <linux/list.h>
193                 #include <linux/cache_def.h>
194         ],[
195                 struct cache_definition cache;
196         ],[
197                 AC_MSG_RESULT([register_cache])
198                 AC_DEFINE(HAVE_REGISTER_CACHE, 1, [register_cache found])
199                 AC_MSG_CHECKING([if kernel expects return from cache shrink ])
200                 tmp_flags="$EXTRA_KCFLAGS"
201                 EXTRA_KCFLAGS="-Werror"
202                 LB_LINUX_TRY_COMPILE([
203                         #include <linux/list.h>
204                         #include <linux/cache_def.h>
205                 ],[
206                         struct cache_definition c;
207                         c.shrinker = (int (*)(int, unsigned int))1;
208                 ],[
209                         AC_DEFINE(HAVE_CACHE_RETURN_INT, 1,
210                                   [kernel expects return from shrink_cache])
211                         AC_MSG_RESULT(yes)
212                 ],[
213                         AC_MSG_RESULT(no)
214                 ])
215                 EXTRA_KCFLAGS="$tmp_flags"
216         ],[
217                 AC_MSG_RESULT([no])
218         ])
219 ])
220 ])
221
222 #
223 # LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
224 #
225 # check for our patched grab_cache_page_nowait_gfp() function
226 #
227 AC_DEFUN([LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP],
228 [AC_MSG_CHECKING([if kernel defines grab_cache_page_nowait_gfp()])
229 HAVE_GCPN_GFP="`grep -c 'grab_cache_page_nowait_gfp' $LINUX/include/linux/pagemap.h`"
230 if test "$HAVE_GCPN_GFP" != 0 ; then
231         AC_DEFINE(HAVE_GRAB_CACHE_PAGE_NOWAIT_GFP, 1,
232                 [kernel has grab_cache_page_nowait_gfp()])
233         AC_MSG_RESULT(yes)
234 else
235         AC_MSG_RESULT(no)
236 fi
237 ])
238
239 #
240 # LC_FUNC_DEV_SET_RDONLY
241 #
242 # check for the old-style dev_set_rdonly which took an extra "devno" param
243 # and can only set a single device to discard writes at one time
244 #
245 AC_DEFUN([LC_FUNC_DEV_SET_RDONLY],
246 [AC_MSG_CHECKING([if kernel has new dev_set_rdonly])
247 LB_LINUX_TRY_COMPILE([
248         #include <linux/fs.h>
249 ],[
250         #ifndef HAVE_CLEAR_RDONLY_ON_PUT
251         #error needs to be patched by lustre kernel patches from Lustre version 1.4.3 or above.
252         #endif
253 ],[
254         AC_MSG_RESULT([yes])
255         AC_DEFINE(HAVE_DEV_SET_RDONLY, 1, [kernel has new dev_set_rdonly])
256 ],[
257         AC_MSG_RESULT([no, Linux kernel source needs to be patches by lustre
258 kernel patches from Lustre version 1.4.3 or above.])
259 ])
260 ])
261
262 #
263 # LC_CONFIG_BACKINGFS
264 #
265 # setup, check the backing filesystem
266 #
267 AC_DEFUN([LC_CONFIG_BACKINGFS],
268 [
269 BACKINGFS="ldiskfs"
270
271 if test x$with_ldiskfs = xno ; then
272         BACKINGFS="ext3"
273
274         if test x$linux25$enable_server = xyesyes ; then
275                 AC_MSG_ERROR([ldiskfs is required for 2.6-based servers.])
276         fi
277
278         # --- Check that ext3 and ext3 xattr are enabled in the kernel
279         LC_CONFIG_EXT3([],[
280                 AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel])
281         ],[
282                 AC_MSG_WARN([Lustre requires that extended attributes for ext3 are enabled in the kernel])
283                 AC_MSG_WARN([This build may fail.])
284         ])
285 else
286         # ldiskfs is enabled
287         LB_DEFINE_LDISKFS_OPTIONS
288 fi #ldiskfs
289
290 AC_MSG_CHECKING([which backing filesystem to use])
291 AC_MSG_RESULT([$BACKINGFS])
292 AC_SUBST(BACKINGFS)
293 ])
294
295 #
296 # LC_CONFIG_PINGER
297 #
298 # the pinger is temporary, until we have the recovery node in place
299 #
300 AC_DEFUN([LC_CONFIG_PINGER],
301 [AC_MSG_CHECKING([whether to enable pinger support])
302 AC_ARG_ENABLE([pinger],
303         AC_HELP_STRING([--disable-pinger],
304                         [disable recovery pinger support]),
305         [],[enable_pinger='yes'])
306 AC_MSG_RESULT([$enable_pinger])
307 if test x$enable_pinger != xno ; then
308   AC_DEFINE(ENABLE_PINGER, 1, Use the Pinger)
309 fi
310 ])
311
312 #
313 # LC_CONFIG_CHECKSUM
314 #
315 # do checksum of bulk data between client and OST
316 #
317 AC_DEFUN([LC_CONFIG_CHECKSUM],
318 [AC_MSG_CHECKING([whether to enable data checksum support])
319 AC_ARG_ENABLE([checksum],
320        AC_HELP_STRING([--disable-checksum],
321                        [disable data checksum support]),
322        [],[enable_checksum='yes'])
323 AC_MSG_RESULT([$enable_checksum])
324 if test x$enable_checksum != xno ; then
325   AC_DEFINE(ENABLE_CHECKSUM, 1, do data checksums)
326 fi
327 ])
328
329 #
330 # LC_CONFIG_HEALTH_CHECK_WRITE
331 #
332 # Turn off the actual write to the disk
333 #
334 AC_DEFUN([LC_CONFIG_HEALTH_CHECK_WRITE],
335 [AC_MSG_CHECKING([whether to enable a write with the health check])
336 AC_ARG_ENABLE([health_write],
337         AC_HELP_STRING([--enable-health_write],
338                         [enable disk writes when doing health check]),
339         [],[enable_health_write='no'])
340 AC_MSG_RESULT([$enable_health_write])
341 if test x$enable_health_write != xno ; then
342   AC_DEFINE(USE_HEALTH_CHECK_WRITE, 1, Write when Checking Health)
343 fi
344 ])
345
346 #
347 # LC_CONFIG_LIBLUSTRE_RECOVERY
348 #
349 AC_DEFUN([LC_CONFIG_LIBLUSTRE_RECOVERY],
350 [AC_MSG_CHECKING([whether to enable liblustre recovery support])
351 AC_ARG_ENABLE([liblustre-recovery],
352         AC_HELP_STRING([--disable-liblustre-recovery],
353                         [disable liblustre recovery support]),
354         [],[enable_liblustre_recovery='yes'])
355 AC_MSG_RESULT([$enable_liblustre_recovery])
356 if test x$enable_liblustre_recovery != xno ; then
357   AC_DEFINE(ENABLE_LIBLUSTRE_RECOVERY, 1, Liblustre Can Recover)
358 fi
359 ])
360
361 #
362 # LC_CONFIG_OBD_BUFFER_SIZE
363 #
364 # the maximum buffer size of lctl ioctls
365 #
366 AC_DEFUN([LC_CONFIG_OBD_BUFFER_SIZE],
367 [AC_MSG_CHECKING([maximum OBD ioctl size])
368 AC_ARG_WITH([obd-buffer-size],
369         AC_HELP_STRING([--with-obd-buffer-size=[size]],
370                         [set lctl ioctl maximum bytes (default=8192)]),
371         [
372                 OBD_BUFFER_SIZE=$with_obd_buffer_size
373         ],[
374                 OBD_BUFFER_SIZE=8192
375         ])
376 AC_MSG_RESULT([$OBD_BUFFER_SIZE bytes])
377 AC_DEFINE_UNQUOTED(OBD_MAX_IOCTL_BUFFER, $OBD_BUFFER_SIZE, [IOCTL Buffer Size])
378 ])
379
380 #
381 # LC_STRUCT_STATFS
382 #
383 # AIX does not have statfs.f_namelen
384 #
385 AC_DEFUN([LC_STRUCT_STATFS],
386 [AC_MSG_CHECKING([if struct statfs has a f_namelen field])
387 LB_LINUX_TRY_COMPILE([
388         #include <linux/vfs.h>
389 ],[
390         struct statfs sfs;
391         sfs.f_namelen = 1;
392 ],[
393         AC_MSG_RESULT([yes])
394         AC_DEFINE(HAVE_STATFS_NAMELEN, 1, [struct statfs has a namelen field])
395 ],[
396         AC_MSG_RESULT([no])
397 ])
398 ])
399
400 #
401 # LC_READLINK_SSIZE_T
402 #
403 AC_DEFUN([LC_READLINK_SSIZE_T],
404 [AC_MSG_CHECKING([if readlink returns ssize_t])
405 AC_TRY_COMPILE([
406         #include <unistd.h>
407 ],[
408         ssize_t readlink(const char *, char *, size_t);
409 ],[
410         AC_MSG_RESULT([yes])
411         AC_DEFINE(HAVE_POSIX_1003_READLINK, 1, [readlink returns ssize_t])
412 ],[
413         AC_MSG_RESULT([no])
414 ])
415 ])
416
417 AC_DEFUN([LC_FUNC_PAGE_MAPPED],
418 [AC_MSG_CHECKING([if kernel offers page_mapped])
419 LB_LINUX_TRY_COMPILE([
420         #include <linux/mm.h>
421 ],[
422         page_mapped(NULL);
423 ],[
424         AC_MSG_RESULT([yes])
425         AC_DEFINE(HAVE_PAGE_MAPPED, 1, [page_mapped found])
426 ],[
427         AC_MSG_RESULT([no])
428 ])
429 ])
430
431 AC_DEFUN([LC_STRUCT_FILE_OPS_UNLOCKED_IOCTL],
432 [AC_MSG_CHECKING([if struct file_operations has an unlocked_ioctl field])
433 LB_LINUX_TRY_COMPILE([
434         #include <linux/fs.h>
435 ],[
436         struct file_operations fops;
437         &fops.unlocked_ioctl;
438 ],[
439         AC_MSG_RESULT([yes])
440         AC_DEFINE(HAVE_UNLOCKED_IOCTL, 1, [struct file_operations has an unlock ed_ioctl field])
441 ],[
442         AC_MSG_RESULT([no])
443 ])
444 ])
445
446 AC_DEFUN([LC_FILEMAP_POPULATE],
447 [AC_MSG_CHECKING([for exported filemap_populate])
448 LB_LINUX_TRY_COMPILE([
449         #include <asm/page.h>
450         #include <linux/mm.h>
451 ],[
452        filemap_populate(NULL, 0, 0, __pgprot(0), 0, 0);
453 ],[
454         AC_MSG_RESULT([yes])
455         AC_DEFINE(HAVE_FILEMAP_POPULATE, 1, [Kernel exports filemap_populate])
456 ],[
457         AC_MSG_RESULT([no])
458 ])
459 ])
460
461 AC_DEFUN([LC_D_ADD_UNIQUE],
462 [AC_MSG_CHECKING([for d_add_unique])
463 LB_LINUX_TRY_COMPILE([
464         #include <linux/dcache.h>
465 ],[
466        d_add_unique(NULL, NULL);
467 ],[
468         AC_MSG_RESULT([yes])
469         AC_DEFINE(HAVE_D_ADD_UNIQUE, 1, [Kernel has d_add_unique])
470 ],[
471         AC_MSG_RESULT([no])
472 ])
473 ])
474
475 AC_DEFUN([LC_BIT_SPINLOCK_H],
476 [LB_CHECK_FILE([$LINUX/include/linux/bit_spinlock.h],[
477         AC_MSG_CHECKING([if bit_spinlock.h can be compiled])
478         LB_LINUX_TRY_COMPILE([
479                 #include <asm/processor.h>
480                 #include <linux/spinlock.h>
481                 #include <linux/bit_spinlock.h>
482         ],[],[
483                 AC_MSG_RESULT([yes])
484                 AC_DEFINE(HAVE_BIT_SPINLOCK_H, 1, [Kernel has bit_spinlock.h])
485         ],[
486                 AC_MSG_RESULT([no])
487         ])
488 ],
489 [])
490 ])
491
492 #
493 # LC_POSIX_ACL_XATTR
494 #
495 # If we have xattr_acl.h
496 #
497 AC_DEFUN([LC_XATTR_ACL],
498 [LB_CHECK_FILE([$LINUX/include/linux/xattr_acl.h],[
499         AC_MSG_CHECKING([if xattr_acl.h can be compiled])
500         LB_LINUX_TRY_COMPILE([
501                 #include <linux/xattr_acl.h>
502         ],[],[
503                 AC_MSG_RESULT([yes])
504                 AC_DEFINE(HAVE_XATTR_ACL, 1, [Kernel has xattr_acl])
505         ],[
506                 AC_MSG_RESULT([no])
507         ])
508 ],
509 [])
510 ])
511
512 #
513 # LC_LINUX_FIEMAP_H
514 #
515 # If we have fiemap.h
516 # after 2.6.27 use fiemap.h in include/linux
517 #
518 AC_DEFUN([LC_LINUX_FIEMAP_H],
519 [LB_CHECK_FILE([$LINUX/include/linux/fiemap.h],[
520         AC_MSG_CHECKING([if fiemap.h can be compiled])
521         LB_LINUX_TRY_COMPILE([
522                 #include <linux/fiemap.h>
523         ],[],[
524                 AC_MSG_RESULT([yes])
525                 AC_DEFINE(HAVE_LINUX_FIEMAP_H, 1, [Kernel has fiemap.h])
526         ],[
527                 AC_MSG_RESULT([no])
528         ])
529 ],
530 [])
531 ])
532
533
534 AC_DEFUN([LC_STRUCT_INTENT_FILE],
535 [AC_MSG_CHECKING([if struct open_intent has a file field])
536 LB_LINUX_TRY_COMPILE([
537         #include <linux/fs.h>
538         #include <linux/namei.h>
539 ],[
540         struct open_intent intent;
541         &intent.file;
542 ],[
543         AC_MSG_RESULT([yes])
544         AC_DEFINE(HAVE_FILE_IN_STRUCT_INTENT, 1, [struct open_intent has a file field])
545 ],[
546         AC_MSG_RESULT([no])
547 ])
548 ])
549
550
551 AC_DEFUN([LC_POSIX_ACL_XATTR_H],
552 [LB_CHECK_FILE([$LINUX/include/linux/posix_acl_xattr.h],[
553         AC_MSG_CHECKING([if linux/posix_acl_xattr.h can be compiled])
554         LB_LINUX_TRY_COMPILE([
555                 #include <linux/posix_acl_xattr.h>
556         ],[],[
557                 AC_MSG_RESULT([yes])
558                 AC_DEFINE(HAVE_LINUX_POSIX_ACL_XATTR_H, 1, [linux/posix_acl_xattr.h found])
559
560         ],[
561                 AC_MSG_RESULT([no])
562         ])
563 $1
564 ],[
565 AC_MSG_RESULT([no])
566 ])
567 ])
568
569 #
570 # LC_EXPORT___IGET
571 # starting from 2.6.19 linux kernel exports __iget()
572 #
573 AC_DEFUN([LC_EXPORT___IGET],
574 [LB_CHECK_SYMBOL_EXPORT([__iget],
575 [fs/inode.c],[
576         AC_DEFINE(HAVE_EXPORT___IGET, 1, [kernel exports __iget])
577 ],[
578 ])
579 ])
580
581 AC_DEFUN([LC_LUSTRE_VERSION_H],
582 [LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
583         rm -f "$LUSTRE/include/linux/lustre_version.h"
584 ],[
585         touch "$LUSTRE/include/linux/lustre_version.h"
586         if test x$enable_server = xyes ; then
587                 AC_MSG_WARN([Unpatched kernel detected.])
588                 AC_MSG_WARN([Lustre servers cannot be built with an unpatched kernel;])
589                 AC_MSG_WARN([disabling server build])
590                 enable_server='no'
591         fi
592 ])
593 ])
594
595 #
596 # LC_CAPA_CRYPTO
597 #
598 AC_DEFUN([LC_CAPA_CRYPTO],
599 [LB_LINUX_CONFIG_IM([CRYPTO],[],[
600         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO is enabled in your kernel.])
601 ])
602 LB_LINUX_CONFIG_IM([CRYPTO_HMAC],[],[
603         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO_HMAC is enabled in your kernel.])
604 ])
605 LB_LINUX_CONFIG_IM([CRYPTO_SHA1],[],[
606         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO_SHA1 is enabled in your kernel.])
607 ])
608 ])
609
610 #
611 # LC_CONFIG_RMTCLIENT
612 #
613 dnl FIXME
614 dnl the AES symbol usually tied with arch, e.g. CRYPTO_AES_586
615 dnl FIXME
616 AC_DEFUN([LC_CONFIG_RMTCLIENT],
617 [LB_LINUX_CONFIG_IM([CRYPTO_AES],[],[
618         AC_MSG_WARN([Lustre remote client require that CONFIG_CRYPTO_AES is enabled in your kernel.])
619 ])
620 ])
621
622 AC_DEFUN([LC_SUNRPC_CACHE],
623 [AC_MSG_CHECKING([if sunrpc struct cache_head uses kref])
624 LB_LINUX_TRY_COMPILE([
625         #include <linux/sunrpc/cache.h>
626 ],[
627         struct cache_head ch;
628         &ch.ref.refcount;
629 ],[
630         AC_MSG_RESULT([yes])
631         AC_DEFINE(HAVE_SUNRPC_CACHE_V2, 1, [sunrpc cache facility v2])
632 ],[
633         AC_MSG_RESULT([no])
634 ])
635 ])
636
637 AC_DEFUN([LC_CONFIG_SUNRPC],
638 [LB_LINUX_CONFIG_IM([SUNRPC],[],
639                     [AC_MSG_ERROR([kernel SUNRPC support is required by using GSS.])])
640  LC_SUNRPC_CACHE
641 ])
642
643 #
644 # LC_CONFIG_GSS_KEYRING (default enabled, if gss is enabled)
645 #
646 AC_DEFUN([LC_CONFIG_GSS_KEYRING],
647 [AC_MSG_CHECKING([whether to enable gss keyring backend])
648  AC_ARG_ENABLE([gss_keyring],
649                [AC_HELP_STRING([--disable-gss-keyring],
650                                [disable gss keyring backend])],
651                [],[enable_gss_keyring='yes'])
652  AC_MSG_RESULT([$enable_gss_keyring])
653
654  if test x$enable_gss_keyring != xno; then
655         LB_LINUX_CONFIG_IM([KEYS],[],
656                            [AC_MSG_ERROR([GSS keyring backend require that CONFIG_KEYS be enabled in your kernel.])])
657
658         AC_CHECK_LIB([keyutils], [keyctl_search], [],
659                      [AC_MSG_ERROR([libkeyutils is not found, which is required by gss keyring backend])],)
660
661         AC_DEFINE([HAVE_GSS_KEYRING], [1],
662                   [Define this if you enable gss keyring backend])
663  fi
664 ])
665
666 #
667 # LC_CONFIG_GSS (default disabled)
668 #
669 # Build gss and related tools of Lustre. Currently both kernel and user space
670 # parts are depend on linux platform.
671 #
672 AC_DEFUN([LC_CONFIG_GSS],
673 [AC_MSG_CHECKING([whether to enable gss/krb5 support])
674  AC_ARG_ENABLE([gss],
675                [AC_HELP_STRING([--enable-gss], [enable gss/krb5 support])],
676                [],[enable_gss='no'])
677  AC_MSG_RESULT([$enable_gss])
678
679  if test x$enable_gss == xyes; then
680         LC_CONFIG_GSS_KEYRING
681         LC_CONFIG_SUNRPC
682
683         AC_DEFINE([HAVE_GSS], [1], [Define this if you enable gss])
684
685         LB_LINUX_CONFIG_IM([CRYPTO_MD5],[],
686                            [AC_MSG_WARN([kernel MD5 support is recommended by using GSS.])])
687         LB_LINUX_CONFIG_IM([CRYPTO_SHA1],[],
688                            [AC_MSG_WARN([kernel SHA1 support is recommended by using GSS.])])
689         LB_LINUX_CONFIG_IM([CRYPTO_SHA256],[],
690                            [AC_MSG_WARN([kernel SHA256 support is recommended by using GSS.])])
691         LB_LINUX_CONFIG_IM([CRYPTO_SHA512],[],
692                            [AC_MSG_WARN([kernel SHA512 support is recommended by using GSS.])])
693
694         AC_CHECK_LIB([gssapi], [gss_init_sec_context],
695                      [GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssapi"],
696                      [AC_CHECK_LIB([gssglue], [gss_init_sec_context],
697                                    [GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssglue"],
698                                    [AC_MSG_ERROR([libgssapi or libgssglue is not found, which is required by GSS.])])],)
699
700         AC_SUBST(GSSAPI_LIBS)
701
702         AC_KERBEROS_V5
703  fi
704 ])
705
706 # LC_FUNC_MS_FLOCK_LOCK
707 #
708 # SLES9 kernel has MS_FLOCK_LOCK sb flag
709 #
710 AC_DEFUN([LC_FUNC_MS_FLOCK_LOCK],
711 [AC_MSG_CHECKING([if kernel has MS_FLOCK_LOCK sb flag])
712 LB_LINUX_TRY_COMPILE([
713         #include <linux/fs.h>
714 ],[
715         int flags = MS_FLOCK_LOCK;
716 ],[
717         AC_DEFINE(HAVE_MS_FLOCK_LOCK, 1,
718                 [kernel has MS_FLOCK_LOCK flag])
719         AC_MSG_RESULT([yes])
720 ],[
721         AC_MSG_RESULT([no])
722 ])
723 ])
724
725 #
726 # LC_FUNC_HAVE_CAN_SLEEP_ARG
727 #
728 # SLES9 kernel has third arg can_sleep
729 # in fs/locks.c: flock_lock_file_wait()
730 #
731 AC_DEFUN([LC_FUNC_HAVE_CAN_SLEEP_ARG],
732 [AC_MSG_CHECKING([if kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
733 LB_LINUX_TRY_COMPILE([
734         #include <linux/fs.h>
735 ],[
736         int cansleep;
737         struct file *file;
738         struct file_lock *file_lock;
739         flock_lock_file_wait(file, file_lock, cansleep);
740 ],[
741         AC_DEFINE(HAVE_CAN_SLEEP_ARG, 1,
742                 [kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
743         AC_MSG_RESULT([yes])
744 ],[
745         AC_MSG_RESULT([no])
746 ])
747 ])
748
749 #
750 # LC_FUNC_F_OP_FLOCK
751 #
752 # rhel4.2 kernel has f_op->flock field
753 #
754 AC_DEFUN([LC_FUNC_F_OP_FLOCK],
755 [AC_MSG_CHECKING([if struct file_operations has flock field])
756 LB_LINUX_TRY_COMPILE([
757         #include <linux/fs.h>
758 ],[
759         struct file_operations ll_file_operations_flock;
760         ll_file_operations_flock.flock = NULL;
761 ],[
762         AC_DEFINE(HAVE_F_OP_FLOCK, 1,
763                 [struct file_operations has flock field])
764         AC_MSG_RESULT([yes])
765 ],[
766         AC_MSG_RESULT([no])
767 ])
768 ])
769
770 #
771 # LC_TASK_PPTR
772 #
773 # task struct has p_pptr instead of parent
774 #
775 AC_DEFUN([LC_TASK_PPTR],
776 [AC_MSG_CHECKING([task p_pptr found])
777 LB_LINUX_TRY_COMPILE([
778         #include <linux/sched.h>
779 ],[
780         struct task_struct *p;
781         
782         p = p->p_pptr;
783 ],[
784         AC_MSG_RESULT([yes])
785         AC_DEFINE(HAVE_TASK_PPTR, 1, [task p_pptr found])
786 ],[
787         AC_MSG_RESULT([no])
788 ])
789 ])
790
791 #
792 # LC_FUNC_F_OP_FLOCK
793 #
794 # rhel4.2 kernel has f_op->flock field
795 #
796 AC_DEFUN([LC_FUNC_F_OP_FLOCK],
797 [AC_MSG_CHECKING([if struct file_operations has flock field])
798 LB_LINUX_TRY_COMPILE([
799         #include <linux/fs.h>
800 ],[
801         struct file_operations ll_file_operations_flock;
802         ll_file_operations_flock.flock = NULL;
803 ],[
804         AC_DEFINE(HAVE_F_OP_FLOCK, 1,
805                 [struct file_operations has flock field])
806         AC_MSG_RESULT([yes])
807 ],[
808         AC_MSG_RESULT([no])
809 ])
810 ])
811
812 # LC_EXPORT_SYNCHRONIZE_RCU
813 # after 2.6.12 synchronize_rcu is preferred over synchronize_kernel
814 AC_DEFUN([LC_EXPORT_SYNCHRONIZE_RCU],
815 [LB_CHECK_SYMBOL_EXPORT([synchronize_rcu],
816 [kernel/rcupdate.c],[
817         AC_DEFINE(HAVE_SYNCHRONIZE_RCU, 1,
818                 [in 2.6.12 synchronize_rcu preferred over synchronize_kernel])
819 ],[
820 ])
821 ])
822
823 # LC_INODE_I_MUTEX
824 # after 2.6.15 inode have i_mutex intead of i_sem
825 AC_DEFUN([LC_INODE_I_MUTEX],
826 [AC_MSG_CHECKING([if inode has i_mutex ])
827 LB_LINUX_TRY_COMPILE([
828         #include <linux/mutex.h>
829         #include <linux/fs.h>
830         #undef i_mutex
831 ],[
832         struct inode i;
833
834         mutex_unlock(&i.i_mutex);
835 ],[
836         AC_MSG_RESULT(yes)
837         AC_DEFINE(HAVE_INODE_I_MUTEX, 1,
838                 [after 2.6.15 inode have i_mutex intead of i_sem])
839 ],[
840         AC_MSG_RESULT(no)
841 ])
842 ])
843
844 # LC_SEQ_LOCK
845 # after 2.6.18 seq_file has lock intead of sem
846 AC_DEFUN([LC_SEQ_LOCK],
847 [AC_MSG_CHECKING([if struct seq_file has lock field])
848 LB_LINUX_TRY_COMPILE([
849         #include <linux/seq_file.h>
850 ],[
851         struct seq_file seq;
852
853         mutex_unlock(&seq.lock);
854 ],[
855         AC_MSG_RESULT(yes)
856         AC_DEFINE(HAVE_SEQ_LOCK, 1,
857                 [after 2.6.18 seq_file has lock intead of sem])
858 ],[
859         AC_MSG_RESULT(NO)
860 ])
861 ])
862
863 # LC_DQUOTOFF_MUTEX
864 # after 2.6.17 dquote use mutex instead if semaphore
865 AC_DEFUN([LC_DQUOTOFF_MUTEX],
866 [AC_MSG_CHECKING([use dqonoff_mutex])
867 LB_LINUX_TRY_COMPILE([
868         #include <linux/mutex.h>
869         #include <linux/fs.h>
870         #include <linux/quota.h>
871 ],[
872         struct quota_info dq;
873
874         mutex_unlock(&dq.dqonoff_mutex);
875 ],[
876         AC_MSG_RESULT(yes)
877         AC_DEFINE(HAVE_DQUOTOFF_MUTEX, 1,
878                 [after 2.6.17 dquote use mutex instead if semaphore])
879 ],[
880         AC_MSG_RESULT(no)
881 ])
882 ])
883
884 #
885 # LC_STATFS_DENTRY_PARAM
886 # starting from 2.6.18 linux kernel uses dentry instead of
887 # super_block for first vfs_statfs argument
888 #
889 AC_DEFUN([LC_STATFS_DENTRY_PARAM],
890 [AC_MSG_CHECKING([first vfs_statfs parameter is dentry])
891 LB_LINUX_TRY_COMPILE([
892         #include <linux/fs.h>
893 ],[
894         int vfs_statfs(struct dentry *, struct kstatfs *);
895 ],[
896         AC_DEFINE(HAVE_STATFS_DENTRY_PARAM, 1,
897                 [first parameter of vfs_statfs is dentry])
898         AC_MSG_RESULT([yes])
899 ],[
900         AC_MSG_RESULT([no])
901 ])
902 ])
903
904 #
905 # LC_VFS_KERN_MOUNT
906 # starting from 2.6.18 kernel don't export do_kern_mount
907 # and want to use vfs_kern_mount instead.
908 #
909 AC_DEFUN([LC_VFS_KERN_MOUNT],
910 [AC_MSG_CHECKING([vfs_kern_mount exist in kernel])
911 LB_LINUX_TRY_COMPILE([
912         #include <linux/mount.h>
913 ],[
914         vfs_kern_mount(NULL, 0, NULL, NULL);
915 ],[
916         AC_DEFINE(HAVE_VFS_KERN_MOUNT, 1,
917                 [vfs_kern_mount exist in kernel])
918         AC_MSG_RESULT([yes])
919 ],[
920         AC_MSG_RESULT([no])
921 ])
922 ])
923
924 #
925 # LC_INVALIDATEPAGE_RETURN_INT
926 # more 2.6 api changes.  return type for the invalidatepage
927 # address_space_operation is 'void' in new kernels but 'int' in old
928 #
929 AC_DEFUN([LC_INVALIDATEPAGE_RETURN_INT],
930 [AC_MSG_CHECKING([invalidatepage has return int])
931 LB_LINUX_TRY_COMPILE([
932         #include <linux/buffer_head.h>
933 ],[
934         int rc = block_invalidatepage(NULL, 0);
935 ],[
936         AC_MSG_RESULT(yes)
937         AC_DEFINE(HAVE_INVALIDATEPAGE_RETURN_INT, 1,
938                 [Define if return type of invalidatepage should be int])
939 ],[
940         AC_MSG_RESULT(no)
941 ])
942 ])
943
944 # LC_UMOUNTBEGIN_HAS_VFSMOUNT
945 # more 2.6 API changes. 2.6.18 umount_begin has different parameters
946 AC_DEFUN([LC_UMOUNTBEGIN_HAS_VFSMOUNT],
947 [AC_MSG_CHECKING([if umount_begin needs vfsmount parameter instead of super_block])
948 tmp_flags="$EXTRA_KCFLAGS"
949 EXTRA_KCFLAGS="-Werror"
950 LB_LINUX_TRY_COMPILE([
951         #include <linux/fs.h>
952
953         struct vfsmount;
954         static void cfg_umount_begin (struct vfsmount *v, int flags)
955         {
956                 ;
957         }
958
959         static struct super_operations cfg_super_operations = {
960                 .umount_begin   = cfg_umount_begin,
961         };
962 ],[
963         cfg_super_operations.umount_begin(NULL,0);
964 ],[
965         AC_MSG_RESULT(yes)
966         AC_DEFINE(HAVE_UMOUNTBEGIN_VFSMOUNT, 1,
967                 [Define umount_begin need second argument])
968 ],[
969         AC_MSG_RESULT(no)
970 ])
971 EXTRA_KCFLAGS="$tmp_flags"
972 ])
973
974 # inode have i_private field since 2.6.17
975 AC_DEFUN([LC_INODE_IPRIVATE],
976 [AC_MSG_CHECKING([if inode has a i_private field])
977 LB_LINUX_TRY_COMPILE([
978 #include <linux/fs.h>
979 ],[
980         struct inode i;
981         i.i_private = NULL; 
982 ],[
983         AC_MSG_RESULT(yes)
984         AC_DEFINE(HAVE_INODE_IPRIVATE, 1,
985                 [struct inode has i_private field])
986 ],[
987         AC_MSG_RESULT(no)
988 ])
989 ])
990
991 # 2.6.19 API changes
992 # inode don't have i_blksize field
993 AC_DEFUN([LC_INODE_BLKSIZE],
994 [AC_MSG_CHECKING([inode has i_blksize field])
995 LB_LINUX_TRY_COMPILE([
996 #include <linux/fs.h>
997 ],[
998         struct inode i;
999         i.i_blksize = 0;
1000 ],[
1001         AC_MSG_RESULT(yes)
1002         AC_DEFINE(HAVE_INODE_BLKSIZE, 1,
1003                 [struct inode has i_blksize field])
1004 ],[
1005         AC_MSG_RESULT(no)
1006 ])
1007 ])
1008
1009 # LC_VFS_READDIR_U64_INO
1010 # 2.6.19 use u64 for inode number instead of inode_t
1011 AC_DEFUN([LC_VFS_READDIR_U64_INO],
1012 [AC_MSG_CHECKING([check vfs_readdir need 64bit inode number])
1013 tmp_flags="$EXTRA_KCFLAGS"
1014 EXTRA_KCFLAGS="-Werror"
1015 LB_LINUX_TRY_COMPILE([
1016 #include <linux/fs.h>
1017         int fillonedir(void * __buf, const char * name, int namlen, loff_t offset,
1018                       u64 ino, unsigned int d_type)
1019         {
1020                 return 0;
1021         }
1022 ],[
1023         filldir_t filter;
1024
1025         filter = fillonedir;
1026         return 1;
1027 ],[
1028         AC_MSG_RESULT(yes)
1029         AC_DEFINE(HAVE_VFS_READDIR_U64_INO, 1,
1030                 [if vfs_readdir need 64bit inode number])
1031 ],[
1032         AC_MSG_RESULT(no)
1033 ])
1034 EXTRA_KCFLAGS="$tmp_flags"
1035 ])
1036
1037 # LC_FILE_WRITEV
1038 # 2.6.19 replaced writev with aio_write
1039 AC_DEFUN([LC_FILE_WRITEV],
1040 [AC_MSG_CHECKING([writev in fops])
1041 LB_LINUX_TRY_COMPILE([
1042         #include <linux/fs.h>
1043 ],[
1044         struct file_operations *fops = NULL;
1045         fops->writev = NULL;
1046 ],[
1047         AC_MSG_RESULT(yes)
1048         AC_DEFINE(HAVE_FILE_WRITEV, 1,
1049                 [use fops->writev])
1050 ],[
1051         AC_MSG_RESULT(no)
1052 ])
1053 ])
1054
1055 # LC_GENERIC_FILE_READ
1056 # 2.6.19 replaced readv with aio_read
1057 AC_DEFUN([LC_FILE_READV],
1058 [AC_MSG_CHECKING([readv in fops])
1059 LB_LINUX_TRY_COMPILE([
1060         #include <linux/fs.h>
1061 ],[
1062         struct file_operations *fops = NULL;
1063         fops->readv = NULL;
1064 ],[
1065         AC_MSG_RESULT(yes)
1066         AC_DEFINE(HAVE_FILE_READV, 1,
1067                 [use fops->readv])
1068 ],[
1069         AC_MSG_RESULT(no)
1070 ])
1071 ])
1072
1073 # LC_NR_PAGECACHE
1074 # 2.6.18 don't export nr_pagecahe
1075 AC_DEFUN([LC_NR_PAGECACHE],
1076 [AC_MSG_CHECKING([kernel export nr_pagecache])
1077 LB_LINUX_TRY_COMPILE([
1078         #include <linux/pagemap.h>
1079 ],[
1080         return atomic_read(&nr_pagecache);
1081 ],[
1082         AC_MSG_RESULT(yes)
1083         AC_DEFINE(HAVE_NR_PAGECACHE, 1,
1084                 [is kernel export nr_pagecache])
1085 ],[
1086         AC_MSG_RESULT(no)
1087 ])
1088 ])
1089
1090 # LC_CANCEL_DIRTY_PAGE
1091 # 2.6.20 introduse cancel_dirty_page instead of
1092 # clear_page_dirty.
1093 AC_DEFUN([LC_CANCEL_DIRTY_PAGE],
1094 [AC_MSG_CHECKING([kernel has cancel_dirty_page])
1095 LB_LINUX_TRY_COMPILE([
1096         #include <linux/mm.h>
1097         #include <linux/page-flags.h>
1098 ],[
1099         /* tmp workaround for broken OFED 1.4.1 at SLES10 */
1100         #if defined(CONFIG_SLE_VERSION) && CONFIG_SLE_VERSION == 10 && defined(_BACKPORT_LINUX_MM_H_)
1101         #error badly implementation of cancel_dirty_pages
1102         #endif
1103         cancel_dirty_page(NULL, 0);
1104 ],[
1105         AC_MSG_RESULT(yes)
1106         AC_DEFINE(HAVE_CANCEL_DIRTY_PAGE, 1,
1107                   [kernel has cancel_dirty_page instead of clear_page_dirty])
1108 ],[
1109         AC_MSG_RESULT(no)
1110 ])
1111 ])
1112
1113 #
1114 # LC_PAGE_CONSTANT
1115 #
1116 # In order to support raid5 zerocopy patch, we have to patch the kernel to make
1117 # it support constant page, which means the page won't be modified during the
1118 # IO.
1119 #
1120 AC_DEFUN([LC_PAGE_CONSTANT],
1121 [AC_MSG_CHECKING([if kernel have PageConstant defined])
1122 LB_LINUX_TRY_COMPILE([
1123         #include <linux/mm.h>
1124         #include <linux/page-flags.h>
1125 ],[
1126         #ifndef PG_constant
1127         #error "Have no raid5 zcopy patch"
1128         #endif
1129 ],[
1130         AC_MSG_RESULT(yes)
1131         AC_DEFINE(HAVE_PAGE_CONSTANT, 1, [kernel have PageConstant supported])
1132 ],[
1133         AC_MSG_RESULT(no);
1134 ])
1135 ])
1136
1137 # RHEL5 in FS-cache patch rename PG_checked flag
1138 # into PG_fs_misc
1139 AC_DEFUN([LC_PG_FS_MISC],
1140 [AC_MSG_CHECKING([kernel has PG_fs_misc])
1141 LB_LINUX_TRY_COMPILE([
1142         #include <linux/mm.h>
1143         #include <linux/page-flags.h>
1144 ],[
1145         #ifndef PG_fs_misc
1146         #error PG_fs_misc not defined in kernel
1147         #endif
1148 ],[
1149         AC_MSG_RESULT(yes)
1150         AC_DEFINE(HAVE_PG_FS_MISC, 1,
1151                   [is kernel have PG_fs_misc])
1152 ],[
1153         AC_MSG_RESULT(no)
1154 ])
1155 ])
1156
1157 # RHEL5 PageChecked and SetPageChecked defined
1158 AC_DEFUN([LC_PAGE_CHECKED],
1159 [AC_MSG_CHECKING([kernel has PageChecked and SetPageChecked])
1160 LB_LINUX_TRY_COMPILE([
1161         #include <linux/mm.h>
1162         #include <linux/page-flags.h>
1163 ],[
1164         #ifndef PageChecked
1165         #error PageChecked not defined in kernel
1166         #endif
1167         #ifndef SetPageChecked
1168         #error SetPageChecked not defined in kernel
1169         #endif
1170 ],[
1171         AC_MSG_RESULT(yes)
1172         AC_DEFINE(HAVE_PAGE_CHECKED, 1,
1173                   [does kernel have PageChecked and SetPageChecked])
1174 ],[
1175         AC_MSG_RESULT(no)
1176 ])
1177 ])
1178
1179 AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE],
1180 [LB_CHECK_SYMBOL_EXPORT([truncate_complete_page],
1181 [mm/truncate.c],[
1182 AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
1183             [kernel export truncate_complete_page])
1184 ],[
1185 ])
1186 ])
1187
1188 AC_DEFUN([LC_EXPORT_TRUNCATE_RANGE],
1189 [LB_CHECK_SYMBOL_EXPORT([truncate_inode_pages_range],
1190 [mm/truncate.c],[
1191 AC_DEFINE(HAVE_TRUNCATE_RANGE, 1,
1192             [kernel export truncate_inode_pages_range])
1193 ],[
1194 ])
1195 ])
1196
1197 AC_DEFUN([LC_EXPORT_D_REHASH_COND],
1198 [LB_CHECK_SYMBOL_EXPORT([d_rehash_cond],
1199 [fs/dcache.c],[
1200 AC_DEFINE(HAVE_D_REHASH_COND, 1,
1201             [d_rehash_cond is exported by the kernel])
1202 ],[
1203 ])
1204 ])
1205
1206 AC_DEFUN([LC_EXPORT___D_REHASH],
1207 [LB_CHECK_SYMBOL_EXPORT([__d_rehash],
1208 [fs/dcache.c],[
1209 AC_DEFINE(HAVE___D_REHASH, 1,
1210             [__d_rehash is exported by the kernel])
1211 ],[
1212 ])
1213 ])
1214
1215 AC_DEFUN([LC_EXPORT_D_MOVE_LOCKED],
1216 [LB_CHECK_SYMBOL_EXPORT([d_move_locked],
1217 [fs/dcache.c],[
1218 AC_DEFINE(HAVE_D_MOVE_LOCKED, 1,
1219             [d_move_locked is exported by the kernel])
1220 ],[
1221 ])
1222 ])
1223
1224 AC_DEFUN([LC_EXPORT___D_MOVE],
1225 [LB_CHECK_SYMBOL_EXPORT([__d_move],
1226 [fs/dcache.c],[
1227 AC_DEFINE(HAVE___D_MOVE, 1,
1228             [__d_move is exported by the kernel])
1229 ],[
1230 ])
1231 ])
1232
1233 #
1234 # LC_EXPORT_INVALIDATE_MAPPING_PAGES
1235 #
1236 # SLES9, RHEL4, RHEL5, vanilla 2.6.24 export invalidate_mapping_pages() but
1237 # SLES10 2.6.16 does not, for some reason.  For filter cache invalidation.
1238 #
1239 AC_DEFUN([LC_EXPORT_INVALIDATE_MAPPING_PAGES],
1240     [LB_CHECK_SYMBOL_EXPORT([invalidate_mapping_pages], [mm/truncate.c], [
1241          AC_DEFINE(HAVE_INVALIDATE_MAPPING_PAGES, 1,
1242                         [exported invalidate_mapping_pages])],
1243     [LB_CHECK_SYMBOL_EXPORT([invalidate_inode_pages], [mm/truncate.c], [
1244          AC_DEFINE(HAVE_INVALIDATE_INODE_PAGES, 1,
1245                         [exported invalidate_inode_pages])], [
1246        AC_MSG_ERROR([no way to invalidate pages])
1247   ])
1248     ],[])
1249 ])
1250
1251 #
1252 # LC_EXPORT_FILEMAP_FDATASYNC_RANGE
1253 #
1254 # No standard kernels export this
1255 #
1256 AC_DEFUN([LC_EXPORT_FILEMAP_FDATAWRITE_RANGE],
1257 [LB_CHECK_SYMBOL_EXPORT([filemap_fdatawrite_range],
1258 [mm/filemap.c],[
1259 AC_DEFINE(HAVE_FILEMAP_FDATAWRITE_RANGE, 1,
1260             [filemap_fdatawrite_range is exported by the kernel])
1261 ],[
1262 ])
1263 ])
1264
1265 # The actual symbol exported varies among architectures, so we need
1266 # to check many symbols (but only in the current architecture.)  No
1267 # matter what symbol is exported, the kernel #defines node_to_cpumask
1268 # to the appropriate function and that's what we use.
1269 AC_DEFUN([LC_EXPORT_NODE_TO_CPUMASK],
1270          [LB_CHECK_SYMBOL_EXPORT([node_to_cpumask],
1271                                  [arch/$LINUX_ARCH/mm/numa.c],
1272                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
1273                                             [node_to_cpumask is exported by
1274                                              the kernel])]) # x86_64
1275           LB_CHECK_SYMBOL_EXPORT([node_to_cpu_mask],
1276                                  [arch/$LINUX_ARCH/kernel/smpboot.c],
1277                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
1278                                             [node_to_cpumask is exported by
1279                                              the kernel])]) # ia64
1280           LB_CHECK_SYMBOL_EXPORT([node_2_cpu_mask],
1281                                  [arch/$LINUX_ARCH/kernel/smpboot.c],
1282                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
1283                                             [node_to_cpumask is exported by
1284                                              the kernel])]) # i386
1285           ])
1286
1287 # 2.6.22 lost second parameter for invalidate_bdev
1288 AC_DEFUN([LC_INVALIDATE_BDEV_2ARG],
1289 [AC_MSG_CHECKING([if invalidate_bdev has second argument])
1290 LB_LINUX_TRY_COMPILE([
1291         #include <linux/buffer_head.h>
1292 ],[
1293         invalidate_bdev(NULL,0);
1294 ],[
1295         AC_MSG_RESULT([yes])
1296         AC_DEFINE(HAVE_INVALIDATE_BDEV_2ARG, 1,
1297                 [invalidate_bdev has second argument])
1298 ],[
1299         AC_MSG_RESULT([no])
1300 ])
1301 ])
1302
1303 # 2.6.23 have return type 'void' for unregister_blkdev
1304 AC_DEFUN([LC_UNREGISTER_BLKDEV_RETURN_INT],
1305 [AC_MSG_CHECKING([if unregister_blkdev return int])
1306 LB_LINUX_TRY_COMPILE([
1307         #include <linux/fs.h>
1308 ],[
1309         int i = unregister_blkdev(0,NULL);
1310 ],[
1311         AC_MSG_RESULT([yes])
1312         AC_DEFINE(HAVE_UNREGISTER_BLKDEV_RETURN_INT, 1,
1313                 [unregister_blkdev return int])
1314 ],[
1315         AC_MSG_RESULT([no])
1316 ])
1317 ])
1318
1319 # 2.6.23 change .sendfile to .splice_read
1320 AC_DEFUN([LC_KERNEL_SPLICE_READ],
1321 [AC_MSG_CHECKING([if kernel has .splice_read])
1322 LB_LINUX_TRY_COMPILE([
1323         #include <linux/fs.h>
1324 ],[
1325         struct file_operations file;
1326
1327         file.splice_read = NULL;
1328 ], [
1329         AC_MSG_RESULT([yes])
1330         AC_DEFINE(HAVE_KERNEL_SPLICE_READ, 1,
1331                 [kernel has .slice_read])
1332 ],[
1333         AC_MSG_RESULT([no])
1334 ])
1335 ])
1336
1337 # 2.6.23 extract nfs export related data into exportfs.h
1338 AC_DEFUN([LC_HAVE_EXPORTFS_H],
1339 [
1340 tmpfl="$CFLAGS"
1341 CFLAGS="$CFLAGS -I$LINUX_OBJ/include"
1342 AC_CHECK_HEADERS([linux/exportfs.h])
1343 CFLAGS="$tmpfl"
1344 ])
1345
1346 #
1347 # LC_VFS_INTENT_PATCHES
1348 #
1349 # check if the kernel has the VFS intent patches
1350 AC_DEFUN([LC_VFS_INTENT_PATCHES],
1351 [AC_MSG_CHECKING([if the kernel has the VFS intent patches])
1352 LB_LINUX_TRY_COMPILE([
1353         #include <linux/fs.h>
1354         #include <linux/namei.h>
1355 ],[
1356         struct nameidata nd;
1357         struct lookup_intent *it;
1358
1359         it = &nd.intent;
1360         intent_init(it, IT_OPEN);
1361         it->d.lustre.it_disposition = 0;
1362         it->d.lustre.it_data = NULL;
1363 ],[
1364         AC_MSG_RESULT([yes])
1365         AC_DEFINE(HAVE_VFS_INTENT_PATCHES, 1, [VFS intent patches are applied])
1366 ],[
1367         AC_MSG_RESULT([no])
1368 ])
1369 ])
1370
1371 AC_DEFUN([LC_S_TIME_GRAN],
1372 [AC_MSG_CHECKING([if super block has s_time_gran member])
1373 LB_LINUX_TRY_COMPILE([
1374         #include <linux/fs.h>
1375 ],[
1376         struct super_block sb;
1377
1378         return sb.s_time_gran;
1379 ],[
1380         AC_MSG_RESULT([yes])
1381         AC_DEFINE(HAVE_S_TIME_GRAN, 1, [super block has s_time_gran member])
1382 ],[
1383         AC_MSG_RESULT([no])
1384 ])
1385 ])
1386
1387 AC_DEFUN([LC_SB_TIME_GRAN],
1388 [AC_MSG_CHECKING([if kernel has old get_sb_time_gran])
1389 LB_LINUX_TRY_COMPILE([
1390         #include <linux/fs.h>
1391 ],[
1392         return get_sb_time_gran(NULL);
1393 ],[
1394         AC_MSG_RESULT([yes])
1395         AC_DEFINE(HAVE_SB_TIME_GRAN, 1, [kernel has old get_sb_time_gran])
1396 ],[
1397         AC_MSG_RESULT([no])
1398 ])
1399 ])
1400
1401
1402 # ~2.6.12 merge patch from oracle to convert tree_lock from spinlock to rwlock
1403 AC_DEFUN([LC_RW_TREE_LOCK],
1404 [AC_MSG_CHECKING([if kernel has tree_lock as rwlock])
1405 tmp_flags="$EXTRA_KCFLAGS"
1406 EXTRA_KCFLAGS="-Werror"
1407 LB_LINUX_TRY_COMPILE([
1408         #include <linux/fs.h>
1409 ],[
1410         struct address_space a;
1411
1412         write_lock(&a.tree_lock);
1413 ],[
1414         AC_MSG_RESULT([yes])
1415         AC_DEFINE(HAVE_RW_TREE_LOCK, 1, [kernel has tree_lock as rw_lock])
1416 ],[
1417         AC_MSG_RESULT([no])
1418 ])
1419 EXTRA_KCFLAGS="$tmp_flags"
1420 ])
1421
1422 AC_DEFUN([LC_CONST_ACL_SIZE],
1423 [AC_MSG_CHECKING([calc acl size])
1424 tmp_flags="$CFLAGS"
1425 CFLAGS="$CFLAGS -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 $EXTRA_KCFLAGS"
1426 AC_TRY_RUN([
1427 #define __KERNEL__
1428 #include <linux/autoconf.h>
1429 #include <linux/types.h>
1430 #undef __KERNEL__
1431 // block include
1432 #define __LINUX_POSIX_ACL_H
1433
1434 # ifdef CONFIG_FS_POSIX_ACL
1435 #  ifdef HAVE_XATTR_ACL
1436 #   include <linux/xattr_acl.h>
1437 #  endif
1438 #  ifdef HAVE_LINUX_POSIX_ACL_XATTR_H
1439 #   include <linux/posix_acl_xattr.h>
1440 #  endif
1441 # endif
1442
1443 #include <lustre_acl.h>
1444
1445 #include <stdio.h>
1446
1447 int main(void)
1448 {
1449     int size = mds_xattr_acl_size(LUSTRE_POSIX_ACL_MAX_ENTRIES);
1450     FILE *f = fopen("acl.size","w+");
1451     fprintf(f,"%d", size);
1452     fclose(f);
1453
1454     return 0;
1455 }
1456
1457 ],[
1458         acl_size=`cat acl.size`
1459         AC_MSG_RESULT([ACL size $acl_size])
1460         AC_DEFINE_UNQUOTED(XATTR_ACL_SIZE, AS_TR_SH([$acl_size]), [size of xattr acl])
1461 ],[
1462         AC_ERROR([ACL size can't computed])
1463 ])
1464 CFLAGS="$tmp_flags"
1465 ])
1466
1467 #
1468 # check for crypto API
1469 #
1470 AC_DEFUN([LC_ASYNC_BLOCK_CIPHER],
1471 [AC_MSG_CHECKING([if kernel has block cipher support])
1472 LB_LINUX_TRY_COMPILE([
1473         #include <linux/err.h>
1474         #include <linux/crypto.h>
1475 ],[
1476         struct crypto_blkcipher *tfm;
1477         tfm = crypto_alloc_blkcipher("aes", 0, 0 );
1478 ],[
1479         AC_MSG_RESULT([yes])
1480         AC_DEFINE(HAVE_ASYNC_BLOCK_CIPHER, 1, [kernel has block cipher support])
1481 ],[
1482         AC_MSG_RESULT([no])
1483 ])
1484 ])
1485
1486 #
1487 # check for struct hash_desc
1488 #
1489 AC_DEFUN([LC_STRUCT_HASH_DESC],
1490 [AC_MSG_CHECKING([if kernel has struct hash_desc])
1491 LB_LINUX_TRY_COMPILE([
1492         #include <linux/err.h>
1493         #include <linux/crypto.h>
1494 ],[
1495         struct hash_desc foo;
1496 ],[
1497         AC_MSG_RESULT([yes])
1498         AC_DEFINE(HAVE_STRUCT_HASH_DESC, 1, [kernel has struct hash_desc])
1499 ],[
1500         AC_MSG_RESULT([no])
1501 ])
1502 ])
1503
1504 #
1505 # check for struct blkcipher_desc
1506 #
1507 AC_DEFUN([LC_STRUCT_BLKCIPHER_DESC],
1508 [AC_MSG_CHECKING([if kernel has struct blkcipher_desc])
1509 LB_LINUX_TRY_COMPILE([
1510         #include <linux/err.h>
1511         #include <linux/crypto.h>
1512 ],[
1513         struct blkcipher_desc foo;
1514 ],[
1515         AC_MSG_RESULT([yes])
1516         AC_DEFINE(HAVE_STRUCT_BLKCIPHER_DESC, 1, [kernel has struct blkcipher_desc])
1517 ],[
1518         AC_MSG_RESULT([no])
1519 ])
1520 ])
1521
1522 #
1523 # check for FS_RENAME_DOES_D_MOVE flag
1524 #
1525 AC_DEFUN([LC_FS_RENAME_DOES_D_MOVE],
1526 [AC_MSG_CHECKING([if kernel has FS_RENAME_DOES_D_MOVE flag])
1527 LB_LINUX_TRY_COMPILE([
1528         #include <linux/fs.h>
1529 ],[
1530         int v = FS_RENAME_DOES_D_MOVE;
1531 ],[
1532         AC_MSG_RESULT([yes])
1533         AC_DEFINE(HAVE_FS_RENAME_DOES_D_MOVE, 1, [kernel has FS_RENAME_DOES_D_MOVE flag])
1534 ],[
1535         AC_MSG_RESULT([no])
1536 ])
1537 ])
1538
1539 # vfs_symlink seems to have started out with 3 args until 2.6.7 where a
1540 # "mode" argument was added, but then again, in some later version it was
1541 # removed
1542 AC_DEFUN([LC_4ARGS_VFS_SYMLINK],
1543 [AC_MSG_CHECKING([if vfs_symlink wants 4 args])
1544 LB_LINUX_TRY_COMPILE([
1545         #include <linux/fs.h>
1546 ],[
1547         struct inode *dir;
1548         struct dentry *dentry;
1549         const char *oldname = NULL;
1550         int mode = 0;
1551
1552         vfs_symlink(dir, dentry, oldname, mode);
1553 ],[
1554         AC_MSG_RESULT(yes)
1555         AC_DEFINE(HAVE_4ARGS_VFS_SYMLINK, 1,
1556                   [vfs_symlink wants 4 args])
1557 ],[
1558         AC_MSG_RESULT(no)
1559 ])
1560 ])
1561
1562 # Ensure stack size big than 8k in Lustre server
1563 AC_DEFUN([LC_STACK_SIZE],
1564 [AC_MSG_CHECKING([stack size big than 8k])
1565 LB_LINUX_TRY_COMPILE([
1566         #include <linux/thread_info.h>
1567 ],[
1568         #if THREAD_SIZE < 8192
1569         #error "stack size < 8192"
1570         #endif
1571 ],[
1572         AC_MSG_RESULT(yes)
1573 ],[
1574         AC_MSG_ERROR([Lustre requires that Linux is configured with at least a 8KB stack.])
1575 ])
1576 ])
1577
1578 #
1579 # LC_PROG_LINUX
1580 #
1581 # Lustre linux kernel checks
1582 #
1583 AC_DEFUN([LC_PROG_LINUX],
1584          [LC_LUSTRE_VERSION_H
1585          if test x$enable_server = xyes ; then
1586              AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
1587              LC_STACK_SIZE
1588              LC_CONFIG_BACKINGFS
1589          fi
1590          LC_CONFIG_PINGER
1591          LC_CONFIG_CHECKSUM
1592          LC_CONFIG_LIBLUSTRE_RECOVERY
1593          LC_CONFIG_HEALTH_CHECK_WRITE
1594          LC_CONFIG_LRU_RESIZE
1595          LC_QUOTA_MODULE
1596
1597          LC_TASK_PPTR
1598          # RHEL4 patches
1599          LC_EXPORT_TRUNCATE_COMPLETE
1600          LC_EXPORT_TRUNCATE_RANGE
1601          LC_EXPORT_D_REHASH_COND
1602          LC_EXPORT___D_REHASH
1603          LC_EXPORT_D_MOVE_LOCKED
1604          LC_EXPORT___D_MOVE
1605          LC_EXPORT_NODE_TO_CPUMASK
1606
1607          LC_FUNC_RELEASEPAGE_WITH_INT
1608          LC_HEADER_MM_INLINE
1609          LC_STRUCT_INODE
1610          LC_FUNC_REGISTER_CACHE
1611          LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
1612          LC_FUNC_DEV_SET_RDONLY
1613          LC_FUNC_FILEMAP_FDATAWRITE
1614          LC_STRUCT_STATFS
1615          LC_FUNC_PAGE_MAPPED
1616          LC_STRUCT_FILE_OPS_UNLOCKED_IOCTL
1617          LC_FILEMAP_POPULATE
1618          LC_D_ADD_UNIQUE
1619          LC_BIT_SPINLOCK_H
1620
1621          LC_XATTR_ACL
1622          LC_POSIX_ACL_XATTR_H
1623          LC_CONST_ACL_SIZE
1624
1625          LC_STRUCT_INTENT_FILE
1626
1627          LC_CAPA_CRYPTO
1628          LC_CONFIG_RMTCLIENT
1629          LC_CONFIG_GSS
1630          LC_FUNC_MS_FLOCK_LOCK
1631          LC_FUNC_HAVE_CAN_SLEEP_ARG
1632          LC_FUNC_F_OP_FLOCK
1633          LC_QUOTA_READ
1634          LC_COOKIE_FOLLOW_LINK
1635          LC_FUNC_RCU
1636          LC_PERCPU_COUNTER
1637          LC_QUOTA64
1638          LC_4ARGS_VFS_SYMLINK
1639          LC_NETLINK
1640
1641          # does the kernel have VFS intent patches?
1642          LC_VFS_INTENT_PATCHES
1643
1644          # ~2.6.11
1645          LC_S_TIME_GRAN
1646          LC_SB_TIME_GRAN
1647
1648          # 2.6.12
1649          LC_RW_TREE_LOCK
1650          LC_EXPORT_SYNCHRONIZE_RCU
1651
1652          # 2.6.15
1653          LC_INODE_I_MUTEX
1654
1655          # 2.6.16
1656          LC_SECURITY_PLUG  # for SLES10 SP2
1657
1658          # 2.6.17
1659          LC_INODE_IPRIVATE
1660          LC_DQUOTOFF_MUTEX
1661
1662          # 2.6.18
1663          LC_NR_PAGECACHE
1664          LC_STATFS_DENTRY_PARAM
1665          LC_VFS_KERN_MOUNT
1666          LC_INVALIDATEPAGE_RETURN_INT
1667          LC_UMOUNTBEGIN_HAS_VFSMOUNT
1668          LC_SEQ_LOCK
1669          LC_EXPORT_FILEMAP_FDATAWRITE_RANGE
1670          if test x$enable_server = xyes ; then
1671                 LC_EXPORT_INVALIDATE_MAPPING_PAGES
1672          fi
1673
1674          #2.6.18 + RHEL5 (fc6)
1675          LC_PG_FS_MISC
1676          LC_PAGE_CHECKED
1677
1678          # 2.6.19
1679          LC_INODE_BLKSIZE
1680          LC_VFS_READDIR_U64_INO
1681          LC_FILE_WRITEV
1682          LC_FILE_READV
1683
1684          # 2.6.20
1685          LC_CANCEL_DIRTY_PAGE
1686
1687          # raid5-zerocopy patch
1688          LC_PAGE_CONSTANT
1689
1690          # 2.6.22
1691          LC_INVALIDATE_BDEV_2ARG
1692          LC_ASYNC_BLOCK_CIPHER
1693          LC_STRUCT_HASH_DESC
1694          LC_STRUCT_BLKCIPHER_DESC
1695          LC_FS_RENAME_DOES_D_MOVE
1696          # 2.6.23
1697          LC_UNREGISTER_BLKDEV_RETURN_INT
1698          LC_KERNEL_SPLICE_READ
1699          LC_HAVE_EXPORTFS_H
1700 ])
1701
1702 #
1703 # LC_CONFIG_CLIENT_SERVER
1704 #
1705 # Build client/server sides of Lustre
1706 #
1707 AC_DEFUN([LC_CONFIG_CLIENT_SERVER],
1708 [AC_MSG_CHECKING([whether to build Lustre server support])
1709 AC_ARG_ENABLE([server],
1710         AC_HELP_STRING([--disable-server],
1711                         [disable Lustre server support]),
1712         [],[enable_server='yes'])
1713 AC_MSG_RESULT([$enable_server])
1714
1715 AC_MSG_CHECKING([whether to build Lustre client support])
1716 AC_ARG_ENABLE([client],
1717         AC_HELP_STRING([--disable-client],
1718                         [disable Lustre client support]),
1719         [],[enable_client='yes'])
1720 AC_MSG_RESULT([$enable_client])])
1721
1722 #
1723 # LC_CONFIG_LIBLUSTRE
1724 #
1725 # whether to build liblustre
1726 #
1727 AC_DEFUN([LC_CONFIG_LIBLUSTRE],
1728 [AC_MSG_CHECKING([whether to build Lustre library])
1729 AC_ARG_ENABLE([liblustre],
1730         AC_HELP_STRING([--disable-liblustre],
1731                         [disable building of Lustre library]),
1732         [],[enable_liblustre=$with_sysio])
1733 AC_MSG_RESULT([$enable_liblustre])
1734 # only build sysio if liblustre is built
1735 with_sysio="$enable_liblustre"
1736
1737 AC_MSG_CHECKING([whether to build liblustre tests])
1738 AC_ARG_ENABLE([liblustre-tests],
1739         AC_HELP_STRING([--enable-liblustre-tests],
1740                         [enable liblustre tests, if --disable-tests is used]),
1741         [],[enable_liblustre_tests=$enable_tests])
1742 if test x$enable_liblustre != xyes ; then
1743    enable_liblustre_tests='no'
1744 fi
1745 AC_MSG_RESULT([$enable_liblustre_tests])
1746
1747 AC_MSG_CHECKING([whether to enable liblustre acl])
1748 AC_ARG_ENABLE([liblustre-acl],
1749         AC_HELP_STRING([--disable-liblustre-acl],
1750                         [disable ACL support for liblustre]),
1751         [],[enable_liblustre_acl=yes])
1752 AC_MSG_RESULT([$enable_liblustre_acl])
1753 if test x$enable_liblustre_acl = xyes ; then
1754   AC_DEFINE(LIBLUSTRE_POSIX_ACL, 1, Liblustre Support ACL-enabled MDS)
1755 fi
1756
1757 #
1758 # --enable-mpitest
1759 #
1760 AC_ARG_ENABLE(mpitests,
1761         AC_HELP_STRING([--enable-mpitests=yes|no|mpicc wrapper],
1762                            [include mpi tests]),
1763         [
1764          enable_mpitests=yes
1765          case $enableval in
1766          yes)
1767                 MPICC_WRAPPER=mpicc
1768                 ;;
1769          no)
1770                 enable_mpitests=no
1771                 ;;
1772          *)
1773                 MPICC_WRAPPER=$enableval
1774                  ;;
1775          esac
1776         ],
1777         [
1778         MPICC_WRAPPER=mpicc
1779         enable_mpitests=yes
1780         ]
1781 )
1782
1783 if test x$enable_mpitests != xno; then
1784         AC_MSG_CHECKING([whether mpitests can be built])
1785         oldcc=$CC
1786         CC=$MPICC_WRAPPER
1787         AC_LINK_IFELSE(
1788             [AC_LANG_PROGRAM([[
1789                     #include <mpi.h>
1790                 ]],[[
1791                     int flag;
1792                     MPI_Initialized(&flag);
1793                 ]])],
1794             [
1795                     AC_MSG_RESULT([yes])
1796             ],[
1797                     AC_MSG_RESULT([no])
1798                     enable_mpitests=no
1799         ])
1800         CC=$oldcc
1801 fi
1802 AC_SUBST(MPICC_WRAPPER)
1803
1804 AC_MSG_NOTICE([Enabling Lustre configure options for libsysio])
1805 ac_configure_args="$ac_configure_args --with-lustre-hack --with-sockets"
1806
1807 LC_CONFIG_PINGER
1808 LC_CONFIG_LIBLUSTRE_RECOVERY
1809 ])
1810
1811 AC_DEFUN([LC_CONFIG_LRU_RESIZE],
1812 [AC_MSG_CHECKING([whether to enable lru self-adjusting])
1813 AC_ARG_ENABLE([lru_resize],
1814         AC_HELP_STRING([--enable-lru-resize],
1815                         [enable lru resize support]),
1816         [],[enable_lru_resize='yes'])
1817 AC_MSG_RESULT([$enable_lru_resize])
1818 if test x$enable_lru_resize != xno; then
1819    AC_DEFINE(HAVE_LRU_RESIZE_SUPPORT, 1, [Enable lru resize support])
1820 fi
1821 ])
1822
1823 #
1824 # LC_CONFIG_QUOTA
1825 #
1826 # whether to enable quota support global control
1827 #
1828 AC_DEFUN([LC_CONFIG_QUOTA],
1829 [AC_ARG_ENABLE([quota],
1830         AC_HELP_STRING([--enable-quota],
1831                         [enable quota support]),
1832         [],[enable_quota='yes'])
1833 ])
1834
1835 # whether to enable quota support(kernel modules)
1836 AC_DEFUN([LC_QUOTA_MODULE],
1837 [if test x$enable_quota != xno; then
1838     LB_LINUX_CONFIG([QUOTA],[
1839         enable_quota_module='yes'
1840         AC_DEFINE(HAVE_QUOTA_SUPPORT, 1, [Enable quota support])
1841     ],[
1842         enable_quota_module='no'
1843         AC_MSG_WARN([quota is not enabled because the kernel - lacks quota support])
1844     ])
1845 fi
1846 ])
1847
1848 AC_DEFUN([LC_QUOTA],
1849 [#check global
1850 LC_CONFIG_QUOTA
1851 #check for utils
1852 AC_CHECK_HEADER(sys/quota.h,
1853                 [AC_DEFINE(HAVE_SYS_QUOTA_H, 1, [Define to 1 if you have <sys/quota.h>.])],
1854                 [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
1855 ])
1856
1857 AC_DEFUN([LC_QUOTA_READ],
1858 [AC_MSG_CHECKING([if kernel supports quota_read])
1859 LB_LINUX_TRY_COMPILE([
1860         #include <linux/fs.h>
1861 ],[
1862         struct super_operations sp;
1863         void *i = (void *)sp.quota_read;
1864 ],[
1865         AC_MSG_RESULT([yes])
1866         AC_DEFINE(KERNEL_SUPPORTS_QUOTA_READ, 1, [quota_read found])
1867 ],[
1868         AC_MSG_RESULT([no])
1869 ])
1870 ])
1871
1872 #
1873 # LC_CONFIG_SPLIT
1874 #
1875 # whether to enable split support
1876 #
1877 AC_DEFUN([LC_CONFIG_SPLIT],
1878 [AC_MSG_CHECKING([whether to enable split support])
1879 AC_ARG_ENABLE([split],
1880         AC_HELP_STRING([--enable-split],
1881                         [enable split support]),
1882         [],[enable_split='no'])
1883 AC_MSG_RESULT([$enable_split])
1884 if test x$enable_split != xno; then
1885    AC_DEFINE(HAVE_SPLIT_SUPPORT, 1, [enable split support])
1886 fi
1887 ])
1888
1889 #
1890 # LC_COOKIE_FOLLOW_LINK
1891 #
1892 # kernel 2.6.13+ ->follow_link returns a cookie
1893 #
1894
1895 AC_DEFUN([LC_COOKIE_FOLLOW_LINK],
1896 [AC_MSG_CHECKING([if inode_operations->follow_link returns a cookie])
1897 LB_LINUX_TRY_COMPILE([
1898         #include <linux/fs.h>
1899         #include <linux/namei.h>
1900 ],[
1901         struct dentry dentry;
1902         struct nameidata nd;
1903
1904         dentry.d_inode->i_op->put_link(&dentry, &nd, NULL);
1905 ],[
1906         AC_DEFINE(HAVE_COOKIE_FOLLOW_LINK, 1, [inode_operations->follow_link returns a cookie])
1907         AC_MSG_RESULT([yes])
1908 ],[
1909         AC_MSG_RESULT([no])
1910 ])
1911 ])
1912
1913 #
1914 # LC_FUNC_RCU
1915 #
1916 # kernels prior than 2.6.0(?) have no RCU supported; in kernel 2.6.5(SUSE),
1917 # call_rcu takes three parameters.
1918 #
1919 AC_DEFUN([LC_FUNC_RCU],
1920 [AC_MSG_CHECKING([if kernel have RCU supported])
1921 LB_LINUX_TRY_COMPILE([
1922         #include <linux/rcupdate.h>
1923 ],[],[
1924         AC_DEFINE(HAVE_RCU, 1, [have RCU defined])
1925         AC_MSG_RESULT([yes])
1926
1927         AC_MSG_CHECKING([if call_rcu takes three parameters])
1928         LB_LINUX_TRY_COMPILE([
1929                 #include <linux/rcupdate.h>
1930         ],[
1931                 struct rcu_head rh;
1932                 call_rcu(&rh, (void (*)(struct rcu_head *))1, NULL);
1933         ],[
1934                 AC_DEFINE(HAVE_CALL_RCU_PARAM, 1, [call_rcu takes three parameters])
1935                 AC_MSG_RESULT([yes])
1936         ],[
1937                 AC_MSG_RESULT([no])
1938         ])
1939 ],[
1940         AC_MSG_RESULT([no])
1941 ])
1942 ])
1943
1944 #
1945 # LC_QUOTA64
1946 # linux kernel have 64-bit limits support
1947 #
1948 AC_DEFUN([LC_QUOTA64],
1949 [if test x$enable_quota_module = xyes -a x$enable_server = xyes ; then
1950         AC_MSG_CHECKING([if kernel has 64-bit quota limits support])
1951         LB_LINUX_TRY_COMPILE([
1952                 #include <linux/kernel.h>
1953                 #include <linux/fs.h>
1954                 #include <linux/quotaio_v2.h>
1955                 int versions[] = V2_INITQVERSIONS_R1;
1956                 struct v2_disk_dqblk_r1 dqblk_r1;
1957         ],[],[
1958                 AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
1959                 AC_MSG_RESULT([yes])
1960         ],[
1961                 LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
1962                         AC_MSG_ERROR([You have got no 64-bit kernel quota support.])
1963                 ],[])
1964                 AC_MSG_RESULT([no])
1965         ])
1966 fi
1967 ])
1968
1969 # LC_SECURITY_PLUG  # for SLES10 SP2
1970 # check security plug in sles10 sp2 kernel
1971 AC_DEFUN([LC_SECURITY_PLUG],
1972 [AC_MSG_CHECKING([If kernel has security plug support])
1973 LB_LINUX_TRY_COMPILE([
1974         #include <linux/fs.h>
1975 ],[
1976         struct dentry   *dentry;
1977         struct vfsmount *mnt;
1978         struct iattr    *iattr;
1979
1980         notify_change(dentry, mnt, iattr);
1981 ],[
1982         AC_MSG_RESULT(yes)
1983         AC_DEFINE(HAVE_SECURITY_PLUG, 1,
1984                 [SLES10 SP2 use extra parameter in vfs])
1985 ],[
1986         AC_MSG_RESULT(no)
1987 ])
1988 ])
1989
1990 AC_DEFUN([LC_PERCPU_COUNTER],
1991 [AC_MSG_CHECKING([if have struct percpu_counter defined])
1992 LB_LINUX_TRY_COMPILE([
1993         #include <linux/percpu_counter.h>
1994 ],[],[
1995         AC_DEFINE(HAVE_PERCPU_COUNTER, 1, [percpu_counter found])
1996         AC_MSG_RESULT([yes])
1997
1998         AC_MSG_CHECKING([if percpu_counter_inc takes the 2nd argument])
1999         LB_LINUX_TRY_COMPILE([
2000                 #include <linux/percpu_counter.h>
2001         ],[
2002                 struct percpu_counter c;
2003                 percpu_counter_init(&c, 0);
2004         ],[
2005                 AC_DEFINE(HAVE_PERCPU_2ND_ARG, 1, [percpu_counter_init has two
2006                                                    arguments])
2007                 AC_MSG_RESULT([yes])
2008         ],[
2009                 AC_MSG_RESULT([no])
2010         ])
2011 ],[
2012         AC_MSG_RESULT([no])
2013 ])
2014 ])
2015
2016 #
2017 # LC_NETLINK
2018 #
2019 # If we have netlink.h, and nlmsg_new takes 2 args
2020 #
2021 AC_DEFUN([LC_NETLINK],
2022 [AC_MSG_CHECKING([if netlink.h can be compiled])
2023 LB_LINUX_TRY_COMPILE([
2024         #include <net/netlink.h>
2025 ],[],[
2026         AC_MSG_RESULT([yes])
2027         AC_DEFINE(HAVE_NETLINK, 1, [net/netlink.h found])
2028
2029         AC_MSG_CHECKING([if nlmsg_new takes a 2nd argument])
2030         LB_LINUX_TRY_COMPILE([
2031                 #include <net/netlink.h>
2032         ],[
2033                 nlmsg_new(100, GFP_KERNEL);
2034         ],[
2035                 AC_MSG_RESULT([yes])
2036                 AC_DEFINE(HAVE_NETLINK_NL2, 1, [nlmsg_new takes 2 args])
2037         ],[
2038                 AC_MSG_RESULT([no])
2039         ])
2040 ],[
2041         AC_MSG_RESULT([no])
2042 ])
2043 ])
2044
2045 #
2046 # LC_CONFIGURE
2047 #
2048 # other configure checks
2049 #
2050 AC_DEFUN([LC_CONFIGURE],
2051 [LC_CONFIG_OBD_BUFFER_SIZE
2052
2053 if test $target_cpu == "i686" -o $target_cpu == "x86_64"; then
2054         CFLAGS="$CFLAGS -Werror"
2055 fi
2056
2057 # include/liblustre.h
2058 AC_CHECK_HEADERS([sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
2059
2060 # liblustre/llite_lib.h
2061 AC_CHECK_HEADERS([xtio.h file.h])
2062
2063 # liblustre/dir.c
2064 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
2065
2066 # liblustre/lutil.c
2067 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h catamount/data.h])
2068 AC_CHECK_FUNCS([inet_ntoa])
2069
2070 # libsysio/src/readlink.c
2071 LC_READLINK_SSIZE_T
2072
2073 # lvfs/prng.c - depends on linux/types.h from liblustre/dir.c
2074 AC_CHECK_HEADERS([linux/random.h], [], [],
2075                  [#ifdef HAVE_LINUX_TYPES_H
2076                   # include <linux/types.h>
2077                   #endif
2078                  ])
2079
2080 # utils/llverfs.c
2081 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
2082
2083 # check for -lz support
2084 ZLIB=""
2085 AC_CHECK_LIB([z],
2086              [adler32],
2087              [AC_CHECK_HEADERS([zlib.h],
2088                                [ZLIB="-lz"
2089                                 AC_DEFINE([HAVE_ADLER], 1,
2090                                           [support alder32 checksum type])],
2091                                [AC_MSG_WARN([No zlib-devel package found,
2092                                              unable to use adler32 checksum])])],
2093              [AC_MSG_WARN([No zlib package found, unable to use adler32 checksum])]
2094 )
2095 AC_SUBST(ZLIB)
2096
2097 # Super safe df
2098 AC_ARG_ENABLE([mindf],
2099       AC_HELP_STRING([--enable-mindf],
2100                       [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
2101       [],[])
2102 if test "$enable_mindf" = "yes" ;  then
2103       AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])
2104 fi
2105
2106 AC_ARG_ENABLE([fail_alloc],
2107         AC_HELP_STRING([--disable-fail-alloc],
2108                 [disable randomly alloc failure]),
2109         [],[enable_fail_alloc=yes])
2110 AC_MSG_CHECKING([whether to randomly failing memory alloc])
2111 AC_MSG_RESULT([$enable_fail_alloc])
2112 if test x$enable_fail_alloc != xno ; then
2113         AC_DEFINE([RANDOM_FAIL_ALLOC], 1, [enable randomly alloc failure])
2114 fi
2115
2116 AC_ARG_ENABLE([invariants],
2117         AC_HELP_STRING([--enable-invariants],
2118                 [enable invariant checking (cpu intensive)]),
2119         [],[])
2120 AC_MSG_CHECKING([whether to check invariants (expensive cpu-wise)])
2121 AC_MSG_RESULT([$enable_invariants])
2122 if test x$enable_invariants = xyes ; then
2123         AC_DEFINE([INVARIANT_CHECK], 1, [enable invariant checking])
2124 fi
2125
2126 AC_ARG_ENABLE([lu_ref],
2127         AC_HELP_STRING([--enable-lu_ref],
2128                 [enable lu_ref reference tracking code]),
2129         [],[])
2130 AC_MSG_CHECKING([whether to track references with lu_ref])
2131 AC_MSG_RESULT([$enable_lu_ref])
2132 if test x$enable_lu_ref = xyes ; then
2133         AC_DEFINE([USE_LU_REF], 1, [enable lu_ref reference tracking code])
2134 fi
2135
2136 ])
2137
2138 #
2139 # LC_CONDITIONALS
2140 #
2141 # AM_CONDITIONALS for lustre
2142 #
2143 AC_DEFUN([LC_CONDITIONALS],
2144 [AM_CONDITIONAL(LIBLUSTRE, test x$enable_liblustre = xyes)
2145 AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
2146 AM_CONDITIONAL(LIBLUSTRE_TESTS, test x$enable_liblustre_tests = xyes)
2147 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
2148 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
2149 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
2150 AM_CONDITIONAL(QUOTA, test x$enable_quota_module = xyes)
2151 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
2152 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
2153 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
2154 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
2155 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
2156 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
2157 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
2158 ])
2159
2160 #
2161 # LC_CONFIG_FILES
2162 #
2163 # files that should be generated with AC_OUTPUT
2164 #
2165 AC_DEFUN([LC_CONFIG_FILES],
2166 [AC_CONFIG_FILES([
2167 lustre/Makefile
2168 lustre/autoMakefile
2169 lustre/autoconf/Makefile
2170 lustre/contrib/Makefile
2171 lustre/doc/Makefile
2172 lustre/include/Makefile
2173 lustre/include/lustre_ver.h
2174 lustre/include/linux/Makefile
2175 lustre/include/lustre/Makefile
2176 lustre/kernel_patches/targets/2.6-vanilla.target
2177 lustre/kernel_patches/targets/2.6-rhel4.target
2178 lustre/kernel_patches/targets/2.6-rhel5.target
2179 lustre/kernel_patches/targets/2.6-fc5.target
2180 lustre/kernel_patches/targets/2.6-patchless.target
2181 lustre/kernel_patches/targets/2.6-sles10.target
2182 lustre/ldlm/Makefile
2183 lustre/fid/Makefile
2184 lustre/fid/autoMakefile
2185 lustre/liblustre/Makefile
2186 lustre/liblustre/tests/Makefile
2187 lustre/liblustre/tests/mpi/Makefile
2188 lustre/llite/Makefile
2189 lustre/llite/autoMakefile
2190 lustre/lclient/Makefile
2191 lustre/lov/Makefile
2192 lustre/lov/autoMakefile
2193 lustre/lvfs/Makefile
2194 lustre/lvfs/autoMakefile
2195 lustre/mdc/Makefile
2196 lustre/mdc/autoMakefile
2197 lustre/lmv/Makefile
2198 lustre/lmv/autoMakefile
2199 lustre/mds/Makefile
2200 lustre/mds/autoMakefile
2201 lustre/mdt/Makefile
2202 lustre/mdt/autoMakefile
2203 lustre/cmm/Makefile
2204 lustre/cmm/autoMakefile
2205 lustre/mdd/Makefile
2206 lustre/mdd/autoMakefile
2207 lustre/fld/Makefile
2208 lustre/fld/autoMakefile
2209 lustre/obdclass/Makefile
2210 lustre/obdclass/autoMakefile
2211 lustre/obdclass/linux/Makefile
2212 lustre/obdecho/Makefile
2213 lustre/obdecho/autoMakefile
2214 lustre/obdfilter/Makefile
2215 lustre/obdfilter/autoMakefile
2216 lustre/osc/Makefile
2217 lustre/osc/autoMakefile
2218 lustre/ost/Makefile
2219 lustre/ost/autoMakefile
2220 lustre/osd/Makefile
2221 lustre/osd/autoMakefile
2222 lustre/mgc/Makefile
2223 lustre/mgc/autoMakefile
2224 lustre/mgs/Makefile
2225 lustre/mgs/autoMakefile
2226 lustre/ptlrpc/Makefile
2227 lustre/ptlrpc/autoMakefile
2228 lustre/ptlrpc/gss/Makefile
2229 lustre/ptlrpc/gss/autoMakefile
2230 lustre/quota/Makefile
2231 lustre/quota/autoMakefile
2232 lustre/scripts/Makefile
2233 lustre/tests/Makefile
2234 lustre/tests/mpi/Makefile
2235 lustre/utils/Makefile
2236 lustre/utils/gss/Makefile
2237 ])
2238 case $lb_target_os in
2239         darwin)
2240                 AC_CONFIG_FILES([ lustre/obdclass/darwin/Makefile ])
2241                 ;;
2242 esac
2243
2244 ])