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