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