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