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