Whamcloud - gitweb
b=22683 store cl_env in task_struct for redhat kernel and liblustre.
[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=no
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_D_OBTAIN_ALIAS
704 # starting from 2.6.18 kernel don't export do_kern_mount
705 # and want to use vfs_kern_mount instead.
706 #
707 AC_DEFUN([LC_D_OBTAIN_ALIAS],
708 [AC_MSG_CHECKING([d_obtain_alias exist in kernel])
709 LB_LINUX_TRY_COMPILE([
710         #include <linux/dcache.h>
711 ],[
712         d_obtain_alias(NULL);
713 ],[
714         AC_DEFINE(HAVE_D_OBTAIN_ALIAS, 1,
715                 [d_obtain_alias exist in kernel])
716         AC_MSG_RESULT([yes])
717 ],[
718         AC_MSG_RESULT([no])
719 ])
720 ])
721
722 #
723 # LC_INVALIDATEPAGE_RETURN_INT
724 # 2.6.17 changes return type for invalidatepage to 'void' from 'int'
725 #
726 AC_DEFUN([LC_INVALIDATEPAGE_RETURN_INT],
727 [AC_MSG_CHECKING([invalidatepage has return int])
728 LB_LINUX_TRY_COMPILE([
729         #include <linux/buffer_head.h>
730 ],[
731         int rc = block_invalidatepage(NULL, 0);
732 ],[
733         AC_MSG_RESULT(yes)
734         AC_DEFINE(HAVE_INVALIDATEPAGE_RETURN_INT, 1,
735                 [Define if return type of invalidatepage should be int])
736 ],[
737         AC_MSG_RESULT(no)
738 ])
739 ])
740
741 # LC_UMOUNTBEGIN_HAS_VFSMOUNT
742 # after 2.6.18 umount_begin has different parameters
743 AC_DEFUN([LC_UMOUNTBEGIN_HAS_VFSMOUNT],
744 [AC_MSG_CHECKING([if umount_begin needs vfsmount parameter instead of super_block])
745 tmp_flags="$EXTRA_KCFLAGS"
746 EXTRA_KCFLAGS="-Werror"
747 LB_LINUX_TRY_COMPILE([
748         #include <linux/fs.h>
749
750         struct vfsmount;
751         static void cfg_umount_begin (struct vfsmount *v, int flags)
752         {
753                 ;
754         }
755
756         static struct super_operations cfg_super_operations = {
757                 .umount_begin   = cfg_umount_begin,
758         };
759 ],[
760         cfg_super_operations.umount_begin(NULL,0);
761 ],[
762         AC_MSG_RESULT(yes)
763         AC_DEFINE(HAVE_UMOUNTBEGIN_VFSMOUNT, 1,
764                 [Define umount_begin need second argument])
765 ],[
766         AC_MSG_RESULT(no)
767 ])
768 EXTRA_KCFLAGS="$tmp_flags"
769 ])
770
771 # inode have i_private field since 2.6.17
772 AC_DEFUN([LC_INODE_IPRIVATE],
773 [AC_MSG_CHECKING([if inode has a i_private field])
774 LB_LINUX_TRY_COMPILE([
775 #include <linux/fs.h>
776 ],[
777         struct inode i;
778         i.i_private = NULL; 
779 ],[
780         AC_MSG_RESULT(yes)
781         AC_DEFINE(HAVE_INODE_IPRIVATE, 1,
782                 [struct inode has i_private field])
783 ],[
784         AC_MSG_RESULT(no)
785 ])
786 ])
787
788 # 2.6.19 API changes
789 # inode don't have i_blksize field
790 AC_DEFUN([LC_INODE_BLKSIZE],
791 [AC_MSG_CHECKING([inode has i_blksize field])
792 LB_LINUX_TRY_COMPILE([
793 #include <linux/fs.h>
794 ],[
795         struct inode i;
796         i.i_blksize = 0;
797 ],[
798         AC_MSG_RESULT(yes)
799         AC_DEFINE(HAVE_INODE_BLKSIZE, 1,
800                 [struct inode has i_blksize field])
801 ],[
802         AC_MSG_RESULT(no)
803 ])
804 ])
805
806 # LC_VFS_READDIR_U64_INO
807 # 2.6.19 use u64 for inode number instead of inode_t
808 AC_DEFUN([LC_VFS_READDIR_U64_INO],
809 [AC_MSG_CHECKING([check vfs_readdir need 64bit inode number])
810 tmp_flags="$EXTRA_KCFLAGS"
811 EXTRA_KCFLAGS="-Werror"
812 LB_LINUX_TRY_COMPILE([
813 #include <linux/fs.h>
814         int fillonedir(void * __buf, const char * name, int namlen, loff_t offset,
815                       u64 ino, unsigned int d_type)
816         {
817                 return 0;
818         }
819 ],[
820         filldir_t filter;
821
822         filter = fillonedir;
823         return 1;
824 ],[
825         AC_MSG_RESULT(yes)
826         AC_DEFINE(HAVE_VFS_READDIR_U64_INO, 1,
827                 [if vfs_readdir need 64bit inode number])
828 ],[
829         AC_MSG_RESULT(no)
830 ])
831 EXTRA_KCFLAGS="$tmp_flags"
832 ])
833
834 # LC_FILE_WRITEV
835 # 2.6.19 replaced writev with aio_write
836 AC_DEFUN([LC_FILE_WRITEV],
837 [AC_MSG_CHECKING([writev in fops])
838 LB_LINUX_TRY_COMPILE([
839         #include <linux/fs.h>
840 ],[
841         struct file_operations *fops = NULL;
842         fops->writev = NULL;
843 ],[
844         AC_MSG_RESULT(yes)
845         AC_DEFINE(HAVE_FILE_WRITEV, 1,
846                 [use fops->writev])
847 ],[
848         AC_MSG_RESULT(no)
849 ])
850 ])
851
852 # LC_GENERIC_FILE_READ
853 # 2.6.19 replaced readv with aio_read
854 AC_DEFUN([LC_FILE_READV],
855 [AC_MSG_CHECKING([readv in fops])
856 LB_LINUX_TRY_COMPILE([
857         #include <linux/fs.h>
858 ],[
859         struct file_operations *fops = NULL;
860         fops->readv = NULL;
861 ],[
862         AC_MSG_RESULT(yes)
863         AC_DEFINE(HAVE_FILE_READV, 1,
864                 [use fops->readv])
865 ],[
866         AC_MSG_RESULT(no)
867 ])
868 ])
869
870 # LC_NR_PAGECACHE
871 # 2.6.18 don't export nr_pagecahe
872 AC_DEFUN([LC_NR_PAGECACHE],
873 [AC_MSG_CHECKING([kernel export nr_pagecache])
874 LB_LINUX_TRY_COMPILE([
875         #include <linux/pagemap.h>
876 ],[
877         return atomic_read(&nr_pagecache);
878 ],[
879         AC_MSG_RESULT(yes)
880         AC_DEFINE(HAVE_NR_PAGECACHE, 1,
881                 [is kernel export nr_pagecache])
882 ],[
883         AC_MSG_RESULT(no)
884 ])
885 ])
886
887 # LC_CANCEL_DIRTY_PAGE
888 # 2.6.20 introduced cancel_dirty_page instead of clear_page_dirty.
889 AC_DEFUN([LC_CANCEL_DIRTY_PAGE],
890         [AC_MSG_CHECKING([kernel has cancel_dirty_page])
891         # the implementation of cancel_dirty_page in OFED 1.4.1's SLES10 SP2
892         # backport is broken, so ignore it
893         if test -f $OFED_BACKPORT_PATH/linux/mm.h &&
894            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
895                 AC_MSG_RESULT(no)
896         else
897                 LB_LINUX_TRY_COMPILE([
898                         #include <linux/mm.h>
899                         #include <linux/page-flags.h>
900 ],[
901                         cancel_dirty_page(NULL, 0);
902 ],[
903                         AC_MSG_RESULT(yes)
904                         AC_DEFINE(HAVE_CANCEL_DIRTY_PAGE, 1,
905                                   [kernel has cancel_dirty_page instead of clear_page_dirty])
906 ],[
907                         AC_MSG_RESULT(no)
908 ])
909         fi
910 ])
911
912 #
913 # LC_PAGE_CONSTANT
914 #
915 # In order to support raid5 zerocopy patch, we have to patch the kernel to make
916 # it support constant page, which means the page won't be modified during the
917 # IO.
918 #
919 AC_DEFUN([LC_PAGE_CONSTANT],
920 [AC_MSG_CHECKING([if kernel have PageConstant defined])
921 LB_LINUX_TRY_COMPILE([
922         #include <linux/mm.h>
923         #include <linux/page-flags.h>
924 ],[
925         #ifndef PG_constant
926         #error "Have no raid5 zcopy patch"
927         #endif
928 ],[
929         AC_MSG_RESULT(yes)
930         AC_DEFINE(HAVE_PAGE_CONSTANT, 1, [kernel have PageConstant supported])
931 ],[
932         AC_MSG_RESULT(no);
933 ])
934 ])
935
936 # RHEL5 in FS-cache patch rename PG_checked flag into PG_fs_misc
937 AC_DEFUN([LC_PG_FS_MISC],
938 [AC_MSG_CHECKING([kernel has PG_fs_misc])
939 LB_LINUX_TRY_COMPILE([
940         #include <linux/mm.h>
941         #include <linux/page-flags.h>
942 ],[
943         #ifndef PG_fs_misc
944         #error PG_fs_misc not defined in kernel
945         #endif
946 ],[
947         AC_MSG_RESULT(yes)
948         AC_DEFINE(HAVE_PG_FS_MISC, 1,
949                   [is kernel have PG_fs_misc])
950 ],[
951         AC_MSG_RESULT(no)
952 ])
953 ])
954
955 # RHEL5 PageChecked and SetPageChecked defined
956 AC_DEFUN([LC_PAGE_CHECKED],
957 [AC_MSG_CHECKING([kernel has PageChecked and SetPageChecked])
958 LB_LINUX_TRY_COMPILE([
959         #include <linux/autoconf.h>
960 #ifdef HAVE_LINUX_MMTYPES_H
961         #include <linux/mm_types.h>
962 #endif
963         #include <linux/page-flags.h>
964 ],[
965         struct page *p;
966
967         /* before 2.6.26 this define*/
968         #ifndef PageChecked     
969         /* 2.6.26 use function instead of define for it */
970         SetPageChecked(p);
971         PageChecked(p);
972         #endif
973 ],[
974         AC_MSG_RESULT(yes)
975         AC_DEFINE(HAVE_PAGE_CHECKED, 1,
976                   [does kernel have PageChecked and SetPageChecked])
977 ],[
978         AC_MSG_RESULT(no)
979 ])
980 ])
981
982 AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE],
983 [LB_CHECK_SYMBOL_EXPORT([truncate_complete_page],
984 [mm/truncate.c],[
985 AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
986             [kernel export truncate_complete_page])
987 ],[
988 ])
989 ])
990
991 AC_DEFUN([LC_EXPORT_TRUNCATE_RANGE],
992 [LB_CHECK_SYMBOL_EXPORT([truncate_inode_pages_range],
993 [mm/truncate.c],[
994 AC_DEFINE(HAVE_TRUNCATE_RANGE, 1,
995             [kernel export truncate_inode_pages_range])
996 ],[
997 ])
998 ])
999
1000 AC_DEFUN([LC_EXPORT_D_REHASH_COND],
1001 [LB_CHECK_SYMBOL_EXPORT([d_rehash_cond],
1002 [fs/dcache.c],[
1003 AC_DEFINE(HAVE_D_REHASH_COND, 1,
1004             [d_rehash_cond is exported by the kernel])
1005 ],[
1006 ])
1007 ])
1008
1009 AC_DEFUN([LC_EXPORT___D_REHASH],
1010 [LB_CHECK_SYMBOL_EXPORT([__d_rehash],
1011 [fs/dcache.c],[
1012 AC_DEFINE(HAVE___D_REHASH, 1,
1013             [__d_rehash is exported by the kernel])
1014 ],[
1015 ])
1016 ])
1017
1018 AC_DEFUN([LC_EXPORT_D_MOVE_LOCKED],
1019 [LB_CHECK_SYMBOL_EXPORT([d_move_locked],
1020 [fs/dcache.c],[
1021 AC_DEFINE(HAVE_D_MOVE_LOCKED, 1,
1022             [d_move_locked is exported by the kernel])
1023 ],[
1024 ])
1025 ])
1026
1027 AC_DEFUN([LC_EXPORT___D_MOVE],
1028 [LB_CHECK_SYMBOL_EXPORT([__d_move],
1029 [fs/dcache.c],[
1030 AC_DEFINE(HAVE___D_MOVE, 1,
1031             [__d_move is exported by the kernel])
1032 ],[
1033 ])
1034 ])
1035
1036 #
1037 # LC_EXPORT_INVALIDATE_MAPPING_PAGES
1038 #
1039 # SLES9, RHEL4, RHEL5, vanilla 2.6.24 export invalidate_mapping_pages() but
1040 # SLES10 2.6.16 does not, for some reason.  For filter cache invalidation.
1041 #
1042 AC_DEFUN([LC_EXPORT_INVALIDATE_MAPPING_PAGES],
1043     [LB_CHECK_SYMBOL_EXPORT([invalidate_mapping_pages], [mm/truncate.c], [
1044          AC_DEFINE(HAVE_INVALIDATE_MAPPING_PAGES, 1,
1045                         [exported invalidate_mapping_pages])],
1046     [LB_CHECK_SYMBOL_EXPORT([invalidate_inode_pages], [mm/truncate.c], [
1047          AC_DEFINE(HAVE_INVALIDATE_INODE_PAGES, 1,
1048                         [exported invalidate_inode_pages])], [
1049        AC_MSG_ERROR([no way to invalidate pages])
1050   ])
1051     ],[])
1052 ])
1053
1054 #
1055 # LC_EXPORT_FILEMAP_FDATASYNC_RANGE
1056 #
1057 # No standard kernels export this
1058 #
1059 AC_DEFUN([LC_EXPORT_FILEMAP_FDATAWRITE_RANGE],
1060 [LB_CHECK_SYMBOL_EXPORT([filemap_fdatawrite_range],
1061 [mm/filemap.c],[
1062 AC_DEFINE(HAVE_FILEMAP_FDATAWRITE_RANGE, 1,
1063             [filemap_fdatawrite_range is exported by the kernel])
1064 ],[
1065 ])
1066 ])
1067
1068 # The actual symbol exported varies among architectures, so we need
1069 # to check many symbols (but only in the current architecture.)  No
1070 # matter what symbol is exported, the kernel #defines node_to_cpumask
1071 # to the appropriate function and that's what we use.
1072 AC_DEFUN([LC_EXPORT_NODE_TO_CPUMASK],
1073          [LB_CHECK_SYMBOL_EXPORT([node_to_cpumask],
1074                                  [arch/$LINUX_ARCH/mm/numa.c],
1075                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
1076                                             [node_to_cpumask is exported by
1077                                              the kernel])]) # x86_64
1078           LB_CHECK_SYMBOL_EXPORT([node_to_cpu_mask],
1079                                  [arch/$LINUX_ARCH/kernel/smpboot.c],
1080                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
1081                                             [node_to_cpumask is exported by
1082                                              the kernel])]) # ia64
1083           LB_CHECK_SYMBOL_EXPORT([node_2_cpu_mask],
1084                                  [arch/$LINUX_ARCH/kernel/smpboot.c],
1085                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
1086                                             [node_to_cpumask is exported by
1087                                              the kernel])]) # i386
1088           ])
1089
1090 # 2.6.22 lost second parameter for invalidate_bdev
1091 AC_DEFUN([LC_INVALIDATE_BDEV_2ARG],
1092 [AC_MSG_CHECKING([if invalidate_bdev has second argument])
1093 LB_LINUX_TRY_COMPILE([
1094         #include <linux/buffer_head.h>
1095 ],[
1096         invalidate_bdev(NULL,0);
1097 ],[
1098         AC_MSG_RESULT([yes])
1099         AC_DEFINE(HAVE_INVALIDATE_BDEV_2ARG, 1,
1100                 [invalidate_bdev has second argument])
1101 ],[
1102         AC_MSG_RESULT([no])
1103 ])
1104 ])
1105
1106 # 2.6.18
1107
1108
1109 # 2.6.23 have return type 'void' for unregister_blkdev
1110 AC_DEFUN([LC_UNREGISTER_BLKDEV_RETURN_INT],
1111 [AC_MSG_CHECKING([if unregister_blkdev return int])
1112 LB_LINUX_TRY_COMPILE([
1113         #include <linux/fs.h>
1114 ],[
1115         int i = unregister_blkdev(0,NULL);
1116 ],[
1117         AC_MSG_RESULT([yes])
1118         AC_DEFINE(HAVE_UNREGISTER_BLKDEV_RETURN_INT, 1,
1119                 [unregister_blkdev return int])
1120 ],[
1121         AC_MSG_RESULT([no])
1122 ])
1123 ])
1124
1125 # 2.6.23 change .sendfile to .splice_read
1126 # RHEL4 (-92 kernel) have both sendfile and .splice_read API
1127 AC_DEFUN([LC_KERNEL_SENDFILE],
1128 [AC_MSG_CHECKING([if kernel has .sendfile])
1129 LB_LINUX_TRY_COMPILE([
1130         #include <linux/fs.h>
1131 ],[
1132         struct file_operations file;
1133
1134         file.sendfile = NULL;
1135 ], [
1136         AC_MSG_RESULT([yes])
1137         AC_DEFINE(HAVE_KERNEL_SENDFILE, 1,
1138                 [kernel has .sendfile])
1139 ],[
1140         AC_MSG_RESULT([no])
1141 ])
1142 ])
1143
1144 # 2.6.23 change .sendfile to .splice_read
1145 AC_DEFUN([LC_KERNEL_SPLICE_READ],
1146 [AC_MSG_CHECKING([if kernel has .splice_read])
1147 LB_LINUX_TRY_COMPILE([
1148         #include <linux/fs.h>
1149 ],[
1150         struct file_operations file;
1151
1152         file.splice_read = NULL;
1153 ], [
1154         AC_MSG_RESULT([yes])
1155         AC_DEFINE(HAVE_KERNEL_SPLICE_READ, 1,
1156                 [kernel has .slice_read])
1157 ],[
1158         AC_MSG_RESULT([no])
1159 ])
1160 ])
1161
1162 # 2.6.23 extract nfs export related data into exportfs.h
1163 AC_DEFUN([LC_HAVE_EXPORTFS_H],
1164 [LB_CHECK_FILE([$LINUX/include/linux/exportfs.h], [
1165         AC_DEFINE(HAVE_LINUX_EXPORTFS_H, 1,
1166                 [kernel has include/exportfs.h])
1167 ],[
1168         AC_MSG_RESULT([no])
1169 ])
1170 ])
1171
1172 # 2.6.23 has new page fault handling API
1173 AC_DEFUN([LC_VM_OP_FAULT],
1174 [AC_MSG_CHECKING([kernel has .fault in vm_operation_struct])
1175 LB_LINUX_TRY_COMPILE([
1176         #include <linux/mm.h>
1177 ],[
1178         struct vm_operations_struct op;
1179
1180         op.fault = NULL;
1181 ], [
1182         AC_MSG_RESULT([yes])
1183         AC_DEFINE(HAVE_VM_OP_FAULT, 1,
1184                 [kernel has .fault in vm_operation_struct])
1185 ],[
1186         AC_MSG_RESULT([no])
1187 ])
1188 ])
1189
1190 #2.6.23 has new shrinker API
1191 AC_DEFUN([LC_REGISTER_SHRINKER],
1192 [AC_MSG_CHECKING([if kernel has register_shrinker])
1193 LB_LINUX_TRY_COMPILE([
1194         #include <linux/mm.h>
1195 ],[
1196         register_shrinker(NULL);
1197 ], [
1198         AC_MSG_RESULT([yes])
1199         AC_DEFINE(HAVE_REGISTER_SHRINKER, 1,
1200                 [kernel has register_shrinker])
1201 ],[
1202         AC_MSG_RESULT([no])
1203 ])
1204 ])
1205
1206 # 2.6.24 has bio_endio with 2 args
1207 AC_DEFUN([LC_BIO_ENDIO_2ARG],
1208 [AC_MSG_CHECKING([if kernel has bio_endio with 2 args])
1209 LB_LINUX_TRY_COMPILE([
1210         #include <linux/bio.h>
1211 ],[
1212         bio_endio(NULL, 0);
1213 ], [
1214         AC_MSG_RESULT([yes])
1215         AC_DEFINE(HAVE_BIO_ENDIO_2ARG, 1,
1216                 [kernel has bio_endio with 2 args])
1217 ],[
1218         AC_MSG_RESULT([no])
1219 ])
1220 ])
1221
1222 # 2.6.24 has new members in exports struct.
1223 AC_DEFUN([LC_FH_TO_DENTRY],
1224 [AC_MSG_CHECKING([if kernel has .fh_to_dentry member in export_operations struct])
1225 LB_LINUX_TRY_COMPILE([
1226 #ifdef HAVE_LINUX_EXPORTFS_H
1227         #include <linux/exportfs.h>
1228 #else
1229         #include <linux/fs.h>
1230 #endif
1231 ],[
1232         struct export_operations exp;
1233
1234         exp.fh_to_dentry   = NULL;
1235 ], [
1236         AC_MSG_RESULT([yes])
1237         AC_DEFINE(HAVE_FH_TO_DENTRY, 1,
1238                 [kernel has .fh_to_dentry member in export_operations struct])
1239 ],[
1240         AC_MSG_RESULT([no])
1241 ])
1242 ])
1243
1244 # 2.6.24 need linux/mm_types.h included
1245 AC_DEFUN([LC_HAVE_MMTYPES_H],
1246 [LB_CHECK_FILE([$LINUX/include/linux/mm_types.h], [
1247         AC_DEFINE(HAVE_LINUX_MMTYPES_H, 1,
1248                 [kernel has include/mm_types.h])
1249 ],[
1250         AC_MSG_RESULT([no])
1251 ])
1252 ])
1253
1254 # 2.6.24 removes long aged procfs entry -> deleted member
1255 AC_DEFUN([LC_PROCFS_DELETED],
1256 [AC_MSG_CHECKING([if kernel has deleted member in procfs entry struct])
1257 LB_LINUX_TRY_COMPILE([
1258         #include <linux/proc_fs.h>
1259 ],[
1260         struct proc_dir_entry pde;
1261
1262         pde.deleted   = NULL;
1263 ], [
1264         AC_MSG_RESULT([yes])
1265         AC_DEFINE(HAVE_PROCFS_DELETED, 1,
1266                 [kernel has deleted member in procfs entry struct])
1267 ],[
1268         AC_MSG_RESULT([no])
1269 ])
1270 ])
1271
1272 # 2.6.25 change define to inline
1273 AC_DEFUN([LC_MAPPING_CAP_WRITEBACK_DIRTY],
1274 [AC_MSG_CHECKING([if kernel have mapping_cap_writeback_dirty])
1275 LB_LINUX_TRY_COMPILE([
1276         #include <linux/backing-dev.h>
1277 ],[
1278         #ifndef mapping_cap_writeback_dirty
1279         mapping_cap_writeback_dirty(NULL);
1280         #endif
1281 ],[
1282         AC_MSG_RESULT([yes])
1283         AC_DEFINE(HAVE_MAPPING_CAP_WRITEBACK_DIRTY, 1,
1284                 [kernel have mapping_cap_writeback_dirty])
1285 ],[
1286         AC_MSG_RESULT([no])
1287 ])
1288 ])
1289
1290
1291
1292 # 2.6.26 isn't export set_fs_pwd and change paramter in fs struct
1293 AC_DEFUN([LC_FS_STRUCT_USE_PATH],
1294 [AC_MSG_CHECKING([fs_struct use path structure])
1295 LB_LINUX_TRY_COMPILE([
1296         #include <asm/atomic.h>
1297         #include <linux/spinlock.h>
1298         #include <linux/fs_struct.h>
1299 ],[
1300         struct path path;
1301         struct fs_struct fs;
1302
1303         fs.pwd = path;
1304 ], [
1305         AC_MSG_RESULT([yes])
1306         AC_DEFINE(HAVE_FS_STRUCT_USE_PATH, 1,
1307                 [fs_struct use path structure])
1308 ],[
1309         AC_MSG_RESULT([no])
1310 ])
1311 ])
1312
1313 #
1314 # LC_VFS_INTENT_PATCHES
1315 #
1316 # check if the kernel has the VFS intent patches
1317 AC_DEFUN([LC_VFS_INTENT_PATCHES],
1318 [AC_MSG_CHECKING([if the kernel has the VFS intent patches])
1319 LB_LINUX_TRY_COMPILE([
1320         #include <linux/fs.h>
1321         #include <linux/namei.h>
1322 ],[
1323         struct nameidata nd;
1324         struct lookup_intent *it;
1325
1326         it = &nd.intent;
1327         intent_init(it, IT_OPEN);
1328         it->d.lustre.it_disposition = 0;
1329         it->d.lustre.it_data = NULL;
1330 ],[
1331         AC_MSG_RESULT([yes])
1332         AC_DEFINE(HAVE_VFS_INTENT_PATCHES, 1, [VFS intent patches are applied])
1333 ],[
1334         AC_MSG_RESULT([no])
1335 ])
1336 ])
1337
1338 AC_DEFUN([LC_S_TIME_GRAN],
1339 [AC_MSG_CHECKING([if super block has s_time_gran member])
1340 LB_LINUX_TRY_COMPILE([
1341         #include <linux/fs.h>
1342 ],[
1343         struct super_block sb;
1344
1345         return sb.s_time_gran;
1346 ],[
1347         AC_MSG_RESULT([yes])
1348         AC_DEFINE(HAVE_S_TIME_GRAN, 1, [super block has s_time_gran member])
1349 ],[
1350         AC_MSG_RESULT([no])
1351 ])
1352 ])
1353
1354 AC_DEFUN([LC_SB_TIME_GRAN],
1355 [AC_MSG_CHECKING([if kernel has old get_sb_time_gran])
1356 LB_LINUX_TRY_COMPILE([
1357         #include <linux/fs.h>
1358 ],[
1359         return get_sb_time_gran(NULL);
1360 ],[
1361         AC_MSG_RESULT([yes])
1362         AC_DEFINE(HAVE_SB_TIME_GRAN, 1, [kernel has old get_sb_time_gran])
1363 ],[
1364         AC_MSG_RESULT([no])
1365 ])
1366 ])
1367
1368 #
1369 # LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
1370 #
1371 # Check for our patched grab_cache_page_nowait_gfp() function
1372 # after 2.6.29 we can emulate this using add_to_page_cache_lru()
1373 #
1374 AC_DEFUN([LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP],
1375 [LB_CHECK_SYMBOL_EXPORT([grab_cache_page_nowait_gfp],
1376 [mm/filemap.c],[
1377         AC_DEFINE(HAVE_GRAB_CACHE_PAGE_NOWAIT_GFP, 1,
1378                   [kernel exports grab_cache_page_nowait_gfp])
1379         ],
1380         [LB_CHECK_SYMBOL_EXPORT([add_to_page_cache_lru],
1381         [mm/filemap.c],[
1382                 AC_DEFINE(HAVE_ADD_TO_PAGE_CACHE_LRU, 1,
1383                         [kernel exports add_to_page_cache_lru])
1384         ],[
1385         ])
1386         ])
1387 ])
1388
1389 # ~2.6.12 merge patch from oracle to convert tree_lock from spinlock to rwlock
1390 AC_DEFUN([LC_RW_TREE_LOCK],
1391 [AC_MSG_CHECKING([if kernel has tree_lock as rwlock])
1392 tmp_flags="$EXTRA_KCFLAGS"
1393 EXTRA_KCFLAGS="-Werror"
1394 LB_LINUX_TRY_COMPILE([
1395         #include <linux/fs.h>
1396 ],[
1397         struct address_space a;
1398
1399         write_lock(&a.tree_lock);
1400 ],[
1401         AC_MSG_RESULT([yes])
1402         AC_DEFINE(HAVE_RW_TREE_LOCK, 1, [kernel has tree_lock as rw_lock])
1403 ],[
1404         AC_MSG_RESULT([no])
1405 ])
1406 EXTRA_KCFLAGS="$tmp_flags"
1407 ])
1408
1409 AC_DEFUN([LC_CONST_ACL_SIZE],
1410 [AC_MSG_CHECKING([calc acl size])
1411 tmp_flags="$CFLAGS"
1412 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"
1413 AC_TRY_RUN([
1414 #define __KERNEL__
1415 #include <linux/autoconf.h>
1416 #include <linux/types.h>
1417 #undef __KERNEL__
1418 // block include
1419 #define __LINUX_POSIX_ACL_H
1420
1421 # ifdef CONFIG_FS_POSIX_ACL
1422 #  ifdef HAVE_XATTR_ACL
1423 #   include <linux/xattr_acl.h>
1424 #  endif
1425 #  ifdef HAVE_LINUX_POSIX_ACL_XATTR_H
1426 #   include <linux/posix_acl_xattr.h>
1427 #  endif
1428 # endif
1429
1430 #include <lustre_acl.h>
1431
1432 #include <stdio.h>
1433
1434 int main(void)
1435 {
1436     int size = mds_xattr_acl_size(LUSTRE_POSIX_ACL_MAX_ENTRIES);
1437     FILE *f = fopen("acl.size","w+");
1438     fprintf(f,"%d", size);
1439     fclose(f);
1440
1441     return 0;
1442 }
1443
1444 ],[
1445         acl_size=`cat acl.size`
1446         AC_MSG_RESULT([ACL size $acl_size])
1447         AC_DEFINE_UNQUOTED(XATTR_ACL_SIZE, AS_TR_SH([$acl_size]), [size of xattr acl])
1448 ],[
1449         AC_ERROR([ACL size can't computed])
1450 ])
1451 CFLAGS="$tmp_flags"
1452 ])
1453
1454 #
1455 # check for crypto API
1456 #
1457 AC_DEFUN([LC_ASYNC_BLOCK_CIPHER],
1458 [AC_MSG_CHECKING([if kernel has block cipher support])
1459 LB_LINUX_TRY_COMPILE([
1460         #include <linux/err.h>
1461         #include <linux/crypto.h>
1462 ],[
1463         struct crypto_blkcipher *tfm;
1464         tfm = crypto_alloc_blkcipher("aes", 0, 0 );
1465 ],[
1466         AC_MSG_RESULT([yes])
1467         AC_DEFINE(HAVE_ASYNC_BLOCK_CIPHER, 1, [kernel has block cipher support])
1468 ],[
1469         AC_MSG_RESULT([no])
1470 ])
1471 ])
1472
1473 #
1474 # check for struct hash_desc
1475 #
1476 AC_DEFUN([LC_STRUCT_HASH_DESC],
1477 [AC_MSG_CHECKING([if kernel has struct hash_desc])
1478 LB_LINUX_TRY_COMPILE([
1479         #include <linux/err.h>
1480         #include <linux/crypto.h>
1481 ],[
1482         struct hash_desc foo;
1483 ],[
1484         AC_MSG_RESULT([yes])
1485         AC_DEFINE(HAVE_STRUCT_HASH_DESC, 1, [kernel has struct hash_desc])
1486 ],[
1487         AC_MSG_RESULT([no])
1488 ])
1489 ])
1490
1491 #
1492 # check for struct blkcipher_desc
1493 #
1494 AC_DEFUN([LC_STRUCT_BLKCIPHER_DESC],
1495 [AC_MSG_CHECKING([if kernel has struct blkcipher_desc])
1496 LB_LINUX_TRY_COMPILE([
1497         #include <linux/err.h>
1498         #include <linux/crypto.h>
1499 ],[
1500         struct blkcipher_desc foo;
1501 ],[
1502         AC_MSG_RESULT([yes])
1503         AC_DEFINE(HAVE_STRUCT_BLKCIPHER_DESC, 1, [kernel has struct blkcipher_desc])
1504 ],[
1505         AC_MSG_RESULT([no])
1506 ])
1507 ])
1508
1509 #
1510 # 2.6.19 check for FS_RENAME_DOES_D_MOVE flag
1511 #
1512 AC_DEFUN([LC_FS_RENAME_DOES_D_MOVE],
1513 [AC_MSG_CHECKING([if kernel has FS_RENAME_DOES_D_MOVE flag])
1514 LB_LINUX_TRY_COMPILE([
1515         #include <linux/fs.h>
1516 ],[
1517         int v = FS_RENAME_DOES_D_MOVE;
1518 ],[
1519         AC_MSG_RESULT([yes])
1520         AC_DEFINE(HAVE_FS_RENAME_DOES_D_MOVE, 1, [kernel has FS_RENAME_DOES_D_MOVE flag])
1521 ],[
1522         AC_MSG_RESULT([no])
1523 ])
1524 ])
1525
1526 #
1527 # LC_FUNC_F_OP_FLOCK
1528 #
1529 # rhel4.2 kernel has f_op->flock field
1530 #
1531 AC_DEFUN([LC_FUNC_F_OP_FLOCK],
1532 [AC_MSG_CHECKING([if struct file_operations has flock field])
1533 LB_LINUX_TRY_COMPILE([
1534         #include <linux/fs.h>
1535 ],[
1536         struct file_operations ll_file_operations_flock;
1537         ll_file_operations_flock.flock = NULL;
1538 ],[
1539         AC_DEFINE(HAVE_F_OP_FLOCK, 1,
1540                 [struct file_operations has flock field])
1541         AC_MSG_RESULT([yes])
1542 ],[
1543         AC_MSG_RESULT([no])
1544 ])
1545 ])
1546
1547 # vfs_symlink seems to have started out with 3 args until 2.6.7 where a
1548 # "mode" argument was added, but then again, in some later version it was
1549 # removed
1550 AC_DEFUN([LC_4ARGS_VFS_SYMLINK],
1551 [AC_MSG_CHECKING([if vfs_symlink wants 4 args])
1552 LB_LINUX_TRY_COMPILE([
1553         #include <linux/fs.h>
1554 ],[
1555         struct inode *dir;
1556         struct dentry *dentry;
1557         const char *oldname = NULL;
1558         int mode = 0;
1559
1560         vfs_symlink(dir, dentry, oldname, mode);
1561 ],[
1562         AC_MSG_RESULT(yes)
1563         AC_DEFINE(HAVE_4ARGS_VFS_SYMLINK, 1,
1564                   [vfs_symlink wants 4 args])
1565 ],[
1566         AC_MSG_RESULT(no)
1567 ])
1568 ])
1569
1570 # 2.6.23 has new shrinker API
1571 AC_DEFUN([LC_REGISTER_SHRINKER],
1572 [LB_CHECK_SYMBOL_EXPORT([register_shrinker],
1573 [mm/vmscan.c],[
1574         AC_DEFINE(HAVE_REGISTER_SHRINKER, 1,
1575                   [kernel exports register_shrinker])
1576 ],[
1577 ])
1578 ])
1579
1580 #2.6.27
1581 AC_DEFUN([LC_INODE_PERMISION_2ARGS],
1582 [AC_MSG_CHECKING([inode_operations->permission has two args])
1583 LB_LINUX_TRY_COMPILE([
1584         #include <linux/fs.h>
1585 ],[
1586         struct inode *inode;
1587
1588         inode->i_op->permission(NULL,0);
1589 ],[
1590         AC_DEFINE(HAVE_INODE_PERMISION_2ARGS, 1, 
1591                   [inode_operations->permission has two args])
1592         AC_MSG_RESULT([yes])
1593 ],[
1594         AC_MSG_RESULT([no])
1595 ])
1596 ])
1597
1598 # 2.6.27 has file_remove_suid instead of remove_suid
1599 AC_DEFUN([LC_FILE_REMOVE_SUID],
1600 [AC_MSG_CHECKING([kernel has file_remove_suid])
1601 LB_LINUX_TRY_COMPILE([
1602         #include <linux/fs.h>
1603 ],[
1604         file_remove_suid(NULL);
1605 ],[
1606         AC_DEFINE(HAVE_FILE_REMOVE_SUID, 1,
1607                   [kernel have file_remove_suid])
1608         AC_MSG_RESULT([yes])
1609 ],[
1610         AC_MSG_RESULT([no])
1611 ])
1612 ])
1613
1614 # 2.6.27 have new page locking API
1615 AC_DEFUN([LC_TRYLOCKPAGE],
1616 [AC_MSG_CHECKING([kernel uses trylock_page for page lock])
1617 LB_LINUX_TRY_COMPILE([
1618         #include <linux/pagemap.h>
1619 ],[
1620         trylock_page(NULL);
1621 ],[
1622         AC_DEFINE(HAVE_TRYLOCK_PAGE, 1,
1623                   [kernel uses trylock_page for page lock])
1624         AC_MSG_RESULT([yes])
1625 ],[
1626         AC_MSG_RESULT([no])
1627 ])
1628 ])
1629
1630 # vfs_symlink seems to have started out with 3 args until 2.6.7 where a
1631 # "mode" argument was added, but then again, in some later version it was
1632 # removed
1633 AC_DEFUN([LC_4ARGS_VFS_SYMLINK],
1634 [AC_MSG_CHECKING([if vfs_symlink wants 4 args])
1635 LB_LINUX_TRY_COMPILE([
1636         #include <linux/fs.h>
1637 ],[
1638         struct inode *dir;
1639         struct dentry *dentry;
1640         const char *oldname = NULL;
1641         int mode = 0;
1642
1643         vfs_symlink(dir, dentry, oldname, mode);
1644 ],[
1645         AC_MSG_RESULT(yes)
1646         AC_DEFINE(HAVE_4ARGS_VFS_SYMLINK, 1,
1647                   [vfs_symlink wants 4 args])
1648 ],[
1649         AC_MSG_RESULT(no)
1650 ])
1651 ])
1652
1653 # 2.6.27 sles11 remove the bi_hw_segments
1654 AC_DEFUN([LC_BI_HW_SEGMENTS],
1655 [AC_MSG_CHECKING([struct bio has a bi_hw_segments field])
1656 LB_LINUX_TRY_COMPILE([
1657         #include <linux/bio.h>
1658 ],[
1659         struct bio io;
1660         io.bi_hw_segments = 0;
1661 ],[
1662         AC_DEFINE(HAVE_BI_HW_SEGMENTS, 1,
1663                 [struct bio has a bi_hw_segments field])
1664         AC_MSG_RESULT([yes])
1665 ],[
1666         AC_MSG_RESULT([no])
1667 ])
1668 ])
1669
1670 # 2.6.27 sles11 move the quotaio_v1.h to fs
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 ],[
1676         AC_MSG_RESULT([no])
1677 ])
1678 ])
1679
1680 # sles10 sp2 need 5 parameter for vfs_symlink
1681 AC_DEFUN([LC_VFS_SYMLINK_5ARGS],
1682 [AC_MSG_CHECKING([vfs_symlink need 5 parameter])
1683 LB_LINUX_TRY_COMPILE([
1684         #include <linux/fs.h>
1685 ],[
1686         struct inode *dir = NULL;
1687         struct dentry *dentry = NULL;
1688         struct vfsmount *mnt = NULL;
1689         const char * path = NULL;
1690         vfs_symlink(dir, dentry, mnt, path, 0);
1691 ],[
1692         AC_DEFINE(HAVE_VFS_SYMLINK_5ARGS, 1,
1693                 [vfs_symlink need 5 parameteres])
1694         AC_MSG_RESULT([yes])
1695 ],[
1696         AC_MSG_RESULT([no])
1697 ])
1698 ])
1699
1700 # 2.6.27 removed the read_inode from super_operations.
1701 AC_DEFUN([LC_READ_INODE_IN_SBOPS],
1702 [AC_MSG_CHECKING([super_operations has a read_inode field])
1703 LB_LINUX_TRY_COMPILE([
1704         #include <linux/fs.h>
1705 ],[
1706         struct super_operations *sop;
1707         sop->read_inode(NULL);
1708 ],[
1709         AC_DEFINE(HAVE_READ_INODE_IN_SBOPS, 1,
1710                 [super_operations has a read_inode])
1711         AC_MSG_RESULT([yes])
1712 ],[
1713         AC_MSG_RESULT([no])
1714 ])
1715 ])
1716
1717 # 2.6.27 sles11 has sb_any_quota_active
1718 AC_DEFUN([LC_SB_ANY_QUOTA_ACTIVE],
1719 [AC_MSG_CHECKING([Kernel has sb_any_quota_active])
1720 LB_LINUX_TRY_COMPILE([
1721         #include <linux/quotaops.h>
1722 ],[
1723         sb_any_quota_active(NULL);
1724 ],[
1725         AC_DEFINE(HAVE_SB_ANY_QUOTA_ACTIVE, 1,
1726                 [Kernel has a sb_any_quota_active])
1727         AC_MSG_RESULT([yes])
1728 ],[
1729         AC_MSG_RESULT([no])
1730 ])
1731 ])
1732
1733 # 2.6.27 sles11 has sb_has_quota_active
1734 AC_DEFUN([LC_SB_HAS_QUOTA_ACTIVE],
1735 [AC_MSG_CHECKING([Kernel has sb_has_quota_active])
1736 LB_LINUX_TRY_COMPILE([
1737         #include <linux/quotaops.h>
1738 ],[
1739         sb_has_quota_active(NULL, 0);
1740 ],[
1741         AC_DEFINE(HAVE_SB_HAS_QUOTA_ACTIVE, 1,
1742                 [Kernel has a sb_has_quota_active])
1743         AC_MSG_RESULT([yes])
1744 ],[
1745         AC_MSG_RESULT([no])
1746 ])
1747 ])
1748
1749 # 2.6.27 has inode_permission instead of permisson
1750 AC_DEFUN([LC_EXPORT_INODE_PERMISSION],
1751 [LB_CHECK_SYMBOL_EXPORT([inode_permission],
1752 [fs/namei.c],[
1753 AC_DEFINE(HAVE_EXPORT_INODE_PERMISSION, 1,
1754             [inode_permission is exported by the kernel])
1755 ],[
1756 ])
1757 ])
1758
1759 # 2.6.27 use 5th parameter in quota_on for remount.
1760 AC_DEFUN([LC_QUOTA_ON_5ARGS],
1761 [AC_MSG_CHECKING([quota_on needs 5 parameters])
1762 LB_LINUX_TRY_COMPILE([
1763         #include <linux/quota.h>
1764 ],[
1765         struct quotactl_ops *qop;
1766         qop->quota_on(NULL, 0, 0, NULL, 0);
1767 ],[
1768         AC_DEFINE(HAVE_QUOTA_ON_5ARGS, 1,
1769                 [quota_on needs 5 paramters])
1770         AC_MSG_RESULT([yes])
1771 ],[
1772         AC_MSG_RESULT([no])
1773 ])
1774 ])
1775
1776 # 2.6.27 use 3th parameter in quota_off for remount.
1777 AC_DEFUN([LC_QUOTA_OFF_3ARGS],
1778 [AC_MSG_CHECKING([quota_off needs 3 parameters])
1779 LB_LINUX_TRY_COMPILE([
1780         #include <linux/quota.h>
1781 ],[
1782         struct quotactl_ops *qop;
1783         qop->quota_off(NULL, 0, 0);
1784 ],[
1785         AC_DEFINE(HAVE_QUOTA_OFF_3ARGS, 1,
1786                 [quota_off needs 3 paramters])
1787         AC_MSG_RESULT([yes])
1788 ],[
1789         AC_MSG_RESULT([no])
1790 ])
1791 ])
1792
1793 # 2.6.27 has vfs_dq_off inline function.
1794 AC_DEFUN([LC_VFS_DQ_OFF],
1795 [AC_MSG_CHECKING([vfs_dq_off is defined])
1796 LB_LINUX_TRY_COMPILE([
1797         #include <linux/quotaops.h>
1798 ],[
1799         vfs_dq_off(NULL, 0);
1800 ],[
1801         AC_DEFINE(HAVE_VFS_DQ_OFF, 1, [vfs_dq_off is defined])
1802         AC_MSG_RESULT([yes])
1803 ],[
1804         AC_MSG_RESULT([no])
1805 ])
1806 ])
1807
1808 #
1809 # LC_LINUX_FIEMAP_H
1810 #
1811 # If we have fiemap.h
1812 # after 2.6.27 use fiemap.h in include/linux
1813 #
1814 AC_DEFUN([LC_LINUX_FIEMAP_H],
1815 [LB_CHECK_FILE([$LINUX/include/linux/fiemap.h],[
1816         AC_MSG_CHECKING([if fiemap.h can be compiled])
1817         LB_LINUX_TRY_COMPILE([
1818                 #include <linux/types.h>
1819                 #include <linux/fiemap.h>
1820         ],[],[
1821                 AC_MSG_RESULT([yes])
1822                 AC_DEFINE(HAVE_LINUX_FIEMAP_H, 1, [Kernel has fiemap.h])
1823         ],[
1824                 AC_MSG_RESULT([no])
1825         ])
1826 ],
1827 [])
1828 ])
1829
1830 # LC_LOCK_MAP_ACQUIRE
1831 # after 2.6.27 lock_map_acquire replaces lock_acquire
1832 AC_DEFUN([LC_LOCK_MAP_ACQUIRE],
1833 [AC_MSG_CHECKING([if lock_map_acquire is defined])
1834 LB_LINUX_TRY_COMPILE([
1835         #include <linux/lockdep.h>
1836 ],[
1837         lock_map_acquire(NULL);
1838 ],[
1839         AC_MSG_RESULT(yes)
1840         AC_DEFINE(HAVE_LOCK_MAP_ACQUIRE, 1,
1841                 [lock_map_acquire is defined])
1842 ],[
1843         AC_MSG_RESULT(no)
1844 ])
1845 ])
1846
1847 # 2.6.31 replaces blk_queue_hardsect_size by blk_queue_logical_block_size function
1848 AC_DEFUN([LC_BLK_QUEUE_LOG_BLK_SIZE],
1849 [AC_MSG_CHECKING([if blk_queue_logical_block_size is defined])
1850 LB_LINUX_TRY_COMPILE([
1851         #include <linux/blkdev.h>
1852 ],[
1853         blk_queue_logical_block_size(NULL, 0);
1854 ],[
1855         AC_MSG_RESULT(yes)
1856         AC_DEFINE(HAVE_BLK_QUEUE_LOG_BLK_SIZE, 1,
1857                   [blk_queue_logical_block_size is defined])
1858 ],[
1859         AC_MSG_RESULT(no)
1860 ])
1861 ])
1862
1863 #
1864 # LC_PROG_LINUX
1865 #
1866 # Lustre linux kernel checks
1867 #
1868 AC_DEFUN([LC_PROG_LINUX],
1869          [LC_LUSTRE_VERSION_H
1870          if test x$enable_server = xyes ; then
1871              AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
1872              LC_FUNC_DEV_SET_RDONLY
1873              LC_STACK_SIZE
1874              LC_CONFIG_BACKINGFS
1875          fi
1876          LC_CONFIG_PINGER
1877          LC_CONFIG_CHECKSUM
1878          LC_CONFIG_LIBLUSTRE_RECOVERY
1879          LC_CONFIG_HEALTH_CHECK_WRITE
1880          LC_CONFIG_LRU_RESIZE
1881          LC_QUOTA_MODULE
1882
1883          # RHEL4 patches
1884          LC_EXPORT_TRUNCATE_COMPLETE
1885          LC_EXPORT_TRUNCATE_RANGE
1886          LC_EXPORT_D_REHASH_COND
1887          LC_EXPORT___D_REHASH
1888          LC_EXPORT_D_MOVE_LOCKED
1889          LC_EXPORT___D_MOVE
1890          LC_EXPORT_NODE_TO_CPUMASK
1891
1892          LC_HEADER_LDISKFS_XATTR
1893          LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
1894          LC_STRUCT_STATFS
1895          LC_FILEMAP_POPULATE
1896          LC_D_ADD_UNIQUE
1897          LC_BIT_SPINLOCK_H
1898
1899          LC_XATTR_ACL
1900          LC_POSIX_ACL_XATTR_H
1901          LC_CONST_ACL_SIZE
1902
1903          LC_STRUCT_INTENT_FILE
1904
1905          LC_CAPA_CRYPTO
1906          LC_CONFIG_RMTCLIENT
1907          LC_CONFIG_GSS
1908          LC_FUNC_MS_FLOCK_LOCK
1909          LC_FUNC_HAVE_CAN_SLEEP_ARG
1910          LC_FUNC_F_OP_FLOCK
1911          LC_QUOTA_READ
1912          LC_COOKIE_FOLLOW_LINK
1913          LC_FUNC_RCU
1914          LC_PERCPU_COUNTER
1915          LC_TASK_CLENV_STORE
1916          LC_QUOTA64
1917          LC_4ARGS_VFS_SYMLINK
1918
1919          # does the kernel have VFS intent patches?
1920          LC_VFS_INTENT_PATCHES
1921
1922          # ~2.6.11
1923          LC_S_TIME_GRAN
1924          LC_SB_TIME_GRAN
1925
1926          # 2.6.12
1927          LC_RW_TREE_LOCK
1928          LC_EXPORT_SYNCHRONIZE_RCU
1929
1930          # 2.6.15
1931          LC_INODE_I_MUTEX
1932
1933          # 2.6.16
1934          LC_SECURITY_PLUG  # for SLES10 SP2
1935
1936          # 2.6.17
1937          LC_INODE_IPRIVATE
1938          LC_DQUOTOFF_MUTEX
1939
1940          # 2.6.18
1941          LC_NR_PAGECACHE
1942          LC_STATFS_DENTRY_PARAM
1943          LC_VFS_KERN_MOUNT
1944          LC_INVALIDATEPAGE_RETURN_INT
1945          LC_UMOUNTBEGIN_HAS_VFSMOUNT
1946          LC_SEQ_LOCK
1947          LC_EXPORT_FILEMAP_FDATAWRITE_RANGE
1948          LC_FLUSH_OWNER_ID
1949          if test x$enable_server = xyes ; then
1950                 LC_EXPORT_INVALIDATE_MAPPING_PAGES
1951          fi
1952
1953          #2.6.18 + RHEL5 (fc6)
1954          LC_PG_FS_MISC
1955          LC_PAGE_CHECKED
1956          LC_LINUX_FIEMAP_H
1957
1958          # 2.6.19
1959          LC_INODE_BLKSIZE
1960          LC_VFS_READDIR_U64_INO
1961          LC_FILE_WRITEV
1962          LC_FILE_READV
1963
1964          # 2.6.20
1965          LC_CANCEL_DIRTY_PAGE
1966
1967          # raid5-zerocopy patch
1968          LC_PAGE_CONSTANT
1969
1970          # 2.6.22
1971          LC_INVALIDATE_BDEV_2ARG
1972          LC_ASYNC_BLOCK_CIPHER
1973          LC_STRUCT_HASH_DESC
1974          LC_STRUCT_BLKCIPHER_DESC
1975          LC_FS_RENAME_DOES_D_MOVE
1976          # 2.6.23
1977          LC_UNREGISTER_BLKDEV_RETURN_INT
1978          LC_KERNEL_SPLICE_READ
1979          LC_KERNEL_SENDFILE
1980          LC_HAVE_EXPORTFS_H
1981          LC_VM_OP_FAULT
1982          LC_REGISTER_SHRINKER
1983   
1984          # 2.6.24
1985          LC_HAVE_MMTYPES_H
1986          LC_BIO_ENDIO_2ARG
1987          LC_FH_TO_DENTRY
1988          LC_PROCFS_DELETED
1989
1990          #2.6.25
1991          LC_MAPPING_CAP_WRITEBACK_DIRTY
1992   
1993          # 2.6.26
1994          LC_FS_STRUCT_USE_PATH
1995
1996          # 2.6.27
1997          LC_INODE_PERMISION_2ARGS
1998          LC_FILE_REMOVE_SUID
1999          LC_TRYLOCKPAGE
2000          LC_READ_INODE_IN_SBOPS
2001          LC_EXPORT_INODE_PERMISSION
2002          LC_QUOTA_ON_5ARGS
2003          LC_QUOTA_OFF_3ARGS
2004          LC_VFS_DQ_OFF
2005          LC_LOCK_MAP_ACQUIRE
2006
2007          # 2.6.27.15-2 sles11
2008          LC_BI_HW_SEGMENTS
2009          LC_HAVE_QUOTAIO_V1_H
2010          LC_VFS_SYMLINK_5ARGS
2011          LC_SB_ANY_QUOTA_ACTIVE
2012          LC_SB_HAS_QUOTA_ACTIVE
2013
2014          # 2.6.31
2015          LC_BLK_QUEUE_LOG_BLK_SIZE
2016 ])
2017
2018 #
2019 # LC_CONFIG_CLIENT_SERVER
2020 #
2021 # Build client/server sides of Lustre
2022 #
2023 AC_DEFUN([LC_CONFIG_CLIENT_SERVER],
2024 [AC_MSG_CHECKING([whether to build Lustre server support])
2025 AC_ARG_ENABLE([server],
2026         AC_HELP_STRING([--disable-server],
2027                         [disable Lustre server support]),
2028         [],[enable_server='yes'])
2029 AC_MSG_RESULT([$enable_server])
2030
2031 AC_MSG_CHECKING([whether to build Lustre client support])
2032 AC_ARG_ENABLE([client],
2033         AC_HELP_STRING([--disable-client],
2034                         [disable Lustre client support]),
2035         [],[enable_client='yes'])
2036 AC_MSG_RESULT([$enable_client])])
2037
2038 #
2039 # LC_CONFIG_LIBLUSTRE
2040 #
2041 # whether to build liblustre
2042 #
2043 AC_DEFUN([LC_CONFIG_LIBLUSTRE],
2044 [AC_MSG_CHECKING([whether to build Lustre library])
2045 AC_ARG_ENABLE([liblustre],
2046         AC_HELP_STRING([--disable-liblustre],
2047                         [disable building of Lustre library]),
2048         [],[enable_liblustre=$with_sysio])
2049 AC_MSG_RESULT([$enable_liblustre])
2050 # only build sysio if liblustre is built
2051 with_sysio="$enable_liblustre"
2052
2053 AC_MSG_CHECKING([whether to build liblustre tests])
2054 AC_ARG_ENABLE([liblustre-tests],
2055         AC_HELP_STRING([--enable-liblustre-tests],
2056                         [enable liblustre tests, if --disable-tests is used]),
2057         [],[enable_liblustre_tests=$enable_tests])
2058 if test x$enable_liblustre != xyes ; then
2059    enable_liblustre_tests='no'
2060 fi
2061 AC_MSG_RESULT([$enable_liblustre_tests])
2062
2063 AC_MSG_CHECKING([whether to enable liblustre acl])
2064 AC_ARG_ENABLE([liblustre-acl],
2065         AC_HELP_STRING([--disable-liblustre-acl],
2066                         [disable ACL support for liblustre]),
2067         [],[enable_liblustre_acl=yes])
2068 AC_MSG_RESULT([$enable_liblustre_acl])
2069 if test x$enable_liblustre_acl = xyes ; then
2070   AC_DEFINE(LIBLUSTRE_POSIX_ACL, 1, Liblustre Support ACL-enabled MDS)
2071 fi
2072
2073 # 2.6.29 change prepare/commit_write to write_begin/end
2074 AC_DEFUN([LC_WRITE_BEGIN_END],
2075 [AC_MSG_CHECKING([if kernel has .write_begin/end])
2076 LB_LINUX_TRY_COMPILE([
2077         #include <linux/fs.h>
2078         #include <linux/pagemap.h>
2079 #ifdef HAVE_LINUX_MMTYPES_H
2080         #include <linux/mm_types.h>
2081 #endif
2082 ],[
2083         struct address_space_operations aops;
2084         struct page *page;
2085
2086         aops.write_begin = NULL;
2087         aops.write_end = NULL;
2088         page = grab_cache_page_write_begin(NULL, 0, 0);
2089 ], [
2090         AC_MSG_RESULT([yes])
2091         AC_DEFINE(HAVE_KERNEL_WRITE_BEGIN_END, 1,
2092                 [kernel has .write_begin/end])
2093 ],[
2094         AC_MSG_RESULT([no])
2095 ])
2096 ])
2097
2098 # 2.6.29 blkdev_put has 2 arguments
2099 AC_DEFUN([LC_BLKDEV_PUT_2ARGS],
2100 [AC_MSG_CHECKING([blkdev_put needs 2 parameters])
2101 LB_LINUX_TRY_COMPILE([
2102         #include <linux/fs.h>
2103 ],[
2104         blkdev_put(NULL, 0);
2105 ],[
2106         AC_DEFINE(HAVE_BLKDEV_PUT_2ARGS, 1,
2107                 [blkdev_put needs 2 paramters])
2108         AC_MSG_RESULT([yes])
2109 ],[
2110         AC_MSG_RESULT([no])
2111 ])
2112 ])
2113
2114 # 2.6.29 dentry_open has 4 arguments
2115 AC_DEFUN([LC_DENTRY_OPEN_4ARGS],
2116 [AC_MSG_CHECKING([dentry_open needs 4 parameters])
2117 LB_LINUX_TRY_COMPILE([
2118         #include <linux/fs.h>
2119 ],[
2120         dentry_open(NULL, NULL, 0, NULL);
2121 ],[
2122         AC_DEFINE(HAVE_DENTRY_OPEN_4ARGS, 1,
2123                 [dentry_open needs 4 paramters])
2124         AC_MSG_RESULT([yes])
2125 ],[
2126         AC_MSG_RESULT([no])
2127 ])
2128 ])
2129
2130 #
2131 # --enable-mpitest
2132 #
2133 AC_ARG_ENABLE(mpitests,
2134         AC_HELP_STRING([--enable-mpitests=yes|no|mpicc wrapper],
2135                            [include mpi tests]),
2136         [
2137          enable_mpitests=yes
2138          case $enableval in
2139          yes)
2140                 MPICC_WRAPPER=mpicc
2141                 ;;
2142          no)
2143                 enable_mpitests=no
2144                 ;;
2145          *)
2146                 MPICC_WRAPPER=$enableval
2147                  ;;
2148          esac
2149         ],
2150         [
2151         MPICC_WRAPPER=mpicc
2152         enable_mpitests=yes
2153         ]
2154 )
2155
2156 if test x$enable_mpitests != xno; then
2157         AC_MSG_CHECKING([whether mpitests can be built])
2158         oldcc=$CC
2159         CC=$MPICC_WRAPPER
2160         AC_LINK_IFELSE(
2161             [AC_LANG_PROGRAM([[
2162                     #include <mpi.h>
2163                 ]],[[
2164                     int flag;
2165                     MPI_Initialized(&flag);
2166                 ]])],
2167             [
2168                     AC_MSG_RESULT([yes])
2169             ],[
2170                     AC_MSG_RESULT([no])
2171                     enable_mpitests=no
2172         ])
2173         CC=$oldcc
2174 fi
2175 AC_SUBST(MPICC_WRAPPER)
2176
2177 AC_MSG_NOTICE([Enabling Lustre configure options for libsysio])
2178 ac_configure_args="$ac_configure_args --with-lustre-hack --with-sockets"
2179
2180 LC_CONFIG_PINGER
2181 LC_CONFIG_LIBLUSTRE_RECOVERY
2182 ])
2183
2184 AC_DEFUN([LC_CONFIG_LRU_RESIZE],
2185 [AC_MSG_CHECKING([whether to enable lru self-adjusting])
2186 AC_ARG_ENABLE([lru_resize],
2187         AC_HELP_STRING([--enable-lru-resize],
2188                         [enable lru resize support]),
2189         [],[enable_lru_resize='yes'])
2190 AC_MSG_RESULT([$enable_lru_resize])
2191 if test x$enable_lru_resize != xno; then
2192    AC_DEFINE(HAVE_LRU_RESIZE_SUPPORT, 1, [Enable lru resize support])
2193 fi
2194 ])
2195
2196 #
2197 # LC_CONFIG_QUOTA
2198 #
2199 # whether to enable quota support global control
2200 #
2201 AC_DEFUN([LC_CONFIG_QUOTA],
2202 [AC_ARG_ENABLE([quota],
2203         AC_HELP_STRING([--enable-quota],
2204                         [enable quota support]),
2205         [],[enable_quota='yes'])
2206 ])
2207
2208 # whether to enable quota support(kernel modules)
2209 AC_DEFUN([LC_QUOTA_MODULE],
2210 [if test x$enable_quota != xno; then
2211     LB_LINUX_CONFIG([QUOTA],[
2212         enable_quota_module='yes'
2213         AC_DEFINE(HAVE_QUOTA_SUPPORT, 1, [Enable quota support])
2214     ],[
2215         enable_quota_module='no'
2216         AC_MSG_WARN([quota is not enabled because the kernel - lacks quota support])
2217     ])
2218 fi
2219 ])
2220
2221 AC_DEFUN([LC_QUOTA],
2222 [#check global
2223 LC_CONFIG_QUOTA
2224 #check for utils
2225 AC_CHECK_HEADER(sys/quota.h,
2226                 [AC_DEFINE(HAVE_SYS_QUOTA_H, 1, [Define to 1 if you have <sys/quota.h>.])],
2227                 [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
2228 ])
2229
2230 AC_DEFUN([LC_QUOTA_READ],
2231 [AC_MSG_CHECKING([if kernel supports quota_read])
2232 LB_LINUX_TRY_COMPILE([
2233         #include <linux/fs.h>
2234 ],[
2235         struct super_operations sp;
2236         void *i = (void *)sp.quota_read;
2237 ],[
2238         AC_MSG_RESULT([yes])
2239         AC_DEFINE(KERNEL_SUPPORTS_QUOTA_READ, 1, [quota_read found])
2240 ],[
2241         AC_MSG_RESULT([no])
2242 ])
2243 ])
2244
2245 #
2246 # LC_CONFIG_SPLIT
2247 #
2248 # whether to enable split support
2249 #
2250 AC_DEFUN([LC_CONFIG_SPLIT],
2251 [AC_MSG_CHECKING([whether to enable split support])
2252 AC_ARG_ENABLE([split],
2253         AC_HELP_STRING([--enable-split],
2254                         [enable split support]),
2255         [],[enable_split='no'])
2256 AC_MSG_RESULT([$enable_split])
2257 if test x$enable_split != xno; then
2258    AC_DEFINE(HAVE_SPLIT_SUPPORT, 1, [enable split support])
2259 fi
2260 ])
2261
2262 #
2263 # LC_COOKIE_FOLLOW_LINK
2264 #
2265 # kernel 2.6.13+ ->follow_link returns a cookie
2266 #
2267
2268 AC_DEFUN([LC_COOKIE_FOLLOW_LINK],
2269 [AC_MSG_CHECKING([if inode_operations->follow_link returns a cookie])
2270 LB_LINUX_TRY_COMPILE([
2271         #include <linux/fs.h>
2272         #include <linux/namei.h>
2273 ],[
2274         struct dentry dentry;
2275         struct nameidata nd;
2276
2277         dentry.d_inode->i_op->put_link(&dentry, &nd, NULL);
2278 ],[
2279         AC_DEFINE(HAVE_COOKIE_FOLLOW_LINK, 1, [inode_operations->follow_link returns a cookie])
2280         AC_MSG_RESULT([yes])
2281 ],[
2282         AC_MSG_RESULT([no])
2283 ])
2284 ])
2285
2286 #
2287 # LC_FUNC_RCU
2288 #
2289 # kernels prior than 2.6.0(?) have no RCU supported; in kernel 2.6.5(SUSE),
2290 # call_rcu takes three parameters.
2291 #
2292 AC_DEFUN([LC_FUNC_RCU],
2293 [AC_MSG_CHECKING([if kernel have RCU supported])
2294 LB_LINUX_TRY_COMPILE([
2295         #include <linux/rcupdate.h>
2296 ],[],[
2297         AC_DEFINE(HAVE_RCU, 1, [have RCU defined])
2298         AC_MSG_RESULT([yes])
2299
2300         AC_MSG_CHECKING([if call_rcu takes three parameters])
2301         LB_LINUX_TRY_COMPILE([
2302                 #include <linux/rcupdate.h>
2303         ],[
2304                 struct rcu_head rh;
2305                 call_rcu(&rh, (void (*)(struct rcu_head *))1, NULL);
2306         ],[
2307                 AC_DEFINE(HAVE_CALL_RCU_PARAM, 1, [call_rcu takes three parameters])
2308                 AC_MSG_RESULT([yes])
2309         ],[
2310                 AC_MSG_RESULT([no])
2311         ])
2312
2313 ],[
2314         AC_MSG_RESULT([no])
2315 ])
2316 ])
2317
2318 #
2319 # LC_QUOTA64
2320 # linux kernel have 64-bit limits support
2321 #
2322 AC_DEFUN([LC_QUOTA64],
2323 [if test x$enable_quota_module = xyes -a x$enable_server = xyes ; then
2324         AC_MSG_CHECKING([if kernel has 64-bit quota limits support])
2325         LB_LINUX_TRY_COMPILE([
2326                 #include <linux/kernel.h>
2327                 #include <linux/fs.h>
2328                 #include <linux/quotaio_v2.h>
2329                 int versions[] = V2_INITQVERSIONS_R1;
2330                 struct v2_disk_dqblk_r1 dqblk_r1;
2331         ],[],[
2332                 AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
2333                 AC_MSG_RESULT([yes])
2334         ],[
2335         tmp_flags="$EXTRA_KCFLAGS"
2336         EXTRA_KCFLAGS="-I$LINUX/fs"
2337         LB_LINUX_TRY_COMPILE([
2338                 #include <linux/kernel.h>
2339                 #include <linux/fs.h>
2340                 #include <quotaio_v2.h>
2341                 struct v2r1_disk_dqblk dqblk_r1;
2342         ],[],[
2343                 AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
2344                 AC_MSG_RESULT([yes])
2345         ],[
2346                 LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
2347                         AC_MSG_ERROR([You have got no 64-bit kernel quota support.])
2348                 ],[])
2349                 AC_MSG_RESULT([no])
2350         ])
2351         EXTRA_KCFLAGS=$tmp_flags
2352         ])
2353 fi
2354 ])
2355
2356 # LC_SECURITY_PLUG  # for SLES10 SP2
2357 # check security plug in sles10 sp2 kernel
2358 AC_DEFUN([LC_SECURITY_PLUG],
2359 [AC_MSG_CHECKING([If kernel has security plug support])
2360 LB_LINUX_TRY_COMPILE([
2361         #include <linux/fs.h>
2362 ],[
2363         struct dentry   *dentry;
2364         struct vfsmount *mnt;
2365         struct iattr    *iattr;
2366
2367         notify_change(dentry, mnt, iattr);
2368 ],[
2369         AC_MSG_RESULT(yes)
2370         AC_DEFINE(HAVE_SECURITY_PLUG, 1,
2371                 [SLES10 SP2 use extra parameter in vfs])
2372 ],[
2373         AC_MSG_RESULT(no)
2374 ])
2375 ])
2376
2377 AC_DEFUN([LC_PERCPU_COUNTER],
2378 [AC_MSG_CHECKING([if have struct percpu_counter defined])
2379 LB_LINUX_TRY_COMPILE([
2380         #include <linux/percpu_counter.h>
2381 ],[],[
2382         AC_DEFINE(HAVE_PERCPU_COUNTER, 1, [percpu_counter found])
2383         AC_MSG_RESULT([yes])
2384
2385         AC_MSG_CHECKING([if percpu_counter_inc takes the 2nd argument])
2386         LB_LINUX_TRY_COMPILE([
2387                 #include <linux/percpu_counter.h>
2388         ],[
2389                 struct percpu_counter c;
2390                 percpu_counter_init(&c, 0);
2391         ],[
2392                 AC_DEFINE(HAVE_PERCPU_2ND_ARG, 1, [percpu_counter_init has two
2393                                                    arguments])
2394                 AC_MSG_RESULT([yes])
2395         ],[
2396                 AC_MSG_RESULT([no])
2397         ])
2398 ],[
2399         AC_MSG_RESULT([no])
2400 ])
2401 ])
2402
2403 AC_DEFUN([LC_TASK_CLENV_TUX_INFO],
2404 [AC_MSG_CHECKING([tux_info])
2405 LB_LINUX_TRY_COMPILE([
2406         #include <linux/sched.h>
2407 ],[
2408         struct task_struct task;
2409         &task.tux_info;
2410 ],[
2411         AC_MSG_RESULT([yes])
2412         AC_DEFINE(LL_TASK_CL_ENV, tux_info, [have tux_info])
2413         have_task_clenv_store='yes'
2414 ],[
2415         AC_MSG_RESULT([no])
2416 ])
2417 ])
2418
2419 AC_DEFUN([LC_TASK_CLENV_STORE],
2420 [
2421         AC_MSG_CHECKING([if we can store cl_env in task_struct])
2422         if test x$have_task_clenv_store != xyes ; then
2423                 LC_TASK_CLENV_TUX_INFO
2424         fi
2425 ])
2426
2427 #
2428 # LC_CONFIGURE
2429 #
2430 # other configure checks
2431 #
2432 AC_DEFUN([LC_CONFIGURE],
2433 [LC_CONFIG_OBD_BUFFER_SIZE
2434
2435 if test $target_cpu == "i686" -o $target_cpu == "x86_64"; then
2436         CFLAGS="$CFLAGS -Werror"
2437 fi
2438
2439 # include/liblustre.h
2440 AC_CHECK_HEADERS([sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
2441
2442 # liblustre/llite_lib.h
2443 AC_CHECK_HEADERS([xtio.h file.h])
2444
2445 # liblustre/dir.c
2446 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
2447
2448 # liblustre/lutil.c
2449 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h catamount/data.h])
2450 AC_CHECK_FUNCS([inet_ntoa])
2451
2452 # libsysio/src/readlink.c
2453 LC_READLINK_SSIZE_T
2454
2455 # lvfs/prng.c - depends on linux/types.h from liblustre/dir.c
2456 AC_CHECK_HEADERS([linux/random.h], [], [],
2457                  [#ifdef HAVE_LINUX_TYPES_H
2458                   # include <linux/types.h>
2459                   #endif
2460                  ])
2461
2462 # utils/llverfs.c
2463 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
2464
2465 # check for -lz support
2466 ZLIB=""
2467 AC_CHECK_LIB([z],
2468              [adler32],
2469              [AC_CHECK_HEADERS([zlib.h],
2470                                [ZLIB="-lz"
2471                                 AC_DEFINE([HAVE_ADLER], 1,
2472                                           [support alder32 checksum type])],
2473                                [AC_MSG_WARN([No zlib-devel package found,
2474                                              unable to use adler32 checksum])])],
2475              [AC_MSG_WARN([No zlib package found, unable to use adler32 checksum])]
2476 )
2477 AC_SUBST(ZLIB)
2478
2479 # Super safe df
2480 AC_ARG_ENABLE([mindf],
2481       AC_HELP_STRING([--enable-mindf],
2482                       [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
2483       [],[])
2484 if test "$enable_mindf" = "yes" ;  then
2485       AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])
2486 fi
2487
2488 AC_ARG_ENABLE([fail_alloc],
2489         AC_HELP_STRING([--disable-fail-alloc],
2490                 [disable randomly alloc failure]),
2491         [],[enable_fail_alloc=yes])
2492 AC_MSG_CHECKING([whether to randomly failing memory alloc])
2493 AC_MSG_RESULT([$enable_fail_alloc])
2494 if test x$enable_fail_alloc != xno ; then
2495         AC_DEFINE([RANDOM_FAIL_ALLOC], 1, [enable randomly alloc failure])
2496 fi
2497
2498 AC_ARG_ENABLE([invariants],
2499         AC_HELP_STRING([--enable-invariants],
2500                 [enable invariant checking (cpu intensive)]),
2501         [],[])
2502 AC_MSG_CHECKING([whether to check invariants (expensive cpu-wise)])
2503 AC_MSG_RESULT([$enable_invariants])
2504 if test x$enable_invariants = xyes ; then
2505         AC_DEFINE([INVARIANT_CHECK], 1, [enable invariant checking])
2506 fi
2507
2508 AC_ARG_ENABLE([lu_ref],
2509         AC_HELP_STRING([--enable-lu_ref],
2510                 [enable lu_ref reference tracking code]),
2511         [],[])
2512 AC_MSG_CHECKING([whether to track references with lu_ref])
2513 AC_MSG_RESULT([$enable_lu_ref])
2514 if test x$enable_lu_ref = xyes ; then
2515         AC_DEFINE([USE_LU_REF], 1, [enable lu_ref reference tracking code])
2516 fi
2517
2518          #2.6.29
2519          LC_WRITE_BEGIN_END
2520          LC_D_OBTAIN_ALIAS
2521          LC_BLKDEV_PUT_2ARGS
2522          LC_DENTRY_OPEN_4ARGS
2523
2524 ])
2525
2526 #
2527 # LC_CONDITIONALS
2528 #
2529 # AM_CONDITIONALS for lustre
2530 #
2531 AC_DEFUN([LC_CONDITIONALS],
2532 [AM_CONDITIONAL(LIBLUSTRE, test x$enable_liblustre = xyes)
2533 AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
2534 AM_CONDITIONAL(LIBLUSTRE_TESTS, test x$enable_liblustre_tests = xyes)
2535 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
2536 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
2537 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
2538 AM_CONDITIONAL(QUOTA, test x$enable_quota_module = xyes)
2539 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
2540 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
2541 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
2542 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
2543 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
2544 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
2545 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
2546 ])
2547
2548 #
2549 # LC_CONFIG_FILES
2550 #
2551 # files that should be generated with AC_OUTPUT
2552 #
2553 AC_DEFUN([LC_CONFIG_FILES],
2554 [AC_CONFIG_FILES([
2555 lustre/Makefile
2556 lustre/autoMakefile
2557 lustre/autoconf/Makefile
2558 lustre/conf/Makefile
2559 lustre/contrib/Makefile
2560 lustre/doc/Makefile
2561 lustre/include/Makefile
2562 lustre/include/lustre_ver.h
2563 lustre/include/linux/Makefile
2564 lustre/include/lustre/Makefile
2565 lustre/kernel_patches/targets/2.6-rhel5.target
2566 lustre/kernel_patches/targets/2.6-sles10.target
2567 lustre/kernel_patches/targets/2.6-sles11.target
2568 lustre/kernel_patches/targets/2.6-oel5.target
2569 lustre/kernel_patches/targets/2.6-fc11.target
2570 lustre/kernel_patches/targets/2.6-fc12.target
2571 lustre/ldlm/Makefile
2572 lustre/fid/Makefile
2573 lustre/fid/autoMakefile
2574 lustre/liblustre/Makefile
2575 lustre/liblustre/tests/Makefile
2576 lustre/liblustre/tests/mpi/Makefile
2577 lustre/llite/Makefile
2578 lustre/llite/autoMakefile
2579 lustre/lclient/Makefile
2580 lustre/lov/Makefile
2581 lustre/lov/autoMakefile
2582 lustre/lvfs/Makefile
2583 lustre/lvfs/autoMakefile
2584 lustre/mdc/Makefile
2585 lustre/mdc/autoMakefile
2586 lustre/lmv/Makefile
2587 lustre/lmv/autoMakefile
2588 lustre/mds/Makefile
2589 lustre/mds/autoMakefile
2590 lustre/mdt/Makefile
2591 lustre/mdt/autoMakefile
2592 lustre/cmm/Makefile
2593 lustre/cmm/autoMakefile
2594 lustre/mdd/Makefile
2595 lustre/mdd/autoMakefile
2596 lustre/fld/Makefile
2597 lustre/fld/autoMakefile
2598 lustre/obdclass/Makefile
2599 lustre/obdclass/autoMakefile
2600 lustre/obdclass/linux/Makefile
2601 lustre/obdecho/Makefile
2602 lustre/obdecho/autoMakefile
2603 lustre/obdfilter/Makefile
2604 lustre/obdfilter/autoMakefile
2605 lustre/osc/Makefile
2606 lustre/osc/autoMakefile
2607 lustre/ost/Makefile
2608 lustre/ost/autoMakefile
2609 lustre/osd-ldiskfs/Makefile
2610 lustre/osd-ldiskfs/autoMakefile
2611 lustre/mgc/Makefile
2612 lustre/mgc/autoMakefile
2613 lustre/mgs/Makefile
2614 lustre/mgs/autoMakefile
2615 lustre/ptlrpc/Makefile
2616 lustre/ptlrpc/autoMakefile
2617 lustre/ptlrpc/gss/Makefile
2618 lustre/ptlrpc/gss/autoMakefile
2619 lustre/quota/Makefile
2620 lustre/quota/autoMakefile
2621 lustre/scripts/Makefile
2622 lustre/tests/Makefile
2623 lustre/tests/mpi/Makefile
2624 lustre/utils/Makefile
2625 lustre/utils/gss/Makefile
2626 lustre/obdclass/darwin/Makefile
2627 ])
2628 ])