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