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