Whamcloud - gitweb
b=13677
[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 # LC_CONFIG_EXT3
51 #
52 # that ext3 is enabled in the kernel
53 #
54 AC_DEFUN([LC_CONFIG_EXT3],
55 [LB_LINUX_CONFIG([EXT3_FS],[],[
56         LB_LINUX_CONFIG([EXT3_FS_MODULE],[],[$2])
57 ])
58 LB_LINUX_CONFIG([EXT3_FS_XATTR],[$1],[$3])
59 ])
60
61 #
62 # LC_FSHOOKS
63 #
64 # If we have (and can build) fshooks.h
65 #
66 AC_DEFUN([LC_FSHOOKS],
67 [LB_CHECK_FILE([$LINUX/include/linux/fshooks.h],[
68         AC_MSG_CHECKING([if fshooks.h can be compiled])
69         LB_LINUX_TRY_COMPILE([
70                 #include <linux/fshooks.h>
71         ],[],[
72                 AC_MSG_RESULT([yes])
73         ],[
74                 AC_MSG_RESULT([no])
75                 AC_MSG_WARN([You might have better luck with gcc 3.3.x.])
76                 AC_MSG_WARN([You can set CC=gcc33 before running configure.])
77                 AC_MSG_ERROR([Your compiler cannot build fshooks.h.])
78         ])
79 $1
80 ],[
81 $2
82 ])
83 ])
84
85 #
86 # LC_STRUCT_KIOBUF
87 #
88 # rh 2.4.18 has iobuf->dovary, but other kernels do not
89 #
90 AC_DEFUN([LC_STRUCT_KIOBUF],
91 [AC_MSG_CHECKING([if struct kiobuf has a dovary field])
92 LB_LINUX_TRY_COMPILE([
93         #include <linux/iobuf.h>
94 ],[
95         struct kiobuf iobuf;
96         iobuf.dovary = 1;
97 ],[
98         AC_MSG_RESULT([yes])
99         AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field])
100 ],[
101         AC_MSG_RESULT([no])
102 ])
103 ])
104
105 #
106 # LC_FUNC_COND_RESCHED
107 #
108 # cond_resched() was introduced in 2.4.20
109 #
110 AC_DEFUN([LC_FUNC_COND_RESCHED],
111 [AC_MSG_CHECKING([if kernel offers cond_resched])
112 LB_LINUX_TRY_COMPILE([
113         #include <linux/sched.h>
114 ],[
115         cond_resched();
116 ],[
117         AC_MSG_RESULT([yes])
118         AC_DEFINE(HAVE_COND_RESCHED, 1, [cond_resched found])
119 ],[
120         AC_MSG_RESULT([no])
121 ])
122 ])
123
124 #
125 # LC_FUNC_ZAP_PAGE_RANGE
126 #
127 # if zap_page_range() takes a vma arg
128 #
129 AC_DEFUN([LC_FUNC_ZAP_PAGE_RANGE],
130 [AC_MSG_CHECKING([if zap_page_range with vma parameter])
131 ZAP_PAGE_RANGE_VMA="`grep -c 'zap_page_range.*struct vm_area_struct' $LINUX/include/linux/mm.h`"
132 if test "$ZAP_PAGE_RANGE_VMA" != 0 ; then
133         AC_DEFINE(ZAP_PAGE_RANGE_VMA, 1, [zap_page_range with vma parameter])
134         AC_MSG_RESULT([yes])
135 else
136         AC_MSG_RESULT([no])
137 fi
138 ])
139
140 #
141 # LC_FUNC_PDE
142 #
143 # if proc_fs.h defines PDE()
144 #
145 AC_DEFUN([LC_FUNC_PDE],
146 [AC_MSG_CHECKING([if kernel defines PDE])
147 HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
148 if test "$HAVE_PDE" != 0 ; then
149         AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE])
150         AC_MSG_RESULT([yes])
151 else
152         AC_MSG_RESULT([no])
153 fi
154 ])
155
156 #
157 # LC_FUNC_FILEMAP_FDATASYNC
158 #
159 # if filemap_fdatasync() exists
160 #
161 AC_DEFUN([LC_FUNC_FILEMAP_FDATAWRITE],
162 [AC_MSG_CHECKING([whether filemap_fdatawrite() is defined])
163 LB_LINUX_TRY_COMPILE([
164         #include <linux/fs.h>
165 ],[
166         int (*foo)(struct address_space *)= filemap_fdatawrite;
167 ],[
168         AC_MSG_RESULT([yes])
169         AC_DEFINE(HAVE_FILEMAP_FDATAWRITE, 1, [filemap_fdatawrite() found])
170 ],[
171         AC_MSG_RESULT([no])
172 ])
173 ])
174
175 #
176 # LC_FUNC_DIRECT_IO
177 #
178 # if direct_IO takes a struct file argument
179 #
180 AC_DEFUN([LC_FUNC_DIRECT_IO],
181 [AC_MSG_CHECKING([if kernel passes struct file to direct_IO])
182 HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
183 if test "$HAVE_DIO_FILE" != 0 ; then
184         AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO])
185         AC_MSG_RESULT(yes)
186 else
187         AC_MSG_RESULT(no)
188 fi
189 ])
190
191 #
192 # LC_HEADER_MM_INLINE
193 #
194 # RHEL kernels define page_count in mm_inline.h
195 #
196 AC_DEFUN([LC_HEADER_MM_INLINE],
197 [AC_MSG_CHECKING([if kernel has mm_inline.h header])
198 LB_LINUX_TRY_COMPILE([
199         #include <linux/mm_inline.h>
200 ],[
201         #ifndef page_count
202         #error mm_inline.h does not define page_count
203         #endif
204 ],[
205         AC_MSG_RESULT([yes])
206         AC_DEFINE(HAVE_MM_INLINE, 1, [mm_inline found])
207 ],[
208         AC_MSG_RESULT([no])
209 ])
210 ])
211
212 #
213 # LC_STRUCT_INODE
214 #
215 # if inode->i_alloc_sem exists
216 #
217 AC_DEFUN([LC_STRUCT_INODE],
218 [AC_MSG_CHECKING([if struct inode has i_alloc_sem])
219 LB_LINUX_TRY_COMPILE([
220         #include <linux/fs.h>
221         #include <linux/version.h>
222 ],[
223         #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24))
224         #error "down_read_trylock broken before 2.4.24"
225         #endif
226         struct inode i;
227         return (char *)&i.i_alloc_sem - (char *)&i;
228 ],[
229         AC_MSG_RESULT([yes])
230         AC_DEFINE(HAVE_I_ALLOC_SEM, 1, [struct inode has i_alloc_sem])
231 ],[
232         AC_MSG_RESULT([no])
233 ])
234 ])
235
236 #
237 # LC_FUNC_REGISTER_CACHE
238 #
239 # if register_cache() is defined by kernel
240 #
241 AC_DEFUN([LC_FUNC_REGISTER_CACHE],
242 [AC_MSG_CHECKING([if kernel defines register_cache()])
243 LB_LINUX_TRY_COMPILE([
244         #include <linux/list.h>
245         #include <linux/cache_def.h>
246 ],[
247         struct cache_definition cache;
248 ],[
249         AC_MSG_RESULT([yes])
250         AC_DEFINE(HAVE_REGISTER_CACHE, 1, [register_cache found])
251         AC_MSG_CHECKING([if kernel expects return from cache shrink function])
252         HAVE_CACHE_RETURN_INT="`grep -c 'int.*shrink' $LINUX/include/linux/cache_def.h`"
253         if test "$HAVE_CACHE_RETURN_INT" != 0 ; then
254                 AC_DEFINE(HAVE_CACHE_RETURN_INT, 1, [kernel expects return from shrink_cache])
255                 AC_MSG_RESULT(yes)
256         else
257                 AC_MSG_RESULT(no)
258         fi
259 ],[
260         AC_MSG_RESULT([no])
261 ])
262 ])
263
264 #
265 # LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
266 #
267 # check for our patched grab_cache_page_nowait_gfp() function
268 #
269 AC_DEFUN([LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP],
270 [AC_MSG_CHECKING([if kernel defines grab_cache_page_nowait_gfp()])
271 HAVE_GCPN_GFP="`grep -c 'grab_cache_page_nowait_gfp' $LINUX/include/linux/pagemap.h`"
272 if test "$HAVE_GCPN_GFP" != 0 ; then
273         AC_DEFINE(HAVE_GRAB_CACHE_PAGE_NOWAIT_GFP, 1,
274                 [kernel has grab_cache_page_nowait_gfp()])
275         AC_MSG_RESULT(yes)
276 else
277         AC_MSG_RESULT(no)
278 fi
279 ])
280
281 #
282 # LC_FUNC_DEV_SET_RDONLY
283 #
284 # check for the old-style dev_set_rdonly which took an extra "devno" param
285 # and can only set a single device to discard writes at one time
286 #
287 AC_DEFUN([LC_FUNC_DEV_SET_RDONLY],
288 [AC_MSG_CHECKING([if kernel has new dev_set_rdonly])
289 LB_LINUX_TRY_COMPILE([
290         #include <linux/fs.h>
291 ],[
292         #ifndef HAVE_CLEAR_RDONLY_ON_PUT
293         #error needs to be patched by lustre kernel patches from Lustre version 1.4.3 or above.
294         #endif
295 ],[
296         AC_MSG_RESULT([yes])
297         AC_DEFINE(HAVE_DEV_SET_RDONLY, 1, [kernel has new dev_set_rdonly])
298 ],[
299         AC_MSG_RESULT([no, Linux kernel source needs to be patches by lustre 
300 kernel patches from Lustre version 1.4.3 or above.])
301 ])
302 ])
303
304 #
305 # LC_CONFIG_BACKINGFS
306 #
307 # setup, check the backing filesystem
308 #
309 AC_DEFUN([LC_CONFIG_BACKINGFS],
310 [
311 BACKINGFS="ldiskfs"
312
313 if test x$with_ldiskfs = xno ; then
314         BACKINGFS="ext3"
315
316         if test x$linux25$enable_server = xyesyes ; then
317                 AC_MSG_ERROR([ldiskfs is required for 2.6-based servers.])
318         fi
319
320         # --- Check that ext3 and ext3 xattr are enabled in the kernel
321         LC_CONFIG_EXT3([],[
322                 AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel])
323         ],[
324                 AC_MSG_WARN([Lustre requires that extended attributes for ext3 are enabled in the kernel])
325                 AC_MSG_WARN([This build may fail.])
326         ])
327 else
328         # ldiskfs is enabled
329         LB_DEFINE_LDISKFS_OPTIONS
330 fi #ldiskfs
331
332 AC_MSG_CHECKING([which backing filesystem to use])
333 AC_MSG_RESULT([$BACKINGFS])
334 AC_SUBST(BACKINGFS)
335 ])
336
337 #
338 # LC_CONFIG_PINGER
339 #
340 # the pinger is temporary, until we have the recovery node in place
341 #
342 AC_DEFUN([LC_CONFIG_PINGER],
343 [AC_MSG_CHECKING([whether to enable pinger support])
344 AC_ARG_ENABLE([pinger],
345         AC_HELP_STRING([--disable-pinger],
346                         [disable recovery pinger support]),
347         [],[enable_pinger='yes'])
348 AC_MSG_RESULT([$enable_pinger])
349 if test x$enable_pinger != xno ; then
350   AC_DEFINE(ENABLE_PINGER, 1, Use the Pinger)
351 fi
352 ])
353
354 #
355 # LC_CONFIG_CHECKSUM
356 #
357 # do checksum of bulk data between client and OST
358 #
359 AC_DEFUN([LC_CONFIG_CHECKSUM],
360 [AC_MSG_CHECKING([whether to enable data checksum support])
361 AC_ARG_ENABLE([checksum],
362        AC_HELP_STRING([--disable-checksum],
363                        [disable data checksum support]),
364        [],[enable_checksum='yes'])
365 AC_MSG_RESULT([$enable_checksum])
366 if test x$enable_checksum != xno ; then
367   AC_DEFINE(ENABLE_CHECKSUM, 1, do data checksums)
368 fi
369 ])
370
371 #
372 # LC_CONFIG_HEALTH_CHECK_WRITE
373 #
374 # Turn on the actual write to the disk
375 #
376 AC_DEFUN([LC_CONFIG_HEALTH_CHECK_WRITE],
377 [AC_MSG_CHECKING([whether to enable a write with the health check])
378 AC_ARG_ENABLE([health-write],
379         AC_HELP_STRING([--enable-health-write],
380                         [enable disk writes when doing health check]),
381         [],[enable_health_write='no'])
382 AC_MSG_RESULT([$enable_health_write])
383 if test x$enable_health_write == xyes ; then
384   AC_DEFINE(USE_HEALTH_CHECK_WRITE, 1, Write when Checking Health)
385 fi
386 ])
387
388 #
389 # LC_CONFIG_LIBLUSTRE_RECOVERY
390 #
391 AC_DEFUN([LC_CONFIG_LIBLUSTRE_RECOVERY],
392 [AC_MSG_CHECKING([whether to enable liblustre recovery support])
393 AC_ARG_ENABLE([liblustre-recovery],
394         AC_HELP_STRING([--disable-liblustre-recovery],
395                         [disable liblustre recovery support]),
396         [],[enable_liblustre_recovery='yes'])
397 AC_MSG_RESULT([$enable_liblustre_recovery])
398 if test x$enable_liblustre_recovery != xno ; then
399   AC_DEFINE(ENABLE_LIBLUSTRE_RECOVERY, 1, Liblustre Can Recover)
400 fi
401 ])
402
403 #
404 # LC_CONFIG_OBD_BUFFER_SIZE
405 #
406 # the maximum buffer size of lctl ioctls
407 #
408 AC_DEFUN([LC_CONFIG_OBD_BUFFER_SIZE],
409 [AC_MSG_CHECKING([maximum OBD ioctl size])
410 AC_ARG_WITH([obd-buffer-size],
411         AC_HELP_STRING([--with-obd-buffer-size=[size]],
412                         [set lctl ioctl maximum bytes (default=8192)]),
413         [
414                 OBD_BUFFER_SIZE=$with_obd_buffer_size
415         ],[
416                 OBD_BUFFER_SIZE=8192
417         ])
418 AC_MSG_RESULT([$OBD_BUFFER_SIZE bytes])
419 AC_DEFINE_UNQUOTED(OBD_MAX_IOCTL_BUFFER, $OBD_BUFFER_SIZE, [IOCTL Buffer Size])
420 ])
421
422 #
423 # LC_STRUCT_STATFS
424 #
425 # AIX does not have statfs.f_namelen
426 #
427 AC_DEFUN([LC_STRUCT_STATFS],
428 [AC_MSG_CHECKING([if struct statfs has a f_namelen field])
429 LB_LINUX_TRY_COMPILE([
430         #include <linux/vfs.h>
431 ],[
432         struct statfs sfs;
433         sfs.f_namelen = 1;
434 ],[
435         AC_MSG_RESULT([yes])
436         AC_DEFINE(HAVE_STATFS_NAMELEN, 1, [struct statfs has a namelen field])
437 ],[
438         AC_MSG_RESULT([no])
439 ])
440 ])
441
442 #
443 # LC_READLINK_SSIZE_T
444 #
445 AC_DEFUN([LC_READLINK_SSIZE_T],
446 [AC_MSG_CHECKING([if readlink returns ssize_t])
447 AC_TRY_COMPILE([
448         #include <unistd.h>
449 ],[
450         ssize_t readlink(const char *, char *, size_t);
451 ],[
452         AC_MSG_RESULT([yes])
453         AC_DEFINE(HAVE_POSIX_1003_READLINK, 1, [readlink returns ssize_t])
454 ],[
455         AC_MSG_RESULT([no])
456 ])
457 ])
458
459 AC_DEFUN([LC_FUNC_PAGE_MAPPED],
460 [AC_MSG_CHECKING([if kernel offers page_mapped])
461 LB_LINUX_TRY_COMPILE([
462         #include <linux/mm.h>
463 ],[
464         page_mapped(NULL);
465 ],[
466         AC_MSG_RESULT([yes])
467         AC_DEFINE(HAVE_PAGE_MAPPED, 1, [page_mapped found])
468 ],[
469         AC_MSG_RESULT([no])
470 ])
471 ])
472
473 AC_DEFUN([LC_STRUCT_FILE_OPS_UNLOCKED_IOCTL],
474 [AC_MSG_CHECKING([if struct file_operations has an unlocked_ioctl field])
475 LB_LINUX_TRY_COMPILE([
476         #include <linux/fs.h>
477 ],[
478         struct file_operations fops;
479         &fops.unlocked_ioctl;
480 ],[
481         AC_MSG_RESULT([yes])
482         AC_DEFINE(HAVE_UNLOCKED_IOCTL, 1, [struct file_operations has an unlock ed_ioctl field])
483 ],[
484         AC_MSG_RESULT([no])
485 ])
486 ])
487
488 AC_DEFUN([LC_FILEMAP_POPULATE],
489 [AC_MSG_CHECKING([for exported filemap_populate])
490 LB_LINUX_TRY_COMPILE([
491         #include <asm/page.h>
492         #include <linux/mm.h>
493 ],[
494         filemap_populate(NULL, 0, 0, __pgprot(0), 0, 0);
495 ],[
496         AC_MSG_RESULT([yes])
497         AC_DEFINE(HAVE_FILEMAP_POPULATE, 1, [Kernel exports filemap_populate])
498 ],[
499         AC_MSG_RESULT([no])
500 ])
501 ])
502
503 AC_DEFUN([LC_D_ADD_UNIQUE],
504 [AC_MSG_CHECKING([for d_add_unique])
505 LB_LINUX_TRY_COMPILE([
506         #include <linux/dcache.h>
507 ],[
508        d_add_unique(NULL, NULL);
509 ],[
510         AC_MSG_RESULT([yes])
511         AC_DEFINE(HAVE_D_ADD_UNIQUE, 1, [Kernel has d_add_unique])
512 ],[
513         AC_MSG_RESULT([no])
514 ])
515 ])
516
517 AC_DEFUN([LC_BIT_SPINLOCK_H],
518 [LB_CHECK_FILE([$LINUX/include/linux/bit_spinlock.h],[
519         AC_MSG_CHECKING([if bit_spinlock.h can be compiled])
520         LB_LINUX_TRY_COMPILE([
521                 #include <asm/processor.h>
522                 #include <linux/spinlock.h>
523                 #include <linux/bit_spinlock.h>
524         ],[],[
525                 AC_MSG_RESULT([yes])
526                 AC_DEFINE(HAVE_BIT_SPINLOCK_H, 1, [Kernel has bit_spinlock.h])
527         ],[
528                 AC_MSG_RESULT([no])
529         ])
530 ],
531 [])
532 ])
533
534 #
535 # LC_POSIX_ACL_XATTR
536 #
537 # If we have xattr_acl.h 
538 #
539 AC_DEFUN([LC_XATTR_ACL],
540 [LB_CHECK_FILE([$LINUX/include/linux/xattr_acl.h],[
541         AC_MSG_CHECKING([if xattr_acl.h can be compiled])
542         LB_LINUX_TRY_COMPILE([
543                 #include <linux/xattr_acl.h>
544         ],[],[
545                 AC_MSG_RESULT([yes])
546                 AC_DEFINE(HAVE_XATTR_ACL, 1, [Kernel has xattr_acl])
547         ],[
548                 AC_MSG_RESULT([no])
549         ])
550 ],
551 [])
552 ])
553
554 AC_DEFUN([LC_STRUCT_INTENT_FILE],
555 [AC_MSG_CHECKING([if struct open_intent has a file field])
556 LB_LINUX_TRY_COMPILE([
557         #include <linux/fs.h>
558         #include <linux/namei.h>
559 ],[
560         struct open_intent intent;
561         &intent.file;
562 ],[
563         AC_MSG_RESULT([yes])
564         AC_DEFINE(HAVE_FILE_IN_STRUCT_INTENT, 1, [struct open_intent has a file field])
565 ],[
566         AC_MSG_RESULT([no])
567 ])
568 ])
569
570
571 AC_DEFUN([LC_POSIX_ACL_XATTR_H],
572 [LB_CHECK_FILE([$LINUX/include/linux/posix_acl_xattr.h],[
573         AC_MSG_CHECKING([if linux/posix_acl_xattr.h can be compiled])
574         LB_LINUX_TRY_COMPILE([
575                 #include <linux/posix_acl_xattr.h>
576         ],[],[
577                 AC_MSG_RESULT([yes])
578                 AC_DEFINE(HAVE_LINUX_POSIX_ACL_XATTR_H, 1, [linux/posix_acl_xattr.h found])
579
580         ],[
581                 AC_MSG_RESULT([no])
582         ])
583 $1
584 ],[
585 AC_MSG_RESULT([no])
586 ])
587 ])
588
589 #
590 # LC_EXPORT___IGET
591 # starting from 2.6.19 linux kernel exports __iget()
592 #
593 AC_DEFUN([LC_EXPORT___IGET],
594 [LB_CHECK_SYMBOL_EXPORT([__iget],
595 [fs/inode.c],[
596         AC_DEFINE(HAVE_EXPORT___IGET, 1, [kernel exports __iget])
597 ],[
598 ])
599 ])
600
601
602 AC_DEFUN([LC_LUSTRE_VERSION_H],
603 [LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
604         rm -f "$LUSTRE/include/linux/lustre_version.h"
605 ],[
606         touch "$LUSTRE/include/linux/lustre_version.h"
607         if test x$enable_server = xyes ; then
608                 AC_MSG_WARN([Unpatched kernel detected.])
609                 AC_MSG_WARN([Lustre servers cannot be built with an unpatched kernel;])
610                 AC_MSG_WARN([disabling server build])
611                 enable_server='no'
612         fi
613 ])
614 ])
615
616 AC_DEFUN([LC_FUNC_SET_FS_PWD],
617 [LB_CHECK_SYMBOL_EXPORT([set_fs_pwd],
618 [fs/namespace.c],[
619         AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd is exported])
620 ],[
621 ])
622 ])
623
624
625 #
626 # LC_FUNC_MS_FLOCK_LOCK
627 #
628 # SLES9 kernel has MS_FLOCK_LOCK sb flag
629 #
630 AC_DEFUN([LC_FUNC_MS_FLOCK_LOCK],
631 [AC_MSG_CHECKING([if kernel has MS_FLOCK_LOCK sb flag])
632 LB_LINUX_TRY_COMPILE([
633         #include <linux/fs.h>
634 ],[
635         int flags = MS_FLOCK_LOCK;
636 ],[
637         AC_DEFINE(HAVE_MS_FLOCK_LOCK, 1,
638                 [kernel has MS_FLOCK_LOCK flag])
639         AC_MSG_RESULT([yes])
640 ],[
641         AC_MSG_RESULT([no])
642 ])
643 ])
644
645 #
646 # LC_FUNC_HAVE_CAN_SLEEP_ARG
647 #
648 # SLES9 kernel has third arg can_sleep
649 # in fs/locks.c: flock_lock_file_wait()
650 #
651 AC_DEFUN([LC_FUNC_HAVE_CAN_SLEEP_ARG],
652 [AC_MSG_CHECKING([if kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
653 LB_LINUX_TRY_COMPILE([
654         #include <linux/fs.h>
655 ],[
656         int cansleep;
657         struct file *file;
658         struct file_lock *file_lock;
659         flock_lock_file_wait(file, file_lock, cansleep);
660 ],[
661         AC_DEFINE(HAVE_CAN_SLEEP_ARG, 1,
662                 [kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
663         AC_MSG_RESULT([yes])
664 ],[
665         AC_MSG_RESULT([no])
666 ])
667 ])
668
669 #
670 # LC_FUNC_F_OP_FLOCK
671 #
672 # rhel4.2 kernel has f_op->flock field
673 #
674 AC_DEFUN([LC_FUNC_F_OP_FLOCK],
675 [AC_MSG_CHECKING([if struct file_operations has flock field])
676 LB_LINUX_TRY_COMPILE([
677         #include <linux/fs.h>
678 ],[
679         struct file_operations ll_file_operations_flock;
680         ll_file_operations_flock.flock = NULL;
681 ],[
682         AC_DEFINE(HAVE_F_OP_FLOCK, 1,
683                 [struct file_operations has flock field])
684         AC_MSG_RESULT([yes])
685 ],[
686         AC_MSG_RESULT([no])
687 ])
688 ])
689
690 #
691 # LC_FUNC_MS_FLOCK_LOCK
692 #
693 # SLES9 kernel has MS_FLOCK_LOCK sb flag
694 #
695 AC_DEFUN([LC_FUNC_MS_FLOCK_LOCK],
696 [AC_MSG_CHECKING([if kernel has MS_FLOCK_LOCK sb flag])
697 LB_LINUX_TRY_COMPILE([
698         #include <linux/fs.h>
699 ],[
700         int flags = MS_FLOCK_LOCK;
701 ],[
702         AC_DEFINE(HAVE_MS_FLOCK_LOCK, 1,
703                 [kernel has MS_FLOCK_LOCK flag])
704         AC_MSG_RESULT([yes])
705 ],[
706         AC_MSG_RESULT([no])
707 ])
708 ])
709
710 #
711 # LC_FUNC_HAVE_CAN_SLEEP_ARG
712 #
713 # SLES9 kernel has third arg can_sleep
714 # in fs/locks.c: flock_lock_file_wait()
715 #
716 AC_DEFUN([LC_FUNC_HAVE_CAN_SLEEP_ARG],
717 [AC_MSG_CHECKING([if kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
718 LB_LINUX_TRY_COMPILE([
719         #include <linux/fs.h>
720 ],[
721         int cansleep;
722         struct file *file;
723         struct file_lock *file_lock;
724         flock_lock_file_wait(file, file_lock, cansleep);
725 ],[
726         AC_DEFINE(HAVE_CAN_SLEEP_ARG, 1,
727                 [kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
728         AC_MSG_RESULT([yes])
729 ],[
730         AC_MSG_RESULT([no])
731 ])
732 ])
733
734 #
735 # LC_TASK_PPTR
736 #
737 # task struct has p_pptr instead of parent
738 #
739 AC_DEFUN([LC_TASK_PPTR],
740 [AC_MSG_CHECKING([task p_pptr found])
741 LB_LINUX_TRY_COMPILE([
742         #include <linux/sched.h>
743 ],[
744         struct task_struct *p;
745         
746         p = p->p_pptr;
747 ],[
748         AC_MSG_RESULT([yes])
749         AC_DEFINE(HAVE_TASK_PPTR, 1, [task p_pptr found])
750 ],[
751         AC_MSG_RESULT([no])
752 ])
753 ])
754
755 #
756 # LC_FUNC_F_OP_FLOCK
757 #
758 # rhel4.2 kernel has f_op->flock field
759 #
760 AC_DEFUN([LC_FUNC_F_OP_FLOCK],
761 [AC_MSG_CHECKING([if struct file_operations has flock field])
762 LB_LINUX_TRY_COMPILE([
763         #include <linux/fs.h>
764 ],[
765         struct file_operations ll_file_operations_flock;
766         ll_file_operations_flock.flock = NULL;
767 ],[
768         AC_DEFINE(HAVE_F_OP_FLOCK, 1,
769                 [struct file_operations has flock field])
770         AC_MSG_RESULT([yes])
771 ],[
772         AC_MSG_RESULT([no])
773 ])
774 ])
775
776 # LC_INODE_I_MUTEX
777 # after 2.6.15 inode have i_mutex intead of i_sem
778 AC_DEFUN([LC_INODE_I_MUTEX],
779 [AC_MSG_CHECKING([use inode have i_mutex ])
780 LB_LINUX_TRY_COMPILE([
781         #include <linux/mutex.h>
782         #include <linux/fs.h>
783         #undef i_mutex
784 ],[
785         struct inode i;
786
787         mutex_unlock(&i.i_mutex);
788 ],[
789         AC_MSG_RESULT(yes)
790         AC_DEFINE(HAVE_INODE_I_MUTEX, 1,
791                 [after 2.6.15 inode have i_mutex intead of i_sem])
792 ],[
793         AC_MSG_RESULT(NO)
794 ])
795 ])
796
797 # LC_SYMVERFILE
798 # SLES 9 uses a different name for this file - unsure about vanilla kernels
799 # around this version, but it matters for servers only.
800 AC_DEFUN([LC_SYMVERFILE],
801          [AC_MSG_CHECKING([name of symverfile])
802           if grep -q Modules.symvers $LINUX/scripts/Makefile.modpost ; then
803               SYMVERFILE=Modules.symvers
804           else
805               SYMVERFILE=Module.symvers
806           fi
807           AC_MSG_RESULT($SYMVERFILE)
808           AC_SUBST(SYMVERFILE)])
809
810 # LC_DQUOTOFF_MUTEX
811 # after 2.6.17 dquote use mutex instead if semaphore
812 AC_DEFUN([LC_DQUOTOFF_MUTEX],
813 [AC_MSG_CHECKING([use dqonoff_mutex])
814 LB_LINUX_TRY_COMPILE([
815         #include <linux/mutex.h>
816         #include <linux/fs.h>
817         #include <linux/quota.h>
818 ],[
819         struct quota_info dq;
820
821         mutex_unlock(&dq.dqonoff_mutex);
822 ],[
823         AC_MSG_RESULT(yes)
824         AC_DEFINE(HAVE_DQUOTOFF_MUTEX, 1,
825                 [after 2.6.17 dquote use mutex instead if semaphore])
826 ],[
827         AC_MSG_RESULT(NO)
828 ])
829 ])
830
831 #
832 # LC_STATFS_DENTRY_PARAM
833 # starting from 2.6.18 linux kernel uses dentry instead of
834 # super_block for first vfs_statfs argument
835 #
836 AC_DEFUN([LC_STATFS_DENTRY_PARAM],
837 [AC_MSG_CHECKING([first vfs_statfs parameter is dentry])
838 LB_LINUX_TRY_COMPILE([
839         #include <linux/fs.h>
840 ],[
841         int vfs_statfs(struct dentry *, struct kstatfs *);
842 ],[
843         AC_DEFINE(HAVE_STATFS_DENTRY_PARAM, 1,
844                 [first parameter of vfs_statfs is dentry])
845         AC_MSG_RESULT([yes])
846 ],[
847         AC_MSG_RESULT([no])
848 ])
849 ])
850
851 #
852 # LC_VFS_KERN_MOUNT
853 # starting from 2.6.18 kernel don't export do_kern_mount
854 # and want to use vfs_kern_mount instead.
855 #
856 AC_DEFUN([LC_VFS_KERN_MOUNT],
857 [AC_MSG_CHECKING([vfs_kern_mount exist in kernel])
858 LB_LINUX_TRY_COMPILE([
859         #include <linux/mount.h>
860 ],[
861         vfs_kern_mount(NULL, 0, NULL, NULL);
862 ],[
863         AC_DEFINE(HAVE_VFS_KERN_MOUNT, 1,
864                 [vfs_kern_mount exist in kernel])
865         AC_MSG_RESULT([yes])
866 ],[
867         AC_MSG_RESULT([no])
868 ])
869 ])
870
871
872 # LC_INVALIDATEPAGE_RETURN_INT
873 # more 2.6 api changes.  return type for the invalidatepage
874 # address_space_operation is 'void' in new kernels but 'int' in old
875 #
876 AC_DEFUN([LC_INVALIDATEPAGE_RETURN_INT],
877 [AC_MSG_CHECKING([invalidatepage has return int])
878 LB_LINUX_TRY_COMPILE([
879         #include <linux/buffer_head.h>
880 ],[
881         int rc = block_invalidatepage(NULL, 0);
882 ],[
883         AC_MSG_RESULT(yes)
884         AC_DEFINE(HAVE_INVALIDATEPAGE_RETURN_INT, 1,
885                 [Define if return type of invalidatepage should be int])
886 ],[
887         AC_MSG_RESULT(NO)
888 ])
889 ])
890
891 # LC_UMOUNTBEGIN_HAS_VFSMOUNT
892 # more 2.6 API changes. 2.6.18 umount_begin has different parameters
893 AC_DEFUN([LC_UMOUNTBEGIN_HAS_VFSMOUNT],
894 [AC_MSG_CHECKING([if umount_begin needs vfsmount parameter instead of super_block])
895 tmp_flags="$EXTRA_KCFLAGS"
896 EXTRA_KCFLAGS="-Werror"
897 LB_LINUX_TRY_COMPILE([
898         #include <linux/fs.h>
899
900         struct vfsmount;
901         static void cfg_umount_begin (struct vfsmount *v, int flags)
902         {
903                 ;
904         }
905
906         static struct super_operations cfg_super_operations = {
907                 .umount_begin   = cfg_umount_begin,
908         };
909 ],[
910         cfg_super_operations.umount_begin(NULL,0);
911 ],[
912         AC_MSG_RESULT(yes)
913         AC_DEFINE(HAVE_UMOUNTBEGIN_VFSMOUNT, 1,
914                 [Define umount_begin need second argument])
915 ],[
916         AC_MSG_RESULT(NO)
917 ])
918 EXTRA_KCFLAGS="$tmp_flags"
919 ])
920
921 # 2.6.19 API changes
922 # inode don't have i_blksize field
923 AC_DEFUN([LC_INODE_BLKSIZE],
924 [AC_MSG_CHECKING([inode has i_blksize field])
925 LB_LINUX_TRY_COMPILE([
926 #include <linux/fs.h>
927 ],[
928         struct inode i;
929         i.i_blksize = 0; 
930 ],[
931         AC_MSG_RESULT(yes)
932         AC_DEFINE(HAVE_INODE_BLKSIZE, 1,
933                 [struct inode has i_blksize field])
934 ],[
935         AC_MSG_RESULT(NO)
936 ])
937 ])
938
939 # LC_VFS_READDIR_U64_INO
940 # 2.6.19 use u64 for inode number instead of inode_t
941 AC_DEFUN([LC_VFS_READDIR_U64_INO],
942 [AC_MSG_CHECKING([check vfs_readdir need 64bit inode number])
943 tmp_flags="$EXTRA_KCFLAGS"
944 EXTRA_KCFLAGS="-Werror"
945 LB_LINUX_TRY_COMPILE([
946 #include <linux/fs.h>
947         int fillonedir(void * __buf, const char * name, int namlen, loff_t offset,
948                       u64 ino, unsigned int d_type)
949         {
950                 return 0;
951         }
952 ],[
953         filldir_t filter;
954
955         filter = fillonedir;
956         return 1;
957 ],[
958         AC_MSG_RESULT(yes)
959         AC_DEFINE(HAVE_VFS_READDIR_U64_INO, 1,
960                 [if vfs_readdir need 64bit inode number])
961 ],[
962         AC_MSG_RESULT(NO)
963 ])
964 EXTRA_KCFLAGS="$tmp_flags"
965 ])
966
967 # LC_GENERIC_FILE_WRITE
968 # 2.6.19 introduce do_sync_write instead of
969 # generic_file_write
970 AC_DEFUN([LC_GENERIC_FILE_WRITE],
971 [AC_MSG_CHECKING([use generic_file_write])
972 LB_LINUX_TRY_COMPILE([
973         #include <linux/fs.h>
974 ],[
975         int result = generic_file_read(NULL, NULL, 0, 0);
976 ],[
977         AC_MSG_RESULT(yes)
978         AC_DEFINE(HAVE_GENERIC_FILE_WRITE, 1,
979                 [use generic_file_write])
980 ],[
981         AC_MSG_RESULT(NO)
982 ])
983 ])
984
985 # LC_GENERIC_FILE_READ
986 # 2.6.19 need to use do_sync_read instead of
987 # generic_file_read
988 AC_DEFUN([LC_GENERIC_FILE_READ],
989 [AC_MSG_CHECKING([use generic_file_read])
990 LB_LINUX_TRY_COMPILE([
991         #include <linux/fs.h>
992 ],[
993         int result = generic_file_read(NULL, NULL, 0, 0);
994 ],[
995         AC_MSG_RESULT(yes)
996         AC_DEFINE(HAVE_GENERIC_FILE_READ, 1,
997                 [use generic_file_read])
998 ],[
999         AC_MSG_RESULT(NO)
1000 ])
1001 ])
1002
1003 # LC_NR_PAGECACHE
1004 # 2.6.18 don't export nr_pagecahe
1005 AC_DEFUN([LC_NR_PAGECACHE],
1006 [AC_MSG_CHECKING([kernel export nr_pagecache])
1007 LB_LINUX_TRY_COMPILE([
1008         #include <linux/pagemap.h>
1009 ],[
1010         return atomic_read(&nr_pagecache);
1011 ],[
1012         AC_MSG_RESULT(yes)
1013         AC_DEFINE(HAVE_NR_PAGECACHE, 1,
1014                 [is kernel export nr_pagecache])
1015 ],[
1016         AC_MSG_RESULT(NO)
1017 ])
1018 ])
1019
1020 # LC_CANCEL_DIRTY_PAGE
1021 # 2.6.20 introduse cancel_dirty_page instead of 
1022 # clear_page_dirty.
1023 AC_DEFUN([LC_CANCEL_DIRTY_PAGE],
1024 [AC_MSG_CHECKING([kernel has cancel_dirty_page])
1025 LB_LINUX_TRY_COMPILE([
1026         #include <linux/page-flags.h>
1027 ],[
1028         cancel_dirty_page(NULL, 0);
1029 ],[
1030         AC_MSG_RESULT(yes)
1031         AC_DEFINE(HAVE_CANCEL_DIRTY_PAGE, 1,
1032                   [kernel has cancel_dirty_page instead of clear_page_dirty])
1033 ],[
1034         AC_MSG_RESULT(NO)
1035 ])
1036 ])
1037
1038 #
1039 # LC_PAGE_CONSTANT
1040 #
1041 # In order to support raid5 zerocopy patch, we have to patch the kernel to make
1042 # it support constant page, which means the page won't be modified during the
1043 # IO.
1044 #
1045 AC_DEFUN([LC_PAGE_CONSTANT],
1046 [AC_MSG_CHECKING([if kernel have PageConstant defined])
1047 LB_LINUX_TRY_COMPILE([
1048         #include <linux/page-flags.h>
1049 ],[
1050         #ifndef PG_constant
1051         #error "Have no raid5 zcopy patch"
1052         #endif
1053 ],[
1054         AC_MSG_RESULT(yes)
1055         AC_DEFINE(HAVE_PAGE_CONSTANT, 1, [kernel have PageConstant supported])
1056 ],[
1057         AC_MSG_RESULT(no);
1058 ])
1059 ])
1060
1061 # RHEL5 in FS-cache patch rename PG_checked flag
1062 # into PG_fs_misc
1063 AC_DEFUN([LC_PG_FS_MISC],
1064 [AC_MSG_CHECKING([kernel has PG_fs_misc])
1065 LB_LINUX_TRY_COMPILE([
1066         #include <linux/page-flags.h>
1067 ],[
1068         #ifndef PG_fs_misc
1069         #error PG_fs_misc not defined in kernel
1070         #endif
1071 ],[
1072         AC_MSG_RESULT(yes)
1073         AC_DEFINE(HAVE_PG_FS_MISC, 1,
1074                   [is kernel have PG_fs_misc])
1075 ],[
1076         AC_MSG_RESULT(NO)
1077 ])
1078 ])
1079
1080 AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE],
1081 [LB_CHECK_SYMBOL_EXPORT([truncate_complete_page],
1082 [mm/truncate.c],[
1083 AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
1084             [kernel export truncate_complete_page])
1085 ],[
1086 ])
1087 ])
1088
1089 AC_DEFUN([LC_EXPORT_D_REHASH_COND],
1090 [LB_CHECK_SYMBOL_EXPORT([d_rehash_cond],
1091 [fs/dcache.c],[
1092 AC_DEFINE(HAVE_D_REHASH_COND, 1,
1093             [d_rehash_cond is exported by the kernel])
1094 ],[
1095 ])
1096 ])
1097
1098 AC_DEFUN([LC_EXPORT___D_REHASH],
1099 [LB_CHECK_SYMBOL_EXPORT([__d_rehash],
1100 [fs/dcache.c],[
1101 AC_DEFINE(HAVE___D_REHASH, 1,
1102             [__d_rehash is exported by the kernel])
1103 ],[
1104 ])
1105 ])
1106
1107 AC_DEFUN([LC_EXPORT_D_MOVE_LOCKED],
1108 [LB_CHECK_SYMBOL_EXPORT([d_move_locked],
1109 [fs/dcache.c],[
1110 AC_DEFINE(HAVE_D_MOVE_LOCKED, 1,
1111             [d_move_locked is exported by the kernel])
1112 ],[
1113 ])
1114 ])
1115
1116 AC_DEFUN([LC_EXPORT___D_MOVE],
1117 [LB_CHECK_SYMBOL_EXPORT([__d_move],
1118 [fs/dcache.c],[
1119 AC_DEFINE(HAVE___D_MOVE, 1,
1120             [__d_move is exported by the kernel])
1121 ],[
1122 ])
1123 ])
1124
1125 # The actual symbol exported varies among architectures, so we need
1126 # to check many symbols (but only in the current architecture.)  No
1127 # matter what symbol is exported, the kernel #defines node_to_cpumask
1128 # to the appropriate function and that's what we use.
1129 AC_DEFUN([LC_EXPORT_NODE_TO_CPUMASK],
1130          [LB_LINUX_ARCH
1131           LB_CHECK_SYMBOL_EXPORT([node_to_cpumask],
1132                                  [arch/$LINUX_ARCH/mm/numa.c],
1133                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
1134                                             [node_to_cpumask is exported by
1135                                              the kernel])]) # x86_64
1136           LB_CHECK_SYMBOL_EXPORT([node_to_cpu_mask],
1137                                  [arch/$LINUX_ARCH/kernel/smpboot.c],
1138                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
1139                                             [node_to_cpumask is exported by
1140                                              the kernel])]) # ia64
1141           LB_CHECK_SYMBOL_EXPORT([node_2_cpu_mask],
1142                                  [arch/$LINUX_ARCH/kernel/smpboot.c],
1143                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
1144                                             [node_to_cpumask is exported by
1145                                              the kernel])]) # i386
1146           ])
1147
1148 #
1149 # LC_VFS_INTENT_PATCHES
1150 #
1151 # check if the kernel has the VFS intent patches
1152 AC_DEFUN([LC_VFS_INTENT_PATCHES],
1153 [AC_MSG_CHECKING([if the kernel has the VFS intent patches])
1154 LB_LINUX_TRY_COMPILE([
1155         #include <linux/fs.h>
1156         #include <linux/namei.h>
1157 ],[
1158         struct nameidata nd;
1159         struct lookup_intent *it;
1160
1161         it = &nd.intent;
1162         intent_init(it, IT_OPEN);
1163         it->d.lustre.it_disposition = 0;
1164         it->d.lustre.it_data = NULL;
1165 ],[
1166         AC_MSG_RESULT([yes])
1167         AC_DEFINE(HAVE_VFS_INTENT_PATCHES, 1, [VFS intent patches are applied])
1168 ],[
1169         AC_MSG_RESULT([no])
1170 ])
1171 ])
1172
1173 # 2.6.22 lost second parameter for invalidate_bdev
1174 AC_DEFUN([LC_INVALIDATE_BDEV_2ARG],
1175 [AC_MSG_CHECKING([if invalidate_bdev has second argument])
1176 LB_LINUX_TRY_COMPILE([
1177         #include <linux/buffer_head.h>
1178 ],[
1179         invalidate_bdev(NULL,0);
1180 ],[
1181         AC_MSG_RESULT([yes])
1182         AC_DEFINE(HAVE_INVALIDATE_BDEV_2ARG, 1,
1183                 [invalidate_bdev has second argument])
1184 ],[
1185         AC_MSG_RESULT([no])
1186 ])
1187 ])
1188
1189 # 2.6.23 have return type 'void' for unregister_blkdev
1190 AC_DEFUN([LC_UNREGISTER_BLKDEV_RETURN_INT],
1191 [AC_MSG_CHECKING([if unregister_blkdev return int])
1192 LB_LINUX_TRY_COMPILE([
1193         #include <linux/fs.h>
1194 ],[
1195         int i = unregister_blkdev(0,NULL);
1196 ],[
1197         AC_MSG_RESULT([yes])
1198         AC_DEFINE(HAVE_UNREGISTER_BLKDEV_RETURN_INT, 1, 
1199                 [unregister_blkdev return int])
1200 ],[
1201         AC_MSG_RESULT([no])
1202 ])
1203 ])
1204
1205 # 2.6.23 change .sendfile to .splice_read
1206 AC_DEFUN([LC_KERNEL_SPLICE_READ],
1207 [AC_MSG_CHECKING([if kernel has .splice_read])
1208 LB_LINUX_TRY_COMPILE([
1209         #include <linux/fs.h>
1210 ],[
1211         struct file_operations file;
1212
1213         file.splice_read = NULL;
1214 ], [
1215         AC_MSG_RESULT([yes])
1216         AC_DEFINE(HAVE_KERNEL_SPLICE_READ, 1,
1217                 [kernel has .slice_read])
1218 ],[
1219         AC_MSG_RESULT([no])
1220 ])
1221 ])
1222
1223 # 2.6.23 extract nfs export related data into exportfs.h
1224 AC_DEFUN([LC_HAVE_EXPORTFS_H],
1225 [
1226 tmpfl="$CFLAGS"
1227 CFLAGS="$CFLAGS -I$LINUX_OBJ/include"
1228 AC_CHECK_HEADERS([linux/exportfs.h])
1229 CFLAGS="$tmpfl"
1230 ])
1231
1232 #
1233 # LC_PROG_LINUX
1234 #
1235 # Lustre linux kernel checks
1236 #
1237 AC_DEFUN([LC_PROG_LINUX],
1238          [LC_LUSTRE_VERSION_H
1239           if test x$enable_server = xyes ; then
1240               LC_CONFIG_BACKINGFS
1241           fi
1242           LC_CONFIG_PINGER
1243           LC_CONFIG_CHECKSUM
1244           LC_CONFIG_LIBLUSTRE_RECOVERY
1245           LC_CONFIG_QUOTA
1246           LC_CONFIG_HEALTH_CHECK_WRITE
1247           LC_CONFIG_LRU_RESIZE
1248
1249           LC_TASK_PPTR
1250           # RHEL4 patches
1251           LC_EXPORT_TRUNCATE_COMPLETE
1252           LC_EXPORT_D_REHASH_COND
1253           LC_EXPORT___D_REHASH
1254           LC_EXPORT_D_MOVE_LOCKED
1255           LC_EXPORT___D_MOVE
1256           LC_EXPORT_NODE_TO_CPUMASK
1257
1258           LC_STRUCT_KIOBUF
1259           LC_FUNC_COND_RESCHED
1260           LC_FUNC_ZAP_PAGE_RANGE
1261           LC_FUNC_PDE
1262           LC_FUNC_DIRECT_IO
1263           LC_HEADER_MM_INLINE
1264           LC_STRUCT_INODE
1265           LC_FUNC_REGISTER_CACHE
1266           LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
1267           LC_FUNC_DEV_SET_RDONLY
1268           LC_FUNC_FILEMAP_FDATAWRITE
1269           LC_STRUCT_STATFS
1270           LC_FUNC_PAGE_MAPPED
1271           LC_STRUCT_FILE_OPS_UNLOCKED_IOCTL
1272           LC_FILEMAP_POPULATE
1273           LC_D_ADD_UNIQUE
1274           LC_BIT_SPINLOCK_H
1275           LC_XATTR_ACL
1276           LC_STRUCT_INTENT_FILE
1277           LC_POSIX_ACL_XATTR_H
1278           LC_EXPORT___IGET
1279           LC_FUNC_SET_FS_PWD
1280           LC_FUNC_MS_FLOCK_LOCK
1281           LC_FUNC_HAVE_CAN_SLEEP_ARG
1282           LC_FUNC_F_OP_FLOCK
1283           LC_QUOTA_READ
1284           LC_COOKIE_FOLLOW_LINK
1285           LC_FUNC_RCU
1286
1287           # does the kernel have VFS intent patches?
1288           LC_VFS_INTENT_PATCHES
1289
1290           # 2.6.15
1291           LC_INODE_I_MUTEX
1292
1293           # SLES 10 (at least)
1294           LC_SYMVERFILE
1295
1296           # 2.6.17
1297           LC_DQUOTOFF_MUTEX
1298
1299           # 2.6.18
1300           LC_NR_PAGECACHE
1301           LC_STATFS_DENTRY_PARAM
1302           LC_VFS_KERN_MOUNT
1303           LC_INVALIDATEPAGE_RETURN_INT
1304           LC_UMOUNTBEGIN_HAS_VFSMOUNT
1305
1306           #2.6.18 + RHEL5 (fc6)
1307           LC_PG_FS_MISC
1308
1309           # 2.6.19
1310           LC_INODE_BLKSIZE
1311           LC_VFS_READDIR_U64_INO
1312           LC_GENERIC_FILE_READ
1313           LC_GENERIC_FILE_WRITE
1314
1315           # 2.6.20
1316           LC_CANCEL_DIRTY_PAGE
1317
1318           # raid5-zerocopy patch
1319           LC_PAGE_CONSTANT
1320           
1321           # 2.6.22
1322           LC_INVALIDATE_BDEV_2ARG
1323           # 2.6.23
1324           LC_UNREGISTER_BLKDEV_RETURN_INT
1325           LC_KERNEL_SPLICE_READ
1326           LC_HAVE_EXPORTFS_H
1327 ])
1328
1329 #
1330 # LC_CONFIG_CLIENT_SERVER
1331 #
1332 # Build client/server sides of Lustre
1333 #
1334 AC_DEFUN([LC_CONFIG_CLIENT_SERVER],
1335 [AC_MSG_CHECKING([whether to build Lustre server support])
1336 AC_ARG_ENABLE([server],
1337         AC_HELP_STRING([--disable-server],
1338                         [disable Lustre server support]),
1339         [],[enable_server='yes'])
1340 AC_MSG_RESULT([$enable_server])
1341
1342 AC_MSG_CHECKING([whether to build Lustre client support])
1343 AC_ARG_ENABLE([client],
1344         AC_HELP_STRING([--disable-client],
1345                         [disable Lustre client support]),
1346         [],[enable_client='yes'])
1347 AC_MSG_RESULT([$enable_client])])
1348
1349 #
1350 # LC_CONFIG_LIBLUSTRE
1351 #
1352 # whether to build liblustre
1353 #
1354 AC_DEFUN([LC_CONFIG_LIBLUSTRE],
1355 [AC_MSG_CHECKING([whether to build Lustre library])
1356 AC_ARG_ENABLE([liblustre],
1357         AC_HELP_STRING([--disable-liblustre],
1358                         [disable building of Lustre library]),
1359         [],[enable_liblustre=$with_sysio])
1360 AC_MSG_RESULT([$enable_liblustre])
1361 # only build sysio if liblustre is built
1362 with_sysio="$enable_liblustre"
1363
1364 AC_MSG_CHECKING([whether to build liblustre tests])
1365 AC_ARG_ENABLE([liblustre-tests],
1366         AC_HELP_STRING([--enable-liblustre-tests],
1367                         [enable liblustre tests, if --disable-tests is used]),
1368         [],[enable_liblustre_tests=$enable_tests])
1369 if test x$enable_liblustre != xyes ; then
1370    enable_liblustre_tests='no'
1371 fi
1372 AC_MSG_RESULT([$enable_liblustre_tests])
1373
1374 AC_MSG_CHECKING([whether to enable liblustre acl])
1375 AC_ARG_ENABLE([liblustre-acl],
1376         AC_HELP_STRING([--disable-liblustre-acl],
1377                         [disable ACL support for liblustre]),
1378         [],[enable_liblustre_acl=yes])
1379 if test x$enable_liblustre != xyes ; then
1380    enable_liblustre_acl='no'
1381 fi
1382 AC_MSG_RESULT([$enable_liblustre_acl])
1383 if test x$enable_liblustre_acl != xno ; then
1384   AC_DEFINE(LIBLUSTRE_POSIX_ACL, 1, Liblustre Support ACL-enabled MDS)
1385 fi
1386
1387 AC_MSG_CHECKING([whether to build mpitests])
1388 AC_ARG_ENABLE([mpitests],
1389         AC_HELP_STRING([--enable-mpitests],
1390                         [build liblustre mpi tests]),
1391         [],[enable_mpitests=no])
1392 AC_MSG_RESULT([$enable_mpitests])
1393
1394 AC_MSG_NOTICE([Enabling Lustre configure options for libsysio])
1395 ac_configure_args="$ac_configure_args --with-lustre-hack --with-sockets"
1396
1397 LC_CONFIG_PINGER
1398 LC_CONFIG_LIBLUSTRE_RECOVERY
1399 ])
1400
1401 AC_DEFUN([LC_CONFIG_LRU_RESIZE],
1402 [AC_MSG_CHECKING([whether to enable lru self-adjusting])
1403 AC_ARG_ENABLE([lru_resize], 
1404         AC_HELP_STRING([--enable-lru-resize],
1405                         [enable lru resize support]),
1406         [],[enable_lru_resize='yes'])
1407 AC_MSG_RESULT([$enable_lru_resize])
1408 if test x$enable_lru_resize != xno; then
1409    AC_DEFINE(HAVE_LRU_RESIZE_SUPPORT, 1, [Enable lru resize support])
1410 fi
1411 ])
1412
1413 #
1414 # LC_CONFIG_QUOTA
1415 #
1416 # whether to enable quota support
1417 #
1418 AC_DEFUN([LC_CONFIG_QUOTA],
1419 [AC_MSG_CHECKING([whether to enable quota support])
1420 AC_ARG_ENABLE([quota], 
1421         AC_HELP_STRING([--enable-quota],
1422                         [enable quota support]),
1423         [],[enable_quota='yes'])
1424 AC_MSG_RESULT([$enable_quota])
1425 if test x$linux25 != xyes; then
1426    enable_quota='no'
1427 fi
1428 if test x$enable_quota != xno; then
1429    AC_DEFINE(HAVE_QUOTA_SUPPORT, 1, [Enable quota support])
1430 fi
1431 ])
1432   
1433 AC_DEFUN([LC_QUOTA_READ],
1434 [AC_MSG_CHECKING([if kernel supports quota_read])
1435 LB_LINUX_TRY_COMPILE([
1436         #include <linux/fs.h>
1437 ],[
1438         struct super_operations sp;
1439         void *i = (void *)sp.quota_read;
1440 ],[
1441         AC_MSG_RESULT([yes])
1442         AC_DEFINE(KERNEL_SUPPORTS_QUOTA_READ, 1, [quota_read found])
1443 ],[
1444         AC_MSG_RESULT([no])
1445 ])
1446 ])
1447
1448 #
1449 # LC_COOKIE_FOLLOW_LINK
1450 #
1451 # kernel 2.6.13+ ->follow_link returns a cookie
1452 #
1453
1454 AC_DEFUN([LC_COOKIE_FOLLOW_LINK],
1455 [AC_MSG_CHECKING([if inode_operations->follow_link returns a cookie])
1456 LB_LINUX_TRY_COMPILE([
1457         #include <linux/fs.h>
1458         #include <linux/namei.h>
1459 ],[
1460         struct dentry dentry;
1461         struct nameidata nd;
1462
1463         dentry.d_inode->i_op->put_link(&dentry, &nd, NULL);
1464 ],[
1465         AC_DEFINE(HAVE_COOKIE_FOLLOW_LINK, 1, [inode_operations->follow_link returns a cookie])
1466         AC_MSG_RESULT([yes])
1467 ],[
1468         AC_MSG_RESULT([no])
1469 ])
1470 ])
1471
1472 #
1473 # LC_FUNC_RCU
1474 #
1475 # kernels prior than 2.6.0(?) have no RCU supported; in kernel 2.6.5(SUSE), 
1476 # call_rcu takes three parameters.
1477 #
1478 AC_DEFUN([LC_FUNC_RCU],
1479 [AC_MSG_CHECKING([if kernel have RCU supported])
1480 LB_LINUX_TRY_COMPILE([
1481         #include <linux/rcupdate.h>
1482 ],[],[
1483         AC_DEFINE(HAVE_RCU, 1, [have RCU defined])
1484         AC_MSG_RESULT([yes])
1485
1486         AC_MSG_CHECKING([if call_rcu takes three parameters])
1487         LB_LINUX_TRY_COMPILE([
1488                 #include <linux/rcupdate.h>
1489         ],[
1490                 struct rcu_head rh;
1491                 call_rcu(&rh, (void (*)(struct rcu_head *))1, NULL);
1492         ],[
1493                 AC_DEFINE(HAVE_CALL_RCU_PARAM, 1, [call_rcu takes three parameters])
1494                 AC_MSG_RESULT([yes])
1495         ],[
1496                 AC_MSG_RESULT([no]) 
1497         ])
1498 ],[
1499         AC_MSG_RESULT([no])
1500 ])
1501 ])
1502
1503 #
1504 # LC_CONFIGURE
1505 #
1506 # other configure checks
1507 #
1508 AC_DEFUN([LC_CONFIGURE],
1509 [LC_CONFIG_OBD_BUFFER_SIZE
1510
1511 # include/liblustre.h
1512 AC_CHECK_HEADERS([asm/page.h sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
1513
1514 # include/lustre/lustre_user.h
1515 # See note there re: __ASM_X86_64_PROCESSOR_H
1516 AC_CHECK_HEADERS([linux/fs.h linux/quota.h])
1517
1518 # liblustre/llite_lib.h
1519 AC_CHECK_HEADERS([xtio.h file.h])
1520
1521 # liblustre/dir.c
1522 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
1523
1524 # liblustre/lutil.c
1525 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h catamount/data.h])
1526 AC_CHECK_FUNCS([inet_ntoa])
1527
1528 # libsysio/src/readlink.c
1529 LC_READLINK_SSIZE_T
1530
1531 # utils/llverfs.c
1532 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
1533
1534 # include/linux/obd_support.h
1535 AC_CHECK_HEADERS([zlib.h])
1536
1537 # check for -lz support
1538 AC_CHECK_LIB(z, [adler32],
1539         [
1540                 ZLIB="-lz"
1541                 AC_DEFINE([HAVE_ADLER], 1, [support alder32 checksum type])
1542         ],
1543         [
1544                 ZLIB=""
1545                 AC_MSG_WARN([No zlib-devel package found, unable to use adler32 checksum])
1546         ])
1547 AC_SUBST(ZLIB)
1548
1549 # Super safe df
1550 AC_ARG_ENABLE([mindf],
1551       AC_HELP_STRING([--enable-mindf],
1552                       [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
1553       [],[])
1554 if test "$enable_mindf" = "yes" ;  then
1555       AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])
1556 fi
1557
1558 AC_ARG_ENABLE([fail_alloc],
1559         AC_HELP_STRING([--disable-fail-alloc],
1560                 [disable randomly alloc failure]),
1561         [],[enable_fail_alloc=yes])
1562 AC_MSG_CHECKING([whether to randomly failing memory alloc])
1563 AC_MSG_RESULT([$enable_fail_alloc])
1564 if test x$enable_fail_alloc != xno ; then
1565         AC_DEFINE([RANDOM_FAIL_ALLOC], 1, [enable randomly alloc failure])
1566 fi
1567
1568 ])
1569
1570 #
1571 # LC_CONDITIONALS
1572 #
1573 # AM_CONDITIONALS for lustre
1574 #
1575 AC_DEFUN([LC_CONDITIONALS],
1576 [AM_CONDITIONAL(LIBLUSTRE, test x$enable_liblustre = xyes)
1577 AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
1578 AM_CONDITIONAL(LIBLUSTRE_TESTS, test x$enable_liblustre_tests = xyes)
1579 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
1580 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
1581 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
1582 AM_CONDITIONAL(QUOTA, test x$enable_quota = xyes)
1583 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
1584 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
1585 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
1586 ])
1587
1588 #
1589 # LC_CONFIG_FILES
1590 #
1591 # files that should be generated with AC_OUTPUT
1592 #
1593 AC_DEFUN([LC_CONFIG_FILES],
1594 [AC_CONFIG_FILES([
1595 lustre/Makefile
1596 lustre/autoMakefile
1597 lustre/autoconf/Makefile
1598 lustre/contrib/Makefile
1599 lustre/doc/Makefile
1600 lustre/include/Makefile
1601 lustre/include/lustre_ver.h
1602 lustre/include/linux/Makefile
1603 lustre/include/lustre/Makefile
1604 lustre/kernel_patches/targets/2.6-suse.target
1605 lustre/kernel_patches/targets/2.6-vanilla.target
1606 lustre/kernel_patches/targets/2.6-rhel4.target
1607 lustre/kernel_patches/targets/2.6-rhel5.target
1608 lustre/kernel_patches/targets/2.6-fc5.target
1609 lustre/kernel_patches/targets/2.6-patchless.target
1610 lustre/kernel_patches/targets/2.6-sles10.target
1611 lustre/kernel_patches/targets/hp_pnnl-2.4.target
1612 lustre/kernel_patches/targets/rh-2.4.target
1613 lustre/kernel_patches/targets/rhel-2.4.target
1614 lustre/kernel_patches/targets/suse-2.4.21-2.target
1615 lustre/kernel_patches/targets/sles-2.4.target
1616 lustre/ldlm/Makefile
1617 lustre/liblustre/Makefile
1618 lustre/liblustre/tests/Makefile
1619 lustre/llite/Makefile
1620 lustre/llite/autoMakefile
1621 lustre/lov/Makefile
1622 lustre/lov/autoMakefile
1623 lustre/lvfs/Makefile
1624 lustre/lvfs/autoMakefile
1625 lustre/mdc/Makefile
1626 lustre/mdc/autoMakefile
1627 lustre/mds/Makefile
1628 lustre/mds/autoMakefile
1629 lustre/obdclass/Makefile
1630 lustre/obdclass/autoMakefile
1631 lustre/obdclass/linux/Makefile
1632 lustre/obdecho/Makefile
1633 lustre/obdecho/autoMakefile
1634 lustre/obdfilter/Makefile
1635 lustre/obdfilter/autoMakefile
1636 lustre/osc/Makefile
1637 lustre/osc/autoMakefile
1638 lustre/ost/Makefile
1639 lustre/ost/autoMakefile
1640 lustre/mgc/Makefile
1641 lustre/mgc/autoMakefile
1642 lustre/mgs/Makefile
1643 lustre/mgs/autoMakefile
1644 lustre/ptlrpc/Makefile
1645 lustre/ptlrpc/autoMakefile
1646 lustre/quota/Makefile
1647 lustre/quota/autoMakefile
1648 lustre/scripts/Makefile
1649 lustre/scripts/version_tag.pl
1650 lustre/tests/Makefile
1651 lustre/utils/Makefile
1652 ])
1653 case $lb_target_os in
1654         darwin)
1655                 AC_CONFIG_FILES([ lustre/obdclass/darwin/Makefile ])
1656                 ;;
1657 esac
1658
1659 ])