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