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