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