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