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