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