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