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