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