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