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