Whamcloud - gitweb
b=19808 fix d_obtain_alias() misuse due to compat macro.
[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.24 has bio_endio with 2 args
1187 AC_DEFUN([LC_BIO_ENDIO_2ARG],
1188 [AC_MSG_CHECKING([if kernel has bio_endio with 2 args])
1189 LB_LINUX_TRY_COMPILE([
1190         #include <linux/bio.h>
1191 ],[
1192         bio_endio(NULL, 0);
1193 ], [
1194         AC_MSG_RESULT([yes])
1195         AC_DEFINE(HAVE_BIO_ENDIO_2ARG, 1,
1196                 [kernel has bio_endio with 2 args])
1197 ],[
1198         AC_MSG_RESULT([no])
1199 ])
1200 ])
1201
1202 # 2.6.24 has new members in exports struct.
1203 AC_DEFUN([LC_FH_TO_DENTRY],
1204 [AC_MSG_CHECKING([if kernel has .fh_to_dentry member in export_operations struct])
1205 LB_LINUX_TRY_COMPILE([
1206 #ifdef HAVE_LINUX_EXPORTFS_H
1207         #include <linux/exportfs.h>
1208 #else
1209         #include <linux/fs.h>
1210 #endif
1211 ],[
1212         struct export_operations exp;
1213
1214         exp.fh_to_dentry   = NULL;
1215 ], [
1216         AC_MSG_RESULT([yes])
1217         AC_DEFINE(HAVE_FH_TO_DENTRY, 1,
1218                 [kernel has .fh_to_dentry member in export_operations struct])
1219 ],[
1220         AC_MSG_RESULT([no])
1221 ])
1222 ])
1223
1224 # 2.6.24 need linux/mm_types.h included
1225 AC_DEFUN([LC_HAVE_MMTYPES_H],
1226 [LB_CHECK_FILE([$LINUX/include/linux/mm_types.h], [
1227         AC_DEFINE(HAVE_LINUX_MMTYPES_H, 1,
1228                 [kernel has include/mm_types.h])
1229 ],[
1230         AC_MSG_RESULT([no])
1231 ])
1232 ])
1233
1234 # 2.6.24 removes long aged procfs entry -> deleted member
1235 AC_DEFUN([LC_PROCFS_DELETED],
1236 [AC_MSG_CHECKING([if kernel has deleted member in procfs entry struct])
1237 LB_LINUX_TRY_COMPILE([
1238         #include <linux/proc_fs.h>
1239 ],[
1240         struct proc_dir_entry pde;
1241
1242         pde.deleted   = NULL;
1243 ], [
1244         AC_MSG_RESULT([yes])
1245         AC_DEFINE(HAVE_PROCFS_DELETED, 1,
1246                 [kernel has deleted member in procfs entry struct])
1247 ],[
1248         AC_MSG_RESULT([no])
1249 ])
1250 ])
1251
1252 # 2.6.25 change define to inline
1253 AC_DEFUN([LC_MAPPING_CAP_WRITEBACK_DIRTY],
1254 [AC_MSG_CHECKING([if kernel have mapping_cap_writeback_dirty])
1255 LB_LINUX_TRY_COMPILE([
1256         #include <linux/backing-dev.h>
1257 ],[
1258         #ifndef mapping_cap_writeback_dirty
1259         mapping_cap_writeback_dirty(NULL);
1260         #endif
1261 ],[
1262         AC_MSG_RESULT([yes])
1263         AC_DEFINE(HAVE_MAPPING_CAP_WRITEBACK_DIRTY, 1,
1264                 [kernel have mapping_cap_writeback_dirty])
1265 ],[
1266         AC_MSG_RESULT([no])
1267 ])
1268 ])
1269
1270
1271
1272 # 2.6.26 isn't export set_fs_pwd and change paramter in fs struct
1273 AC_DEFUN([LC_FS_STRUCT_USE_PATH],
1274 [AC_MSG_CHECKING([fs_struct use path structure])
1275 LB_LINUX_TRY_COMPILE([
1276         #include <asm/atomic.h>
1277         #include <linux/spinlock.h>
1278         #include <linux/fs_struct.h>
1279 ],[
1280         struct path path;
1281         struct fs_struct fs;
1282
1283         fs.pwd = path;
1284 ], [
1285         AC_MSG_RESULT([yes])
1286         AC_DEFINE(HAVE_FS_STRUCT_USE_PATH, 1,
1287                 [fs_struct use path structure])
1288 ],[
1289         AC_MSG_RESULT([no])
1290 ])
1291 ])
1292
1293 #
1294 # LC_VFS_INTENT_PATCHES
1295 #
1296 # check if the kernel has the VFS intent patches
1297 AC_DEFUN([LC_VFS_INTENT_PATCHES],
1298 [AC_MSG_CHECKING([if the kernel has the VFS intent patches])
1299 LB_LINUX_TRY_COMPILE([
1300         #include <linux/fs.h>
1301         #include <linux/namei.h>
1302 ],[
1303         struct nameidata nd;
1304         struct lookup_intent *it;
1305
1306         it = &nd.intent;
1307         intent_init(it, IT_OPEN);
1308         it->d.lustre.it_disposition = 0;
1309         it->d.lustre.it_data = NULL;
1310 ],[
1311         AC_MSG_RESULT([yes])
1312         AC_DEFINE(HAVE_VFS_INTENT_PATCHES, 1, [VFS intent patches are applied])
1313 ],[
1314         AC_MSG_RESULT([no])
1315 ])
1316 ])
1317
1318 AC_DEFUN([LC_S_TIME_GRAN],
1319 [AC_MSG_CHECKING([if super block has s_time_gran member])
1320 LB_LINUX_TRY_COMPILE([
1321         #include <linux/fs.h>
1322 ],[
1323         struct super_block sb;
1324
1325         return sb.s_time_gran;
1326 ],[
1327         AC_MSG_RESULT([yes])
1328         AC_DEFINE(HAVE_S_TIME_GRAN, 1, [super block has s_time_gran member])
1329 ],[
1330         AC_MSG_RESULT([no])
1331 ])
1332 ])
1333
1334 AC_DEFUN([LC_SB_TIME_GRAN],
1335 [AC_MSG_CHECKING([if kernel has old get_sb_time_gran])
1336 LB_LINUX_TRY_COMPILE([
1337         #include <linux/fs.h>
1338 ],[
1339         return get_sb_time_gran(NULL);
1340 ],[
1341         AC_MSG_RESULT([yes])
1342         AC_DEFINE(HAVE_SB_TIME_GRAN, 1, [kernel has old get_sb_time_gran])
1343 ],[
1344         AC_MSG_RESULT([no])
1345 ])
1346 ])
1347
1348 #
1349 # LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
1350 #
1351 # Check for our patched grab_cache_page_nowait_gfp() function
1352 # after 2.6.29 we can emulate this using add_to_page_cache_lru()
1353 #
1354 AC_DEFUN([LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP],
1355 [LB_CHECK_SYMBOL_EXPORT([grab_cache_page_nowait_gfp],
1356 [mm/filemap.c],[
1357         AC_DEFINE(HAVE_GRAB_CACHE_PAGE_NOWAIT_GFP, 1,
1358                   [kernel exports grab_cache_page_nowait_gfp])
1359         ],
1360         [LB_CHECK_SYMBOL_EXPORT([add_to_page_cache_lru],
1361         [mm/filemap.c],[
1362                 AC_DEFINE(HAVE_ADD_TO_PAGE_CACHE_LRU, 1,
1363                         [kernel exports add_to_page_cache_lru])
1364         ],[
1365         ])
1366         ])
1367 ])
1368
1369 # ~2.6.12 merge patch from oracle to convert tree_lock from spinlock to rwlock
1370 AC_DEFUN([LC_RW_TREE_LOCK],
1371 [AC_MSG_CHECKING([if kernel has tree_lock as rwlock])
1372 tmp_flags="$EXTRA_KCFLAGS"
1373 EXTRA_KCFLAGS="-Werror"
1374 LB_LINUX_TRY_COMPILE([
1375         #include <linux/fs.h>
1376 ],[
1377         struct address_space a;
1378
1379         write_lock(&a.tree_lock);
1380 ],[
1381         AC_MSG_RESULT([yes])
1382         AC_DEFINE(HAVE_RW_TREE_LOCK, 1, [kernel has tree_lock as rw_lock])
1383 ],[
1384         AC_MSG_RESULT([no])
1385 ])
1386 EXTRA_KCFLAGS="$tmp_flags"
1387 ])
1388
1389 AC_DEFUN([LC_CONST_ACL_SIZE],
1390 [AC_MSG_CHECKING([calc acl size])
1391 tmp_flags="$CFLAGS"
1392 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"
1393 AC_TRY_RUN([
1394 #define __KERNEL__
1395 #include <linux/autoconf.h>
1396 #include <linux/types.h>
1397 #undef __KERNEL__
1398 // block include
1399 #define __LINUX_POSIX_ACL_H
1400
1401 # ifdef CONFIG_FS_POSIX_ACL
1402 #  ifdef HAVE_XATTR_ACL
1403 #   include <linux/xattr_acl.h>
1404 #  endif
1405 #  ifdef HAVE_LINUX_POSIX_ACL_XATTR_H
1406 #   include <linux/posix_acl_xattr.h>
1407 #  endif
1408 # endif
1409
1410 #include <lustre_acl.h>
1411
1412 #include <stdio.h>
1413
1414 int main(void)
1415 {
1416     int size = mds_xattr_acl_size(LUSTRE_POSIX_ACL_MAX_ENTRIES);
1417     FILE *f = fopen("acl.size","w+");
1418     fprintf(f,"%d", size);
1419     fclose(f);
1420
1421     return 0;
1422 }
1423
1424 ],[
1425         acl_size=`cat acl.size`
1426         AC_MSG_RESULT([ACL size $acl_size])
1427         AC_DEFINE_UNQUOTED(XATTR_ACL_SIZE, AS_TR_SH([$acl_size]), [size of xattr acl])
1428 ],[
1429         AC_ERROR([ACL size can't computed])
1430 ])
1431 CFLAGS="$tmp_flags"
1432 ])
1433
1434 #
1435 # check for crypto API
1436 #
1437 AC_DEFUN([LC_ASYNC_BLOCK_CIPHER],
1438 [AC_MSG_CHECKING([if kernel has block cipher support])
1439 LB_LINUX_TRY_COMPILE([
1440         #include <linux/err.h>
1441         #include <linux/crypto.h>
1442 ],[
1443         struct crypto_blkcipher *tfm;
1444         tfm = crypto_alloc_blkcipher("aes", 0, 0 );
1445 ],[
1446         AC_MSG_RESULT([yes])
1447         AC_DEFINE(HAVE_ASYNC_BLOCK_CIPHER, 1, [kernel has block cipher support])
1448 ],[
1449         AC_MSG_RESULT([no])
1450 ])
1451 ])
1452
1453 #
1454 # check for struct hash_desc
1455 #
1456 AC_DEFUN([LC_STRUCT_HASH_DESC],
1457 [AC_MSG_CHECKING([if kernel has struct hash_desc])
1458 LB_LINUX_TRY_COMPILE([
1459         #include <linux/err.h>
1460         #include <linux/crypto.h>
1461 ],[
1462         struct hash_desc foo;
1463 ],[
1464         AC_MSG_RESULT([yes])
1465         AC_DEFINE(HAVE_STRUCT_HASH_DESC, 1, [kernel has struct hash_desc])
1466 ],[
1467         AC_MSG_RESULT([no])
1468 ])
1469 ])
1470
1471 #
1472 # check for struct blkcipher_desc
1473 #
1474 AC_DEFUN([LC_STRUCT_BLKCIPHER_DESC],
1475 [AC_MSG_CHECKING([if kernel has struct blkcipher_desc])
1476 LB_LINUX_TRY_COMPILE([
1477         #include <linux/err.h>
1478         #include <linux/crypto.h>
1479 ],[
1480         struct blkcipher_desc foo;
1481 ],[
1482         AC_MSG_RESULT([yes])
1483         AC_DEFINE(HAVE_STRUCT_BLKCIPHER_DESC, 1, [kernel has struct blkcipher_desc])
1484 ],[
1485         AC_MSG_RESULT([no])
1486 ])
1487 ])
1488
1489 #
1490 # 2.6.19 check for FS_RENAME_DOES_D_MOVE flag
1491 #
1492 AC_DEFUN([LC_FS_RENAME_DOES_D_MOVE],
1493 [AC_MSG_CHECKING([if kernel has FS_RENAME_DOES_D_MOVE flag])
1494 LB_LINUX_TRY_COMPILE([
1495         #include <linux/fs.h>
1496 ],[
1497         int v = FS_RENAME_DOES_D_MOVE;
1498 ],[
1499         AC_MSG_RESULT([yes])
1500         AC_DEFINE(HAVE_FS_RENAME_DOES_D_MOVE, 1, [kernel has FS_RENAME_DOES_D_MOVE flag])
1501 ],[
1502         AC_MSG_RESULT([no])
1503 ])
1504 ])
1505
1506 #
1507 # LC_FUNC_F_OP_FLOCK
1508 #
1509 # rhel4.2 kernel has f_op->flock field
1510 #
1511 AC_DEFUN([LC_FUNC_F_OP_FLOCK],
1512 [AC_MSG_CHECKING([if struct file_operations has flock field])
1513 LB_LINUX_TRY_COMPILE([
1514         #include <linux/fs.h>
1515 ],[
1516         struct file_operations ll_file_operations_flock;
1517         ll_file_operations_flock.flock = NULL;
1518 ],[
1519         AC_DEFINE(HAVE_F_OP_FLOCK, 1,
1520                 [struct file_operations has flock field])
1521         AC_MSG_RESULT([yes])
1522 ],[
1523         AC_MSG_RESULT([no])
1524 ])
1525 ])
1526
1527 # vfs_symlink seems to have started out with 3 args until 2.6.7 where a
1528 # "mode" argument was added, but then again, in some later version it was
1529 # removed
1530 AC_DEFUN([LC_4ARGS_VFS_SYMLINK],
1531 [AC_MSG_CHECKING([if vfs_symlink wants 4 args])
1532 LB_LINUX_TRY_COMPILE([
1533         #include <linux/fs.h>
1534 ],[
1535         struct inode *dir;
1536         struct dentry *dentry;
1537         const char *oldname = NULL;
1538         int mode = 0;
1539
1540         vfs_symlink(dir, dentry, oldname, mode);
1541 ],[
1542         AC_MSG_RESULT(yes)
1543         AC_DEFINE(HAVE_4ARGS_VFS_SYMLINK, 1,
1544                   [vfs_symlink wants 4 args])
1545 ],[
1546         AC_MSG_RESULT(no)
1547 ])
1548 ])
1549
1550 # 2.6.23 has new shrinker API
1551 AC_DEFUN([LC_REGISTER_SHRINKER],
1552 [LB_CHECK_SYMBOL_EXPORT([register_shrinker],
1553 [mm/vmscan.c],[
1554         AC_DEFINE(HAVE_REGISTER_SHRINKER, 1,
1555                   [kernel exports register_shrinker])
1556 ],[
1557 ])
1558 ])
1559
1560 #2.6.27
1561 AC_DEFUN([LC_INODE_PERMISION_2ARGS],
1562 [AC_MSG_CHECKING([inode_operations->permission has two args])
1563 LB_LINUX_TRY_COMPILE([
1564         #include <linux/fs.h>
1565 ],[
1566         struct inode *inode;
1567
1568         inode->i_op->permission(NULL,0);
1569 ],[
1570         AC_DEFINE(HAVE_INODE_PERMISION_2ARGS, 1, 
1571                   [inode_operations->permission has two args])
1572         AC_MSG_RESULT([yes])
1573 ],[
1574         AC_MSG_RESULT([no])
1575 ])
1576 ])
1577
1578 # 2.6.27 has file_remove_suid instead of remove_suid
1579 AC_DEFUN([LC_FILE_REMOVE_SUID],
1580 [AC_MSG_CHECKING([kernel has file_remove_suid])
1581 LB_LINUX_TRY_COMPILE([
1582         #include <linux/fs.h>
1583 ],[
1584         file_remove_suid(NULL);
1585 ],[
1586         AC_DEFINE(HAVE_FILE_REMOVE_SUID, 1,
1587                   [kernel have file_remove_suid])
1588         AC_MSG_RESULT([yes])
1589 ],[
1590         AC_MSG_RESULT([no])
1591 ])
1592 ])
1593
1594 # 2.6.27 have new page locking API
1595 AC_DEFUN([LC_TRYLOCKPAGE],
1596 [AC_MSG_CHECKING([kernel uses trylock_page for page lock])
1597 LB_LINUX_TRY_COMPILE([
1598         #include <linux/pagemap.h>
1599 ],[
1600         trylock_page(NULL);
1601 ],[
1602         AC_DEFINE(HAVE_TRYLOCK_PAGE, 1,
1603                   [kernel uses trylock_page for page lock])
1604         AC_MSG_RESULT([yes])
1605 ],[
1606         AC_MSG_RESULT([no])
1607 ])
1608 ])
1609
1610 # vfs_symlink seems to have started out with 3 args until 2.6.7 where a
1611 # "mode" argument was added, but then again, in some later version it was
1612 # removed
1613 AC_DEFUN([LC_4ARGS_VFS_SYMLINK],
1614 [AC_MSG_CHECKING([if vfs_symlink wants 4 args])
1615 LB_LINUX_TRY_COMPILE([
1616         #include <linux/fs.h>
1617 ],[
1618         struct inode *dir;
1619         struct dentry *dentry;
1620         const char *oldname = NULL;
1621         int mode = 0;
1622
1623         vfs_symlink(dir, dentry, oldname, mode);
1624 ],[
1625         AC_MSG_RESULT(yes)
1626         AC_DEFINE(HAVE_4ARGS_VFS_SYMLINK, 1,
1627                   [vfs_symlink wants 4 args])
1628 ],[
1629         AC_MSG_RESULT(no)
1630 ])
1631 ])
1632
1633 # 2.6.27 sles11 remove the bi_hw_segments
1634 AC_DEFUN([LC_BI_HW_SEGMENTS],
1635 [AC_MSG_CHECKING([struct bio has a bi_hw_segments field])
1636 LB_LINUX_TRY_COMPILE([
1637         #include <linux/bio.h>
1638 ],[
1639         struct bio io;
1640         io.bi_hw_segments = 0;
1641 ],[
1642         AC_DEFINE(HAVE_BI_HW_SEGMENTS, 1,
1643                 [struct bio has a bi_hw_segments field])
1644         AC_MSG_RESULT([yes])
1645 ],[
1646         AC_MSG_RESULT([no])
1647 ])
1648 ])
1649
1650 #
1651 # 2.6.27 sles11 move the quotaio_v1{2}.h from include/linux to fs
1652 # 2.6.32 move the quotaio_v1{2}.h from fs to fs/quota
1653 AC_DEFUN([LC_HAVE_QUOTAIO_V1_H],
1654 [LB_CHECK_FILE([$LINUX/include/linux/quotaio_v1.h],[
1655         AC_DEFINE(HAVE_QUOTAIO_V1_H, 1,
1656                 [kernel has include/linux/quotaio_v1.h])
1657 ],[LB_CHECK_FILE([$LINUX/fs/quota/quotaio_v1.h],[
1658                AC_DEFINE(HAVE_FS_QUOTA_QUOTAIO_V1_H, 1,
1659                 [kernel has fs/quota/quotaio_v1.h])
1660 ],[
1661         AC_MSG_RESULT([no])
1662 ])
1663 ])
1664 ])
1665
1666 # sles10 sp2 need 5 parameter for vfs_symlink
1667 AC_DEFUN([LC_VFS_SYMLINK_5ARGS],
1668 [AC_MSG_CHECKING([vfs_symlink need 5 parameter])
1669 LB_LINUX_TRY_COMPILE([
1670         #include <linux/fs.h>
1671 ],[
1672         struct inode *dir = NULL;
1673         struct dentry *dentry = NULL;
1674         struct vfsmount *mnt = NULL;
1675         const char * path = NULL;
1676         vfs_symlink(dir, dentry, mnt, path, 0);
1677 ],[
1678         AC_DEFINE(HAVE_VFS_SYMLINK_5ARGS, 1,
1679                 [vfs_symlink need 5 parameteres])
1680         AC_MSG_RESULT([yes])
1681 ],[
1682         AC_MSG_RESULT([no])
1683 ])
1684 ])
1685
1686 # 2.6.27 removed the read_inode from super_operations.
1687 AC_DEFUN([LC_READ_INODE_IN_SBOPS],
1688 [AC_MSG_CHECKING([super_operations has a read_inode field])
1689 LB_LINUX_TRY_COMPILE([
1690         #include <linux/fs.h>
1691 ],[
1692         struct super_operations *sop;
1693         sop->read_inode(NULL);
1694 ],[
1695         AC_DEFINE(HAVE_READ_INODE_IN_SBOPS, 1,
1696                 [super_operations has a read_inode])
1697         AC_MSG_RESULT([yes])
1698 ],[
1699         AC_MSG_RESULT([no])
1700 ])
1701 ])
1702
1703 # 2.6.27 sles11 has sb_any_quota_active
1704 AC_DEFUN([LC_SB_ANY_QUOTA_ACTIVE],
1705 [AC_MSG_CHECKING([Kernel has sb_any_quota_active])
1706 LB_LINUX_TRY_COMPILE([
1707         #include <linux/quotaops.h>
1708 ],[
1709         sb_any_quota_active(NULL);
1710 ],[
1711         AC_DEFINE(HAVE_SB_ANY_QUOTA_ACTIVE, 1,
1712                 [Kernel has a sb_any_quota_active])
1713         AC_MSG_RESULT([yes])
1714 ],[
1715         AC_MSG_RESULT([no])
1716 ])
1717 ])
1718
1719 # 2.6.27 sles11 has sb_has_quota_active
1720 AC_DEFUN([LC_SB_HAS_QUOTA_ACTIVE],
1721 [AC_MSG_CHECKING([Kernel has sb_has_quota_active])
1722 LB_LINUX_TRY_COMPILE([
1723         #include <linux/quotaops.h>
1724 ],[
1725         sb_has_quota_active(NULL, 0);
1726 ],[
1727         AC_DEFINE(HAVE_SB_HAS_QUOTA_ACTIVE, 1,
1728                 [Kernel has a sb_has_quota_active])
1729         AC_MSG_RESULT([yes])
1730 ],[
1731         AC_MSG_RESULT([no])
1732 ])
1733 ])
1734
1735 # 2.6.27 has inode_permission instead of permisson
1736 AC_DEFUN([LC_EXPORT_INODE_PERMISSION],
1737 [LB_CHECK_SYMBOL_EXPORT([inode_permission],
1738 [fs/namei.c],[
1739 AC_DEFINE(HAVE_EXPORT_INODE_PERMISSION, 1,
1740             [inode_permission is exported by the kernel])
1741 ],[
1742 ])
1743 ])
1744
1745 # 2.6.27 use 5th parameter in quota_on for remount.
1746 AC_DEFUN([LC_QUOTA_ON_5ARGS],
1747 [AC_MSG_CHECKING([quota_on needs 5 parameters])
1748 LB_LINUX_TRY_COMPILE([
1749         #include <linux/quota.h>
1750 ],[
1751         struct quotactl_ops *qop;
1752         qop->quota_on(NULL, 0, 0, NULL, 0);
1753 ],[
1754         AC_DEFINE(HAVE_QUOTA_ON_5ARGS, 1,
1755                 [quota_on needs 5 paramters])
1756         AC_MSG_RESULT([yes])
1757 ],[
1758         AC_MSG_RESULT([no])
1759 ])
1760 ])
1761
1762 # 2.6.27 use 3th parameter in quota_off for remount.
1763 AC_DEFUN([LC_QUOTA_OFF_3ARGS],
1764 [AC_MSG_CHECKING([quota_off needs 3 parameters])
1765 LB_LINUX_TRY_COMPILE([
1766         #include <linux/quota.h>
1767 ],[
1768         struct quotactl_ops *qop;
1769         qop->quota_off(NULL, 0, 0);
1770 ],[
1771         AC_DEFINE(HAVE_QUOTA_OFF_3ARGS, 1,
1772                 [quota_off needs 3 paramters])
1773         AC_MSG_RESULT([yes])
1774 ],[
1775         AC_MSG_RESULT([no])
1776 ])
1777 ])
1778
1779 # 2.6.27 has vfs_dq_off inline function.
1780 AC_DEFUN([LC_VFS_DQ_OFF],
1781 [AC_MSG_CHECKING([vfs_dq_off is defined])
1782 LB_LINUX_TRY_COMPILE([
1783         #include <linux/quotaops.h>
1784 ],[
1785         vfs_dq_off(NULL, 0);
1786 ],[
1787         AC_DEFINE(HAVE_VFS_DQ_OFF, 1, [vfs_dq_off is defined])
1788         AC_MSG_RESULT([yes])
1789 ],[
1790         AC_MSG_RESULT([no])
1791 ])
1792 ])
1793
1794 #
1795 # LC_LINUX_FIEMAP_H
1796 #
1797 # If we have fiemap.h
1798 # after 2.6.27 use fiemap.h in include/linux
1799 #
1800 AC_DEFUN([LC_LINUX_FIEMAP_H],
1801 [LB_CHECK_FILE([$LINUX/include/linux/fiemap.h],[
1802         AC_MSG_CHECKING([if fiemap.h can be compiled])
1803         LB_LINUX_TRY_COMPILE([
1804                 #include <linux/types.h>
1805                 #include <linux/fiemap.h>
1806         ],[],[
1807                 AC_MSG_RESULT([yes])
1808                 AC_DEFINE(HAVE_LINUX_FIEMAP_H, 1, [Kernel has fiemap.h])
1809         ],[
1810                 AC_MSG_RESULT([no])
1811         ])
1812 ],
1813 [])
1814 ])
1815
1816 # LC_LOCK_MAP_ACQUIRE
1817 # after 2.6.27 lock_map_acquire replaces lock_acquire
1818 AC_DEFUN([LC_LOCK_MAP_ACQUIRE],
1819 [AC_MSG_CHECKING([if lock_map_acquire is defined])
1820 LB_LINUX_TRY_COMPILE([
1821         #include <linux/lockdep.h>
1822 ],[
1823         lock_map_acquire(NULL);
1824 ],[
1825         AC_MSG_RESULT(yes)
1826         AC_DEFINE(HAVE_LOCK_MAP_ACQUIRE, 1,
1827                 [lock_map_acquire is defined])
1828 ],[
1829         AC_MSG_RESULT(no)
1830 ])
1831 ])
1832
1833 #
1834 # LC_D_OBTAIN_ALIAS
1835 # starting from 2.6.28 kernel replaces d_alloc_anon() with
1836 # d_obtain_alias() for getting anonymous dentries
1837 #
1838 AC_DEFUN([LC_D_OBTAIN_ALIAS],
1839 [AC_MSG_CHECKING([d_obtain_alias exist in kernel])
1840 LB_LINUX_TRY_COMPILE([
1841         #include <linux/dcache.h>
1842 ],[
1843         d_obtain_alias(NULL);
1844 ],[
1845         AC_DEFINE(HAVE_D_OBTAIN_ALIAS, 1,
1846                 [d_obtain_alias exist in kernel])
1847         AC_MSG_RESULT([yes])
1848 ],[
1849         AC_MSG_RESULT([no])
1850 ])
1851 ])
1852
1853 # 2.6.31 replaces blk_queue_hardsect_size by blk_queue_logical_block_size function
1854 AC_DEFUN([LC_BLK_QUEUE_LOG_BLK_SIZE],
1855 [AC_MSG_CHECKING([if blk_queue_logical_block_size is defined])
1856 LB_LINUX_TRY_COMPILE([
1857         #include <linux/blkdev.h>
1858 ],[
1859         blk_queue_logical_block_size(NULL, 0);
1860 ],[
1861         AC_MSG_RESULT(yes)
1862         AC_DEFINE(HAVE_BLK_QUEUE_LOG_BLK_SIZE, 1,
1863                   [blk_queue_logical_block_size is defined])
1864 ],[
1865         AC_MSG_RESULT(no)
1866 ])
1867 ])
1868
1869 # 2.6.32 without DQUOT_INIT defined.
1870 AC_DEFUN([LC_DQUOT_INIT],
1871 [AC_MSG_CHECKING([if DQUOT_INIT is defined])
1872 LB_LINUX_TRY_COMPILE([
1873         #include <linux/quotaops.h>
1874 ],[
1875         DQUOT_INIT(NULL);
1876 ],[
1877         AC_MSG_RESULT(yes)
1878         AC_DEFINE(HAVE_DQUOT_INIT, 1,
1879                   [DQUOT_INIT is defined])
1880 ],[
1881         AC_MSG_RESULT(no)
1882 ])
1883 ])
1884
1885 # 2.6.32 add a limits member in struct request_queue.
1886 AC_DEFUN([LC_REQUEST_QUEUE_LIMITS],
1887 [AC_MSG_CHECKING([if request_queue has a limits field])
1888 LB_LINUX_TRY_COMPILE([
1889         #include <linux/blkdev.h>
1890 ],[
1891         struct request_queue rq;
1892         rq.limits.io_min = 0;
1893 ],[
1894         AC_MSG_RESULT(yes)
1895         AC_DEFINE(HAVE_REQUEST_QUEUE_LIMITS, 1,
1896                   [request_queue has a limits field])
1897 ],[
1898         AC_MSG_RESULT(no)
1899 ])
1900 ])
1901
1902 # 2.6.32 has new BDI interface.
1903 AC_DEFUN([LC_NEW_BACKING_DEV_INFO],
1904 [AC_MSG_CHECKING([if backing_dev_info has a wb_cnt field])
1905 LB_LINUX_TRY_COMPILE([
1906         #include <linux/backing-dev.h>
1907 ],[
1908         struct backing_dev_info bdi;
1909         bdi.wb_cnt = 0;
1910 ],[
1911         AC_MSG_RESULT(yes)
1912         AC_DEFINE(HAVE_NEW_BACKING_DEV_INFO, 1,
1913                   [backing_dev_info has a wb_cnt field])
1914 ],[
1915         AC_MSG_RESULT(no)
1916 ])
1917 ])
1918
1919 # 2.6.24 has bdi_init()/bdi_destroy() functions.
1920 AC_DEFUN([LC_EXPORT_BDI_INIT],
1921 [LB_CHECK_SYMBOL_EXPORT([bdi_init],
1922 [mm/backing-dev.c],[
1923         AC_DEFINE(HAVE_BDI_INIT, 1,
1924                 [bdi_init/bdi_destroy functions are present])
1925 ],[
1926 ])
1927 ])
1928
1929 #
1930 # LC_PROG_LINUX
1931 #
1932 # Lustre linux kernel checks
1933 #
1934 AC_DEFUN([LC_PROG_LINUX],
1935          [LC_LUSTRE_VERSION_H
1936          if test x$enable_server = xyes ; then
1937              AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
1938              LC_FUNC_DEV_SET_RDONLY
1939              LC_STACK_SIZE
1940              LC_CONFIG_BACKINGFS
1941          fi
1942          LC_CONFIG_PINGER
1943          LC_CONFIG_CHECKSUM
1944          LC_CONFIG_LIBLUSTRE_RECOVERY
1945          LC_CONFIG_HEALTH_CHECK_WRITE
1946          LC_CONFIG_LRU_RESIZE
1947          LC_QUOTA_MODULE
1948
1949          # RHEL4 patches
1950          LC_EXPORT_TRUNCATE_COMPLETE
1951          LC_EXPORT_TRUNCATE_RANGE
1952          LC_EXPORT_D_REHASH_COND
1953          LC_EXPORT___D_REHASH
1954          LC_EXPORT_D_MOVE_LOCKED
1955          LC_EXPORT___D_MOVE
1956          LC_EXPORT_NODE_TO_CPUMASK
1957
1958          LC_HEADER_LDISKFS_XATTR
1959          LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
1960          LC_STRUCT_STATFS
1961          LC_FILEMAP_POPULATE
1962          LC_D_ADD_UNIQUE
1963          LC_BIT_SPINLOCK_H
1964
1965          LC_XATTR_ACL
1966          LC_POSIX_ACL_XATTR_H
1967          LC_CONST_ACL_SIZE
1968
1969          LC_STRUCT_INTENT_FILE
1970
1971          LC_CAPA_CRYPTO
1972          LC_CONFIG_RMTCLIENT
1973          LC_CONFIG_GSS
1974          LC_FUNC_MS_FLOCK_LOCK
1975          LC_FUNC_HAVE_CAN_SLEEP_ARG
1976          LC_FUNC_F_OP_FLOCK
1977          LC_QUOTA_READ
1978          LC_COOKIE_FOLLOW_LINK
1979          LC_FUNC_RCU
1980          LC_PERCPU_COUNTER
1981          LC_TASK_CLENV_STORE
1982          LC_4ARGS_VFS_SYMLINK
1983
1984          # does the kernel have VFS intent patches?
1985          LC_VFS_INTENT_PATCHES
1986
1987          # ~2.6.11
1988          LC_S_TIME_GRAN
1989          LC_SB_TIME_GRAN
1990
1991          # 2.6.12
1992          LC_RW_TREE_LOCK
1993          LC_EXPORT_SYNCHRONIZE_RCU
1994
1995          # 2.6.15
1996          LC_INODE_I_MUTEX
1997
1998          # 2.6.16
1999          LC_SECURITY_PLUG  # for SLES10 SP2
2000
2001          # 2.6.17
2002          LC_INODE_IPRIVATE
2003          LC_DQUOTOFF_MUTEX
2004
2005          # 2.6.18
2006          LC_NR_PAGECACHE
2007          LC_STATFS_DENTRY_PARAM
2008          LC_VFS_KERN_MOUNT
2009          LC_INVALIDATEPAGE_RETURN_INT
2010          LC_UMOUNTBEGIN_HAS_VFSMOUNT
2011          LC_SEQ_LOCK
2012          LC_EXPORT_FILEMAP_FDATAWRITE_RANGE
2013          LC_FLUSH_OWNER_ID
2014          if test x$enable_server = xyes ; then
2015                 LC_EXPORT_INVALIDATE_MAPPING_PAGES
2016          fi
2017
2018          #2.6.18 + RHEL5 (fc6)
2019          LC_PG_FS_MISC
2020          LC_PAGE_CHECKED
2021          LC_LINUX_FIEMAP_H
2022
2023          # 2.6.19
2024          LC_INODE_BLKSIZE
2025          LC_VFS_READDIR_U64_INO
2026          LC_FILE_WRITEV
2027          LC_FILE_READV
2028
2029          # 2.6.20
2030          LC_CANCEL_DIRTY_PAGE
2031
2032          # raid5-zerocopy patch
2033          LC_PAGE_CONSTANT
2034
2035          # 2.6.22
2036          LC_INVALIDATE_BDEV_2ARG
2037          LC_ASYNC_BLOCK_CIPHER
2038          LC_STRUCT_HASH_DESC
2039          LC_STRUCT_BLKCIPHER_DESC
2040          LC_FS_RENAME_DOES_D_MOVE
2041
2042          # 2.6.23
2043          LC_UNREGISTER_BLKDEV_RETURN_INT
2044          LC_KERNEL_SPLICE_READ
2045          LC_KERNEL_SENDFILE
2046          LC_HAVE_EXPORTFS_H
2047          LC_VM_OP_FAULT
2048          LC_REGISTER_SHRINKER
2049   
2050          # 2.6.24
2051          LC_HAVE_MMTYPES_H
2052          LC_BIO_ENDIO_2ARG
2053          LC_FH_TO_DENTRY
2054          LC_PROCFS_DELETED
2055          LC_EXPORT_BDI_INIT
2056
2057          #2.6.25
2058          LC_MAPPING_CAP_WRITEBACK_DIRTY
2059   
2060          # 2.6.26
2061          LC_FS_STRUCT_USE_PATH
2062
2063          # 2.6.27
2064          LC_INODE_PERMISION_2ARGS
2065          LC_FILE_REMOVE_SUID
2066          LC_TRYLOCKPAGE
2067          LC_READ_INODE_IN_SBOPS
2068          LC_EXPORT_INODE_PERMISSION
2069          LC_QUOTA_ON_5ARGS
2070          LC_QUOTA_OFF_3ARGS
2071          LC_VFS_DQ_OFF
2072          LC_LOCK_MAP_ACQUIRE
2073
2074          # 2.6.27.15-2 sles11
2075          LC_BI_HW_SEGMENTS
2076          LC_HAVE_QUOTAIO_V1_H
2077          LC_VFS_SYMLINK_5ARGS
2078          LC_SB_ANY_QUOTA_ACTIVE
2079          LC_SB_HAS_QUOTA_ACTIVE
2080
2081          # 2.6.31
2082          LC_BLK_QUEUE_LOG_BLK_SIZE
2083
2084          # 2.6.32
2085          LC_DQUOT_INIT
2086          LC_REQUEST_QUEUE_LIMITS
2087          LC_NEW_BACKING_DEV_INFO
2088
2089          #
2090          if test x$enable_server = xyes ; then
2091                 if test x$enable_quota_module = xyes ; then
2092                         LC_QUOTA64    # must after LC_HAVE_QUOTAIO_V1_H
2093                 fi
2094          fi
2095 ])
2096
2097 #
2098 # LC_CONFIG_CLIENT_SERVER
2099 #
2100 # Build client/server sides of Lustre
2101 #
2102 AC_DEFUN([LC_CONFIG_CLIENT_SERVER],
2103 [AC_MSG_CHECKING([whether to build Lustre server support])
2104 AC_ARG_ENABLE([server],
2105         AC_HELP_STRING([--disable-server],
2106                         [disable Lustre server support]),
2107         [],[enable_server='yes'])
2108 AC_MSG_RESULT([$enable_server])
2109
2110 AC_MSG_CHECKING([whether to build Lustre client support])
2111 AC_ARG_ENABLE([client],
2112         AC_HELP_STRING([--disable-client],
2113                         [disable Lustre client support]),
2114         [],[enable_client='yes'])
2115 AC_MSG_RESULT([$enable_client])])
2116
2117 #
2118 # LC_CONFIG_LIBLUSTRE
2119 #
2120 # whether to build liblustre
2121 #
2122 AC_DEFUN([LC_CONFIG_LIBLUSTRE],
2123 [AC_MSG_CHECKING([whether to build Lustre library])
2124 AC_ARG_ENABLE([liblustre],
2125         AC_HELP_STRING([--disable-liblustre],
2126                         [disable building of Lustre library]),
2127         [],[enable_liblustre=$with_sysio])
2128 AC_MSG_RESULT([$enable_liblustre])
2129 # only build sysio if liblustre is built
2130 with_sysio="$enable_liblustre"
2131
2132 AC_MSG_CHECKING([whether to build liblustre tests])
2133 AC_ARG_ENABLE([liblustre-tests],
2134         AC_HELP_STRING([--enable-liblustre-tests],
2135                         [enable liblustre tests, if --disable-tests is used]),
2136         [],[enable_liblustre_tests=$enable_tests])
2137 if test x$enable_liblustre != xyes ; then
2138    enable_liblustre_tests='no'
2139 fi
2140 AC_MSG_RESULT([$enable_liblustre_tests])
2141
2142 AC_MSG_CHECKING([whether to enable liblustre acl])
2143 AC_ARG_ENABLE([liblustre-acl],
2144         AC_HELP_STRING([--disable-liblustre-acl],
2145                         [disable ACL support for liblustre]),
2146         [],[enable_liblustre_acl=yes])
2147 AC_MSG_RESULT([$enable_liblustre_acl])
2148 if test x$enable_liblustre_acl = xyes ; then
2149   AC_DEFINE(LIBLUSTRE_POSIX_ACL, 1, Liblustre Support ACL-enabled MDS)
2150 fi
2151
2152 # 2.6.29 change prepare/commit_write to write_begin/end
2153 AC_DEFUN([LC_WRITE_BEGIN_END],
2154 [AC_MSG_CHECKING([if kernel has .write_begin/end])
2155 LB_LINUX_TRY_COMPILE([
2156         #include <linux/fs.h>
2157         #include <linux/pagemap.h>
2158 #ifdef HAVE_LINUX_MMTYPES_H
2159         #include <linux/mm_types.h>
2160 #endif
2161 ],[
2162         struct address_space_operations aops;
2163         struct page *page;
2164
2165         aops.write_begin = NULL;
2166         aops.write_end = NULL;
2167         page = grab_cache_page_write_begin(NULL, 0, 0);
2168 ], [
2169         AC_MSG_RESULT([yes])
2170         AC_DEFINE(HAVE_KERNEL_WRITE_BEGIN_END, 1,
2171                 [kernel has .write_begin/end])
2172 ],[
2173         AC_MSG_RESULT([no])
2174 ])
2175 ])
2176
2177 # 2.6.29 blkdev_put has 2 arguments
2178 AC_DEFUN([LC_BLKDEV_PUT_2ARGS],
2179 [AC_MSG_CHECKING([blkdev_put needs 2 parameters])
2180 LB_LINUX_TRY_COMPILE([
2181         #include <linux/fs.h>
2182 ],[
2183         blkdev_put(NULL, 0);
2184 ],[
2185         AC_DEFINE(HAVE_BLKDEV_PUT_2ARGS, 1,
2186                 [blkdev_put needs 2 paramters])
2187         AC_MSG_RESULT([yes])
2188 ],[
2189         AC_MSG_RESULT([no])
2190 ])
2191 ])
2192
2193 # 2.6.29 dentry_open has 4 arguments
2194 AC_DEFUN([LC_DENTRY_OPEN_4ARGS],
2195 [AC_MSG_CHECKING([dentry_open needs 4 parameters])
2196 LB_LINUX_TRY_COMPILE([
2197         #include <linux/fs.h>
2198 ],[
2199         dentry_open(NULL, NULL, 0, NULL);
2200 ],[
2201         AC_DEFINE(HAVE_DENTRY_OPEN_4ARGS, 1,
2202                 [dentry_open needs 4 paramters])
2203         AC_MSG_RESULT([yes])
2204 ],[
2205         AC_MSG_RESULT([no])
2206 ])
2207 ])
2208
2209 #
2210 # --enable-mpitest
2211 #
2212 AC_ARG_ENABLE(mpitests,
2213         AC_HELP_STRING([--enable-mpitests=yes|no|mpicc wrapper],
2214                            [include mpi tests]),
2215         [
2216          enable_mpitests=yes
2217          case $enableval in
2218          yes)
2219                 MPICC_WRAPPER=mpicc
2220                 ;;
2221          no)
2222                 enable_mpitests=no
2223                 ;;
2224          *)
2225                 MPICC_WRAPPER=$enableval
2226                  ;;
2227          esac
2228         ],
2229         [
2230         MPICC_WRAPPER=mpicc
2231         enable_mpitests=yes
2232         ]
2233 )
2234
2235 if test x$enable_mpitests != xno; then
2236         AC_MSG_CHECKING([whether mpitests can be built])
2237         oldcc=$CC
2238         CC=$MPICC_WRAPPER
2239         AC_LINK_IFELSE(
2240             [AC_LANG_PROGRAM([[
2241                     #include <mpi.h>
2242                 ]],[[
2243                     int flag;
2244                     MPI_Initialized(&flag);
2245                 ]])],
2246             [
2247                     AC_MSG_RESULT([yes])
2248             ],[
2249                     AC_MSG_RESULT([no])
2250                     enable_mpitests=no
2251         ])
2252         CC=$oldcc
2253 fi
2254 AC_SUBST(MPICC_WRAPPER)
2255
2256 AC_MSG_NOTICE([Enabling Lustre configure options for libsysio])
2257 ac_configure_args="$ac_configure_args --with-lustre-hack --with-sockets"
2258
2259 LC_CONFIG_PINGER
2260 LC_CONFIG_LIBLUSTRE_RECOVERY
2261 ])
2262
2263 AC_DEFUN([LC_CONFIG_LRU_RESIZE],
2264 [AC_MSG_CHECKING([whether to enable lru self-adjusting])
2265 AC_ARG_ENABLE([lru_resize],
2266         AC_HELP_STRING([--enable-lru-resize],
2267                         [enable lru resize support]),
2268         [],[enable_lru_resize='yes'])
2269 AC_MSG_RESULT([$enable_lru_resize])
2270 if test x$enable_lru_resize != xno; then
2271    AC_DEFINE(HAVE_LRU_RESIZE_SUPPORT, 1, [Enable lru resize support])
2272 fi
2273 ])
2274
2275 #
2276 # LC_CONFIG_QUOTA
2277 #
2278 # whether to enable quota support global control
2279 #
2280 AC_DEFUN([LC_CONFIG_QUOTA],
2281 [AC_ARG_ENABLE([quota],
2282         AC_HELP_STRING([--enable-quota],
2283                         [enable quota support]),
2284         [],[enable_quota='yes'])
2285 ])
2286
2287 # whether to enable quota support(kernel modules)
2288 AC_DEFUN([LC_QUOTA_MODULE],
2289 [if test x$enable_quota != xno; then
2290     LB_LINUX_CONFIG([QUOTA],[
2291         enable_quota_module='yes'
2292         AC_DEFINE(HAVE_QUOTA_SUPPORT, 1, [Enable quota support])
2293     ],[
2294         enable_quota_module='no'
2295         AC_MSG_WARN([quota is not enabled because the kernel - lacks quota support])
2296     ])
2297 fi
2298 ])
2299
2300 AC_DEFUN([LC_QUOTA],
2301 [#check global
2302 LC_CONFIG_QUOTA
2303 #check for utils
2304 AC_CHECK_HEADER(sys/quota.h,
2305                 [AC_DEFINE(HAVE_SYS_QUOTA_H, 1, [Define to 1 if you have <sys/quota.h>.])],
2306                 [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
2307 ])
2308
2309 AC_DEFUN([LC_QUOTA_READ],
2310 [AC_MSG_CHECKING([if kernel supports quota_read])
2311 LB_LINUX_TRY_COMPILE([
2312         #include <linux/fs.h>
2313 ],[
2314         struct super_operations sp;
2315         void *i = (void *)sp.quota_read;
2316 ],[
2317         AC_MSG_RESULT([yes])
2318         AC_DEFINE(KERNEL_SUPPORTS_QUOTA_READ, 1, [quota_read found])
2319 ],[
2320         AC_MSG_RESULT([no])
2321 ])
2322 ])
2323
2324 #
2325 # LC_CONFIG_SPLIT
2326 #
2327 # whether to enable split support
2328 #
2329 AC_DEFUN([LC_CONFIG_SPLIT],
2330 [AC_MSG_CHECKING([whether to enable split support])
2331 AC_ARG_ENABLE([split],
2332         AC_HELP_STRING([--enable-split],
2333                         [enable split support]),
2334         [],[enable_split='no'])
2335 AC_MSG_RESULT([$enable_split])
2336 if test x$enable_split != xno; then
2337    AC_DEFINE(HAVE_SPLIT_SUPPORT, 1, [enable split support])
2338 fi
2339 ])
2340
2341 #
2342 # LC_COOKIE_FOLLOW_LINK
2343 #
2344 # kernel 2.6.13+ ->follow_link returns a cookie
2345 #
2346
2347 AC_DEFUN([LC_COOKIE_FOLLOW_LINK],
2348 [AC_MSG_CHECKING([if inode_operations->follow_link returns a cookie])
2349 LB_LINUX_TRY_COMPILE([
2350         #include <linux/fs.h>
2351         #include <linux/namei.h>
2352 ],[
2353         struct dentry dentry;
2354         struct nameidata nd;
2355
2356         dentry.d_inode->i_op->put_link(&dentry, &nd, NULL);
2357 ],[
2358         AC_DEFINE(HAVE_COOKIE_FOLLOW_LINK, 1, [inode_operations->follow_link returns a cookie])
2359         AC_MSG_RESULT([yes])
2360 ],[
2361         AC_MSG_RESULT([no])
2362 ])
2363 ])
2364
2365 #
2366 # LC_FUNC_RCU
2367 #
2368 # kernels prior than 2.6.0(?) have no RCU supported; in kernel 2.6.5(SUSE),
2369 # call_rcu takes three parameters.
2370 #
2371 AC_DEFUN([LC_FUNC_RCU],
2372 [AC_MSG_CHECKING([if kernel have RCU supported])
2373 LB_LINUX_TRY_COMPILE([
2374         #include <linux/rcupdate.h>
2375 ],[],[
2376         AC_DEFINE(HAVE_RCU, 1, [have RCU defined])
2377         AC_MSG_RESULT([yes])
2378
2379         AC_MSG_CHECKING([if call_rcu takes three parameters])
2380         LB_LINUX_TRY_COMPILE([
2381                 #include <linux/rcupdate.h>
2382         ],[
2383                 struct rcu_head rh;
2384                 call_rcu(&rh, (void (*)(struct rcu_head *))1, NULL);
2385         ],[
2386                 AC_DEFINE(HAVE_CALL_RCU_PARAM, 1, [call_rcu takes three parameters])
2387                 AC_MSG_RESULT([yes])
2388         ],[
2389                 AC_MSG_RESULT([no])
2390         ])
2391
2392 ],[
2393         AC_MSG_RESULT([no])
2394 ])
2395 ])
2396
2397 #
2398 # LC_QUOTA64
2399 # linux kernel have 64-bit limits support
2400 #
2401 AC_DEFUN([LC_QUOTA64],[
2402         AC_MSG_CHECKING([if kernel has 64-bit quota limits support])
2403 tmp_flags="$EXTRA_KCFLAGS"
2404 EXTRA_KCFLAGS="-I$LINUX/fs"
2405         LB_LINUX_TRY_COMPILE([
2406                 #include <linux/kernel.h>
2407                 #include <linux/fs.h>
2408                 #ifdef HAVE_QUOTAIO_V1_H
2409                 # include <linux/quotaio_v2.h>
2410                 int versions[] = V2_INITQVERSIONS_R1;
2411                 struct v2_disk_dqblk_r1 dqblk_r1;
2412                 #else
2413                 # ifdef HAVE_FS_QUOTA_QUOTAIO_V1_H
2414                 #  include <quota/quotaio_v2.h>
2415                 # else
2416                 #  include <quotaio_v2.h>
2417                 # endif
2418                 struct v2r1_disk_dqblk dqblk_r1;
2419                 #endif
2420         ],[],[
2421                 AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
2422                 AC_MSG_RESULT([yes])
2423         ],[
2424                 LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
2425                         AC_MSG_ERROR([You have got no 64-bit kernel quota support.])
2426                 ],[])
2427                 AC_MSG_RESULT([no])
2428         ])
2429 EXTRA_KCFLAGS=$tmp_flags
2430 ])
2431
2432 # LC_SECURITY_PLUG  # for SLES10 SP2
2433 # check security plug in sles10 sp2 kernel
2434 AC_DEFUN([LC_SECURITY_PLUG],
2435 [AC_MSG_CHECKING([If kernel has security plug support])
2436 LB_LINUX_TRY_COMPILE([
2437         #include <linux/fs.h>
2438 ],[
2439         struct dentry   *dentry;
2440         struct vfsmount *mnt;
2441         struct iattr    *iattr;
2442
2443         notify_change(dentry, mnt, iattr);
2444 ],[
2445         AC_MSG_RESULT(yes)
2446         AC_DEFINE(HAVE_SECURITY_PLUG, 1,
2447                 [SLES10 SP2 use extra parameter in vfs])
2448 ],[
2449         AC_MSG_RESULT(no)
2450 ])
2451 ])
2452
2453 AC_DEFUN([LC_PERCPU_COUNTER],
2454 [AC_MSG_CHECKING([if have struct percpu_counter defined])
2455 LB_LINUX_TRY_COMPILE([
2456         #include <linux/percpu_counter.h>
2457 ],[],[
2458         AC_DEFINE(HAVE_PERCPU_COUNTER, 1, [percpu_counter found])
2459         AC_MSG_RESULT([yes])
2460
2461         AC_MSG_CHECKING([if percpu_counter_inc takes the 2nd argument])
2462         LB_LINUX_TRY_COMPILE([
2463                 #include <linux/percpu_counter.h>
2464         ],[
2465                 struct percpu_counter c;
2466                 percpu_counter_init(&c, 0);
2467         ],[
2468                 AC_DEFINE(HAVE_PERCPU_2ND_ARG, 1, [percpu_counter_init has two
2469                                                    arguments])
2470                 AC_MSG_RESULT([yes])
2471         ],[
2472                 AC_MSG_RESULT([no])
2473         ])
2474 ],[
2475         AC_MSG_RESULT([no])
2476 ])
2477 ])
2478
2479 AC_DEFUN([LC_TASK_CLENV_TUX_INFO],
2480 [AC_MSG_CHECKING([tux_info])
2481 LB_LINUX_TRY_COMPILE([
2482         #include <linux/sched.h>
2483 ],[
2484         struct task_struct task;
2485         &task.tux_info;
2486 ],[
2487         AC_MSG_RESULT([yes])
2488         AC_DEFINE(LL_TASK_CL_ENV, tux_info, [have tux_info])
2489         have_task_clenv_store='yes'
2490 ],[
2491         AC_MSG_RESULT([no])
2492 ])
2493 ])
2494
2495 AC_DEFUN([LC_TASK_CLENV_STORE],
2496 [
2497         AC_MSG_CHECKING([if we can store cl_env in task_struct])
2498         if test x$have_task_clenv_store != xyes ; then
2499                 LC_TASK_CLENV_TUX_INFO
2500         fi
2501 ])
2502
2503 #
2504 # LC_CONFIGURE
2505 #
2506 # other configure checks
2507 #
2508 AC_DEFUN([LC_CONFIGURE],
2509 [LC_CONFIG_OBD_BUFFER_SIZE
2510
2511 if test $target_cpu == "i686" -o $target_cpu == "x86_64"; then
2512         CFLAGS="$CFLAGS -Werror"
2513 fi
2514
2515 # include/liblustre.h
2516 AC_CHECK_HEADERS([sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
2517
2518 # liblustre/llite_lib.h
2519 AC_CHECK_HEADERS([xtio.h file.h])
2520
2521 # liblustre/dir.c
2522 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
2523
2524 # liblustre/lutil.c
2525 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h catamount/data.h])
2526 AC_CHECK_FUNCS([inet_ntoa])
2527
2528 # libsysio/src/readlink.c
2529 LC_READLINK_SSIZE_T
2530
2531 # lvfs/prng.c - depends on linux/types.h from liblustre/dir.c
2532 AC_CHECK_HEADERS([linux/random.h], [], [],
2533                  [#ifdef HAVE_LINUX_TYPES_H
2534                   # include <linux/types.h>
2535                   #endif
2536                  ])
2537
2538 # utils/llverfs.c
2539 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
2540
2541 # check for -lz support
2542 ZLIB=""
2543 AC_CHECK_LIB([z],
2544              [adler32],
2545              [AC_CHECK_HEADERS([zlib.h],
2546                                [ZLIB="-lz"
2547                                 AC_DEFINE([HAVE_ADLER], 1,
2548                                           [support alder32 checksum type])],
2549                                [AC_MSG_WARN([No zlib-devel package found,
2550                                              unable to use adler32 checksum])])],
2551              [AC_MSG_WARN([No zlib package found, unable to use adler32 checksum])]
2552 )
2553 AC_SUBST(ZLIB)
2554
2555 # Super safe df
2556 AC_ARG_ENABLE([mindf],
2557       AC_HELP_STRING([--enable-mindf],
2558                       [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
2559       [],[])
2560 if test "$enable_mindf" = "yes" ;  then
2561       AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])
2562 fi
2563
2564 AC_ARG_ENABLE([fail_alloc],
2565         AC_HELP_STRING([--disable-fail-alloc],
2566                 [disable randomly alloc failure]),
2567         [],[enable_fail_alloc=yes])
2568 AC_MSG_CHECKING([whether to randomly failing memory alloc])
2569 AC_MSG_RESULT([$enable_fail_alloc])
2570 if test x$enable_fail_alloc != xno ; then
2571         AC_DEFINE([RANDOM_FAIL_ALLOC], 1, [enable randomly alloc failure])
2572 fi
2573
2574 AC_ARG_ENABLE([invariants],
2575         AC_HELP_STRING([--enable-invariants],
2576                 [enable invariant checking (cpu intensive)]),
2577         [],[])
2578 AC_MSG_CHECKING([whether to check invariants (expensive cpu-wise)])
2579 AC_MSG_RESULT([$enable_invariants])
2580 if test x$enable_invariants = xyes ; then
2581         AC_DEFINE([INVARIANT_CHECK], 1, [enable invariant checking])
2582 fi
2583
2584 AC_ARG_ENABLE([lu_ref],
2585         AC_HELP_STRING([--enable-lu_ref],
2586                 [enable lu_ref reference tracking code]),
2587         [],[])
2588 AC_MSG_CHECKING([whether to track references with lu_ref])
2589 AC_MSG_RESULT([$enable_lu_ref])
2590 if test x$enable_lu_ref = xyes ; then
2591         AC_DEFINE([USE_LU_REF], 1, [enable lu_ref reference tracking code])
2592 fi
2593
2594 AC_ARG_ENABLE([pgstate-track],
2595               AC_HELP_STRING([--enable-pgstate-track],
2596                              [enable page state tracking]),
2597               [enable_pgstat_track='yes'],[])
2598 AC_MSG_CHECKING([whether to enable page state tracking])
2599 AC_MSG_RESULT([$enable_pgstat_track])
2600 if test x$enable_pgstat_track = xyes ; then
2601         AC_DEFINE([LUSTRE_PAGESTATE_TRACKING], 1,
2602                   [enable page state tracking code])
2603 fi
2604
2605          #2.6.29
2606          LC_WRITE_BEGIN_END
2607          LC_D_OBTAIN_ALIAS
2608          LC_BLKDEV_PUT_2ARGS
2609          LC_DENTRY_OPEN_4ARGS
2610
2611 ])
2612
2613 #
2614 # LC_CONDITIONALS
2615 #
2616 # AM_CONDITIONALS for lustre
2617 #
2618 AC_DEFUN([LC_CONDITIONALS],
2619 [AM_CONDITIONAL(LIBLUSTRE, test x$enable_liblustre = xyes)
2620 AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
2621 AM_CONDITIONAL(LIBLUSTRE_TESTS, test x$enable_liblustre_tests = xyes)
2622 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
2623 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
2624 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
2625 AM_CONDITIONAL(QUOTA, test x$enable_quota_module = xyes)
2626 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
2627 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
2628 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
2629 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
2630 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
2631 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
2632 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
2633 ])
2634
2635 #
2636 # LC_CONFIG_FILES
2637 #
2638 # files that should be generated with AC_OUTPUT
2639 #
2640 AC_DEFUN([LC_CONFIG_FILES],
2641 [AC_CONFIG_FILES([
2642 lustre/Makefile
2643 lustre/autoMakefile
2644 lustre/autoconf/Makefile
2645 lustre/conf/Makefile
2646 lustre/contrib/Makefile
2647 lustre/doc/Makefile
2648 lustre/include/Makefile
2649 lustre/include/lustre_ver.h
2650 lustre/include/linux/Makefile
2651 lustre/include/lustre/Makefile
2652 lustre/kernel_patches/targets/2.6-rhel5.target
2653 lustre/kernel_patches/targets/2.6-sles10.target
2654 lustre/kernel_patches/targets/2.6-sles11.target
2655 lustre/kernel_patches/targets/2.6-oel5.target
2656 lustre/kernel_patches/targets/2.6-fc11.target
2657 lustre/kernel_patches/targets/2.6-fc12.target
2658 lustre/ldlm/Makefile
2659 lustre/fid/Makefile
2660 lustre/fid/autoMakefile
2661 lustre/liblustre/Makefile
2662 lustre/liblustre/tests/Makefile
2663 lustre/liblustre/tests/mpi/Makefile
2664 lustre/llite/Makefile
2665 lustre/llite/autoMakefile
2666 lustre/lclient/Makefile
2667 lustre/lov/Makefile
2668 lustre/lov/autoMakefile
2669 lustre/lvfs/Makefile
2670 lustre/lvfs/autoMakefile
2671 lustre/mdc/Makefile
2672 lustre/mdc/autoMakefile
2673 lustre/lmv/Makefile
2674 lustre/lmv/autoMakefile
2675 lustre/mds/Makefile
2676 lustre/mds/autoMakefile
2677 lustre/mdt/Makefile
2678 lustre/mdt/autoMakefile
2679 lustre/cmm/Makefile
2680 lustre/cmm/autoMakefile
2681 lustre/mdd/Makefile
2682 lustre/mdd/autoMakefile
2683 lustre/fld/Makefile
2684 lustre/fld/autoMakefile
2685 lustre/obdclass/Makefile
2686 lustre/obdclass/autoMakefile
2687 lustre/obdclass/linux/Makefile
2688 lustre/obdecho/Makefile
2689 lustre/obdecho/autoMakefile
2690 lustre/obdfilter/Makefile
2691 lustre/obdfilter/autoMakefile
2692 lustre/osc/Makefile
2693 lustre/osc/autoMakefile
2694 lustre/ost/Makefile
2695 lustre/ost/autoMakefile
2696 lustre/osd-ldiskfs/Makefile
2697 lustre/osd-ldiskfs/autoMakefile
2698 lustre/mgc/Makefile
2699 lustre/mgc/autoMakefile
2700 lustre/mgs/Makefile
2701 lustre/mgs/autoMakefile
2702 lustre/ptlrpc/Makefile
2703 lustre/ptlrpc/autoMakefile
2704 lustre/ptlrpc/gss/Makefile
2705 lustre/ptlrpc/gss/autoMakefile
2706 lustre/quota/Makefile
2707 lustre/quota/autoMakefile
2708 lustre/scripts/Makefile
2709 lustre/tests/Makefile
2710 lustre/tests/mpi/Makefile
2711 lustre/utils/Makefile
2712 lustre/utils/gss/Makefile
2713 lustre/obdclass/darwin/Makefile
2714 ])
2715 ])