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