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