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