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