Whamcloud - gitweb
branch: HEAD
[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 libcfs_is_module=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 # LC_CONFIG_EXT3
52 #
53 # that ext3 is enabled in the kernel
54 #
55 AC_DEFUN([LC_CONFIG_EXT3],
56 [LB_LINUX_CONFIG([EXT3_FS],[],[
57         LB_LINUX_CONFIG([EXT3_FS_MODULE],[],[$2])
58 ])
59 LB_LINUX_CONFIG([EXT3_FS_XATTR],[$1],[$3])
60 ])
61
62 #
63 # LC_FSHOOKS
64 #
65 # If we have (and can build) fshooks.h
66 #
67 AC_DEFUN([LC_FSHOOKS],
68 [LB_CHECK_FILE([$LINUX/include/linux/fshooks.h],[
69         AC_MSG_CHECKING([if fshooks.h can be compiled])
70         LB_LINUX_TRY_COMPILE([
71                 #include <linux/fshooks.h>
72         ],[],[
73                 AC_MSG_RESULT([yes])
74         ],[
75                 AC_MSG_RESULT([no])
76                 AC_MSG_WARN([You might have better luck with gcc 3.3.x.])
77                 AC_MSG_WARN([You can set CC=gcc33 before running configure.])
78                 AC_MSG_ERROR([Your compiler cannot build fshooks.h.])
79         ])
80 $1
81 ],[
82 $2
83 ])
84 ])
85
86 #
87 # LC_FUNC_RELEASEPAGE_WITH_INT
88 #
89 # if ->releasepage() takes an int arg in 2.6.9
90 # This kernel defines gfp_t (HAS_GFP_T) but doesn't use it for this function,
91 # while others either don't have gfp_t or pass gfp_t as the parameter.
92 #
93 AC_DEFUN([LC_FUNC_RELEASEPAGE_WITH_INT],
94 [AC_MSG_CHECKING([if releasepage has a int parameter])
95 RELEASEPAGE_WITH_INT="`grep -c 'releasepage.*int' $LINUX/include/linux/fs.h`"
96 if test "$RELEASEPAGE_WITH_INT" != 0 ; then
97         AC_DEFINE(HAVE_RELEASEPAGE_WITH_INT, 1,
98                   [releasepage with int parameter])
99         AC_MSG_RESULT([yes])
100 else
101         AC_MSG_RESULT([no])
102 fi
103 ])
104
105 #
106 # LC_FUNC_FILEMAP_FDATASYNC
107 #
108 # if filemap_fdatasync() exists
109 #
110 AC_DEFUN([LC_FUNC_FILEMAP_FDATAWRITE],
111 [AC_MSG_CHECKING([whether filemap_fdatawrite() is defined])
112 LB_LINUX_TRY_COMPILE([
113         #include <linux/fs.h>
114 ],[
115         int (*foo)(struct address_space *)= filemap_fdatawrite;
116 ],[
117         AC_MSG_RESULT([yes])
118         AC_DEFINE(HAVE_FILEMAP_FDATAWRITE, 1, [filemap_fdatawrite() found])
119 ],[
120         AC_MSG_RESULT([no])
121 ])
122 ])
123
124 #
125 # LC_HEADER_MM_INLINE
126 #
127 # RHEL kernels define page_count in mm_inline.h
128 #
129 AC_DEFUN([LC_HEADER_MM_INLINE],
130 [AC_MSG_CHECKING([if kernel has mm_inline.h header])
131 LB_LINUX_TRY_COMPILE([
132         #include <linux/mm_inline.h>
133 ],[
134         #ifndef page_count
135         #error mm_inline.h does not define page_count
136         #endif
137 ],[
138         AC_MSG_RESULT([yes])
139         AC_DEFINE(HAVE_MM_INLINE, 1, [mm_inline found])
140 ],[
141         AC_MSG_RESULT([no])
142 ])
143 ])
144
145 #
146 # LC_STRUCT_INODE
147 #
148 # if inode->i_alloc_sem exists
149 #
150 AC_DEFUN([LC_STRUCT_INODE],
151 [AC_MSG_CHECKING([if struct inode has i_alloc_sem])
152 LB_LINUX_TRY_COMPILE([
153         #include <linux/fs.h>
154         #include <linux/version.h>
155 ],[
156         #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24))
157         #error "down_read_trylock broken before 2.4.24"
158         #endif
159         struct inode i;
160         return (char *)&i.i_alloc_sem - (char *)&i;
161 ],[
162         AC_MSG_RESULT([yes])
163         AC_DEFINE(HAVE_I_ALLOC_SEM, 1, [struct inode has i_alloc_sem])
164 ],[
165         AC_MSG_RESULT([no])
166 ])
167 ])
168
169 #
170 # LC_FUNC_REGISTER_CACHE
171 #
172 # if register_cache() is defined by kernel
173 #
174 # There are two ways to shrink one customized cache in linux kernels. For the
175 # kernels are prior than 2.6.5(?), register_cache() is used, and for latest
176 # kernels, set_shrinker() is used instead.
177 #
178 AC_DEFUN([LC_FUNC_REGISTER_CACHE],
179 [AC_MSG_CHECKING([if kernel defines cache pressure hook])
180 LB_LINUX_TRY_COMPILE([
181         #include <linux/mm.h>
182 ],[
183         shrinker_t shrinker;
184
185         set_shrinker(1, shrinker);
186 ],[
187         AC_MSG_RESULT([set_shrinker])
188         AC_DEFINE(HAVE_SHRINKER_CACHE, 1, [shrinker_cache found])
189         AC_DEFINE(HAVE_CACHE_RETURN_INT, 1, [shrinkers should return int])
190 ],[
191         LB_LINUX_TRY_COMPILE([
192                 #include <linux/list.h>
193                 #include <linux/cache_def.h>
194         ],[
195                 struct cache_definition cache;
196         ],[
197                 AC_MSG_RESULT([register_cache])
198                 AC_DEFINE(HAVE_REGISTER_CACHE, 1, [register_cache found])
199                 AC_MSG_CHECKING([if kernel expects return from cache shrink ])
200                 tmp_flags="$EXTRA_KCFLAGS"
201                 EXTRA_KCFLAGS="-Werror"
202                 LB_LINUX_TRY_COMPILE([
203                         #include <linux/list.h>
204                         #include <linux/cache_def.h>
205                 ],[
206                         struct cache_definition c;
207                         c.shrinker = (int (*)(int, unsigned int))1;
208                 ],[
209                         AC_DEFINE(HAVE_CACHE_RETURN_INT, 1,
210                                   [kernel expects return from shrink_cache])
211                         AC_MSG_RESULT(yes)
212                 ],[
213                         AC_MSG_RESULT(no)
214                 ])
215                 EXTRA_KCFLAGS="$tmp_flags"
216         ],[
217                 AC_MSG_RESULT([no])
218         ])
219 ])
220 ])
221
222 #
223 # LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
224 #
225 # check for our patched grab_cache_page_nowait_gfp() function
226 #
227 AC_DEFUN([LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP],
228 [AC_MSG_CHECKING([if kernel defines grab_cache_page_nowait_gfp()])
229 HAVE_GCPN_GFP="`grep -c 'grab_cache_page_nowait_gfp' $LINUX/include/linux/pagemap.h`"
230 if test "$HAVE_GCPN_GFP" != 0 ; then
231         AC_DEFINE(HAVE_GRAB_CACHE_PAGE_NOWAIT_GFP, 1,
232                 [kernel has grab_cache_page_nowait_gfp()])
233         AC_MSG_RESULT(yes)
234 else
235         AC_MSG_RESULT(no)
236 fi
237 ])
238
239 #
240 # LC_FUNC_DEV_SET_RDONLY
241 #
242 # check for the old-style dev_set_rdonly which took an extra "devno" param
243 # and can only set a single device to discard writes at one time
244 #
245 AC_DEFUN([LC_FUNC_DEV_SET_RDONLY],
246 [AC_MSG_CHECKING([if kernel has new dev_set_rdonly])
247 LB_LINUX_TRY_COMPILE([
248         #include <linux/fs.h>
249 ],[
250         #ifndef HAVE_CLEAR_RDONLY_ON_PUT
251         #error needs to be patched by lustre kernel patches from Lustre version 1.4.3 or above.
252         #endif
253 ],[
254         AC_MSG_RESULT([yes])
255         AC_DEFINE(HAVE_DEV_SET_RDONLY, 1, [kernel has new dev_set_rdonly])
256 ],[
257         AC_MSG_RESULT([no, Linux kernel source needs to be patches by lustre
258 kernel patches from Lustre version 1.4.3 or above.])
259 ])
260 ])
261
262 #
263 # LC_CONFIG_BACKINGFS
264 #
265 # setup, check the backing filesystem
266 #
267 AC_DEFUN([LC_CONFIG_BACKINGFS],
268 [
269 BACKINGFS="ldiskfs"
270
271 if test x$with_ldiskfs = xno ; then
272         BACKINGFS="ext3"
273
274         if test x$linux25$enable_server = xyesyes ; then
275                 AC_MSG_ERROR([ldiskfs is required for 2.6-based servers.])
276         fi
277
278         # --- Check that ext3 and ext3 xattr are enabled in the kernel
279         LC_CONFIG_EXT3([],[
280                 AC_MSG_ERROR([Lustre requires that ext3 is enabled in the kernel])
281         ],[
282                 AC_MSG_WARN([Lustre requires that extended attributes for ext3 are enabled in the kernel])
283                 AC_MSG_WARN([This build may fail.])
284         ])
285 else
286         # ldiskfs is enabled
287         LB_DEFINE_LDISKFS_OPTIONS
288 fi #ldiskfs
289
290 AC_MSG_CHECKING([which backing filesystem to use])
291 AC_MSG_RESULT([$BACKINGFS])
292 AC_SUBST(BACKINGFS)
293 ])
294
295 #
296 # LC_CONFIG_PINGER
297 #
298 # the pinger is temporary, until we have the recovery node in place
299 #
300 AC_DEFUN([LC_CONFIG_PINGER],
301 [AC_MSG_CHECKING([whether to enable pinger support])
302 AC_ARG_ENABLE([pinger],
303         AC_HELP_STRING([--disable-pinger],
304                         [disable recovery pinger support]),
305         [],[enable_pinger='yes'])
306 AC_MSG_RESULT([$enable_pinger])
307 if test x$enable_pinger != xno ; then
308   AC_DEFINE(ENABLE_PINGER, 1, Use the Pinger)
309 fi
310 ])
311
312 #
313 # LC_CONFIG_CHECKSUM
314 #
315 # do checksum of bulk data between client and OST
316 #
317 AC_DEFUN([LC_CONFIG_CHECKSUM],
318 [AC_MSG_CHECKING([whether to enable data checksum support])
319 AC_ARG_ENABLE([checksum],
320        AC_HELP_STRING([--disable-checksum],
321                        [disable data checksum support]),
322        [],[enable_checksum='yes'])
323 AC_MSG_RESULT([$enable_checksum])
324 if test x$enable_checksum != xno ; then
325   AC_DEFINE(ENABLE_CHECKSUM, 1, do data checksums)
326 fi
327 ])
328
329 #
330 # LC_CONFIG_HEALTH_CHECK_WRITE
331 #
332 # Turn off the actual write to the disk
333 #
334 AC_DEFUN([LC_CONFIG_HEALTH_CHECK_WRITE],
335 [AC_MSG_CHECKING([whether to enable a write with the health check])
336 AC_ARG_ENABLE([health_write],
337         AC_HELP_STRING([--enable-health_write],
338                         [enable disk writes when doing health check]),
339         [],[enable_health_write='no'])
340 AC_MSG_RESULT([$enable_health_write])
341 if test x$enable_health_write != xno ; then
342   AC_DEFINE(USE_HEALTH_CHECK_WRITE, 1, Write when Checking Health)
343 fi
344 ])
345
346 #
347 # LC_CONFIG_LIBLUSTRE_RECOVERY
348 #
349 AC_DEFUN([LC_CONFIG_LIBLUSTRE_RECOVERY],
350 [AC_MSG_CHECKING([whether to enable liblustre recovery support])
351 AC_ARG_ENABLE([liblustre-recovery],
352         AC_HELP_STRING([--disable-liblustre-recovery],
353                         [disable liblustre recovery support]),
354         [],[enable_liblustre_recovery='yes'])
355 AC_MSG_RESULT([$enable_liblustre_recovery])
356 if test x$enable_liblustre_recovery != xno ; then
357   AC_DEFINE(ENABLE_LIBLUSTRE_RECOVERY, 1, Liblustre Can Recover)
358 fi
359 ])
360
361 #
362 # LC_CONFIG_OBD_BUFFER_SIZE
363 #
364 # the maximum buffer size of lctl ioctls
365 #
366 AC_DEFUN([LC_CONFIG_OBD_BUFFER_SIZE],
367 [AC_MSG_CHECKING([maximum OBD ioctl size])
368 AC_ARG_WITH([obd-buffer-size],
369         AC_HELP_STRING([--with-obd-buffer-size=[size]],
370                         [set lctl ioctl maximum bytes (default=8192)]),
371         [
372                 OBD_BUFFER_SIZE=$with_obd_buffer_size
373         ],[
374                 OBD_BUFFER_SIZE=8192
375         ])
376 AC_MSG_RESULT([$OBD_BUFFER_SIZE bytes])
377 AC_DEFINE_UNQUOTED(OBD_MAX_IOCTL_BUFFER, $OBD_BUFFER_SIZE, [IOCTL Buffer Size])
378 ])
379
380 #
381 # LC_STRUCT_STATFS
382 #
383 # AIX does not have statfs.f_namelen
384 #
385 AC_DEFUN([LC_STRUCT_STATFS],
386 [AC_MSG_CHECKING([if struct statfs has a f_namelen field])
387 LB_LINUX_TRY_COMPILE([
388         #include <linux/vfs.h>
389 ],[
390         struct statfs sfs;
391         sfs.f_namelen = 1;
392 ],[
393         AC_MSG_RESULT([yes])
394         AC_DEFINE(HAVE_STATFS_NAMELEN, 1, [struct statfs has a namelen field])
395 ],[
396         AC_MSG_RESULT([no])
397 ])
398 ])
399
400 #
401 # LC_READLINK_SSIZE_T
402 #
403 AC_DEFUN([LC_READLINK_SSIZE_T],
404 [AC_MSG_CHECKING([if readlink returns ssize_t])
405 AC_TRY_COMPILE([
406         #include <unistd.h>
407 ],[
408         ssize_t readlink(const char *, char *, size_t);
409 ],[
410         AC_MSG_RESULT([yes])
411         AC_DEFINE(HAVE_POSIX_1003_READLINK, 1, [readlink returns ssize_t])
412 ],[
413         AC_MSG_RESULT([no])
414 ])
415 ])
416
417 AC_DEFUN([LC_FUNC_PAGE_MAPPED],
418 [AC_MSG_CHECKING([if kernel offers page_mapped])
419 LB_LINUX_TRY_COMPILE([
420         #include <linux/mm.h>
421 ],[
422         page_mapped(NULL);
423 ],[
424         AC_MSG_RESULT([yes])
425         AC_DEFINE(HAVE_PAGE_MAPPED, 1, [page_mapped found])
426 ],[
427         AC_MSG_RESULT([no])
428 ])
429 ])
430
431 AC_DEFUN([LC_STRUCT_FILE_OPS_UNLOCKED_IOCTL],
432 [AC_MSG_CHECKING([if struct file_operations has an unlocked_ioctl field])
433 LB_LINUX_TRY_COMPILE([
434         #include <linux/fs.h>
435 ],[
436         struct file_operations fops;
437         &fops.unlocked_ioctl;
438 ],[
439         AC_MSG_RESULT([yes])
440         AC_DEFINE(HAVE_UNLOCKED_IOCTL, 1, [struct file_operations has an unlock ed_ioctl field])
441 ],[
442         AC_MSG_RESULT([no])
443 ])
444 ])
445
446 AC_DEFUN([LC_FILEMAP_POPULATE],
447 [AC_MSG_CHECKING([for exported filemap_populate])
448 LB_LINUX_TRY_COMPILE([
449         #include <asm/page.h>
450         #include <linux/mm.h>
451 ],[
452        filemap_populate(NULL, 0, 0, __pgprot(0), 0, 0);
453 ],[
454         AC_MSG_RESULT([yes])
455         AC_DEFINE(HAVE_FILEMAP_POPULATE, 1, [Kernel exports filemap_populate])
456 ],[
457         AC_MSG_RESULT([no])
458 ])
459 ])
460
461 AC_DEFUN([LC_D_ADD_UNIQUE],
462 [AC_MSG_CHECKING([for d_add_unique])
463 LB_LINUX_TRY_COMPILE([
464         #include <linux/dcache.h>
465 ],[
466        d_add_unique(NULL, NULL);
467 ],[
468         AC_MSG_RESULT([yes])
469         AC_DEFINE(HAVE_D_ADD_UNIQUE, 1, [Kernel has d_add_unique])
470 ],[
471         AC_MSG_RESULT([no])
472 ])
473 ])
474
475 AC_DEFUN([LC_BIT_SPINLOCK_H],
476 [LB_CHECK_FILE([$LINUX/include/linux/bit_spinlock.h],[
477         AC_MSG_CHECKING([if bit_spinlock.h can be compiled])
478         LB_LINUX_TRY_COMPILE([
479                 #include <asm/processor.h>
480                 #include <linux/spinlock.h>
481                 #include <linux/bit_spinlock.h>
482         ],[],[
483                 AC_MSG_RESULT([yes])
484                 AC_DEFINE(HAVE_BIT_SPINLOCK_H, 1, [Kernel has bit_spinlock.h])
485         ],[
486                 AC_MSG_RESULT([no])
487         ])
488 ],
489 [])
490 ])
491
492 #
493 # LC_POSIX_ACL_XATTR
494 #
495 # If we have xattr_acl.h
496 #
497 AC_DEFUN([LC_XATTR_ACL],
498 [LB_CHECK_FILE([$LINUX/include/linux/xattr_acl.h],[
499         AC_MSG_CHECKING([if xattr_acl.h can be compiled])
500         LB_LINUX_TRY_COMPILE([
501                 #include <linux/xattr_acl.h>
502         ],[],[
503                 AC_MSG_RESULT([yes])
504                 AC_DEFINE(HAVE_XATTR_ACL, 1, [Kernel has xattr_acl])
505         ],[
506                 AC_MSG_RESULT([no])
507         ])
508 ],
509 [])
510 ])
511
512 #
513 # LC_LINUX_FIEMAP_H
514 #
515 # If we have fiemap.h
516 # after 2.6.27 use fiemap.h in include/linux
517 #
518 AC_DEFUN([LC_LINUX_FIEMAP_H],
519 [LB_CHECK_FILE([$LINUX/include/linux/fiemap.h],[
520         AC_MSG_CHECKING([if fiemap.h can be compiled])
521         LB_LINUX_TRY_COMPILE([
522                 #include <linux/fiemap.h>
523         ],[],[
524                 AC_MSG_RESULT([yes])
525                 AC_DEFINE(HAVE_LINUX_FIEMAP_H, 1, [Kernel has fiemap.h])
526         ],[
527                 AC_MSG_RESULT([no])
528         ])
529 ],
530 [])
531 ])
532
533
534 AC_DEFUN([LC_STRUCT_INTENT_FILE],
535 [AC_MSG_CHECKING([if struct open_intent has a file field])
536 LB_LINUX_TRY_COMPILE([
537         #include <linux/fs.h>
538         #include <linux/namei.h>
539 ],[
540         struct open_intent intent;
541         &intent.file;
542 ],[
543         AC_MSG_RESULT([yes])
544         AC_DEFINE(HAVE_FILE_IN_STRUCT_INTENT, 1, [struct open_intent has a file field])
545 ],[
546         AC_MSG_RESULT([no])
547 ])
548 ])
549
550
551 AC_DEFUN([LC_POSIX_ACL_XATTR_H],
552 [LB_CHECK_FILE([$LINUX/include/linux/posix_acl_xattr.h],[
553         AC_MSG_CHECKING([if linux/posix_acl_xattr.h can be compiled])
554         LB_LINUX_TRY_COMPILE([
555                 #include <linux/posix_acl_xattr.h>
556         ],[],[
557                 AC_MSG_RESULT([yes])
558                 AC_DEFINE(HAVE_LINUX_POSIX_ACL_XATTR_H, 1, [linux/posix_acl_xattr.h found])
559
560         ],[
561                 AC_MSG_RESULT([no])
562         ])
563 $1
564 ],[
565 AC_MSG_RESULT([no])
566 ])
567 ])
568
569 #
570 # LC_EXPORT___IGET
571 # starting from 2.6.19 linux kernel exports __iget()
572 #
573 AC_DEFUN([LC_EXPORT___IGET],
574 [LB_CHECK_SYMBOL_EXPORT([__iget],
575 [fs/inode.c],[
576         AC_DEFINE(HAVE_EXPORT___IGET, 1, [kernel exports __iget])
577 ],[
578 ])
579 ])
580
581 AC_DEFUN([LC_LUSTRE_VERSION_H],
582 [LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
583         rm -f "$LUSTRE/include/linux/lustre_version.h"
584 ],[
585         touch "$LUSTRE/include/linux/lustre_version.h"
586         if test x$enable_server = xyes ; then
587                 AC_MSG_WARN([Unpatched kernel detected.])
588                 AC_MSG_WARN([Lustre servers cannot be built with an unpatched kernel;])
589                 AC_MSG_WARN([disabling server build])
590                 enable_server='no'
591         fi
592 ])
593 ])
594
595 AC_DEFUN([LC_FUNC_SET_FS_PWD],
596 [LB_CHECK_SYMBOL_EXPORT([set_fs_pwd],
597 [fs/namespace.c],[
598         AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd is exported])
599 ],[
600 ])
601 ])
602
603 #
604 # LC_CAPA_CRYPTO
605 #
606 AC_DEFUN([LC_CAPA_CRYPTO],
607 [LB_LINUX_CONFIG_IM([CRYPTO],[],[
608         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO is enabled in your kernel.])
609 ])
610 LB_LINUX_CONFIG_IM([CRYPTO_HMAC],[],[
611         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO_HMAC is enabled in your kernel.])
612 ])
613 LB_LINUX_CONFIG_IM([CRYPTO_SHA1],[],[
614         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO_SHA1 is enabled in your kernel.])
615 ])
616 ])
617
618 #
619 # LC_CONFIG_RMTCLIENT
620 #
621 dnl FIXME
622 dnl the AES symbol usually tied with arch, e.g. CRYPTO_AES_586
623 dnl FIXME
624 AC_DEFUN([LC_CONFIG_RMTCLIENT],
625 [LB_LINUX_CONFIG_IM([CRYPTO_AES],[],[
626         AC_MSG_WARN([Lustre remote client require that CONFIG_CRYPTO_AES is enabled in your kernel.])
627 ])
628 ])
629
630 AC_DEFUN([LC_SUNRPC_CACHE],
631 [AC_MSG_CHECKING([if sunrpc struct cache_head uses kref])
632 LB_LINUX_TRY_COMPILE([
633         #include <linux/sunrpc/cache.h>
634 ],[
635         struct cache_head ch;
636         &ch.ref.refcount;
637 ],[
638         AC_MSG_RESULT([yes])
639         AC_DEFINE(HAVE_SUNRPC_CACHE_V2, 1, [sunrpc cache facility v2])
640 ],[
641         AC_MSG_RESULT([no])
642 ])
643 ])
644
645 AC_DEFUN([LC_CONFIG_SUNRPC],
646 [LB_LINUX_CONFIG_IM([SUNRPC],[],
647                     [AC_MSG_ERROR([kernel SUNRPC support is required by using GSS.])])
648  LC_SUNRPC_CACHE
649 ])
650
651 #
652 # LC_CONFIG_GSS_KEYRING (default enabled, if gss is enabled)
653 #
654 AC_DEFUN([LC_CONFIG_GSS_KEYRING],
655 [AC_MSG_CHECKING([whether to enable gss keyring backend])
656  AC_ARG_ENABLE([gss_keyring],
657                [AC_HELP_STRING([--disable-gss-keyring],
658                                [disable gss keyring backend])],
659                [],[enable_gss_keyring='yes'])
660  AC_MSG_RESULT([$enable_gss_keyring])
661
662  if test x$enable_gss_keyring != xno; then
663         LB_LINUX_CONFIG_IM([KEYS],[],
664                            [AC_MSG_ERROR([GSS keyring backend require that CONFIG_KEYS be enabled in your kernel.])])
665
666         AC_CHECK_LIB([keyutils], [keyctl_search], [],
667                      [AC_MSG_ERROR([libkeyutils is not found, which is required by gss keyring backend])],)
668
669         AC_DEFINE([HAVE_GSS_KEYRING], [1],
670                   [Define this if you enable gss keyring backend])
671  fi
672 ])
673
674 #
675 # LC_CONFIG_GSS (default disabled)
676 #
677 # Build gss and related tools of Lustre. Currently both kernel and user space
678 # parts are depend on linux platform.
679 #
680 AC_DEFUN([LC_CONFIG_GSS],
681 [AC_MSG_CHECKING([whether to enable gss/krb5 support])
682  AC_ARG_ENABLE([gss],
683                [AC_HELP_STRING([--enable-gss], [enable gss/krb5 support])],
684                [],[enable_gss='no'])
685  AC_MSG_RESULT([$enable_gss])
686
687  if test x$enable_gss == xyes; then
688         LC_CONFIG_GSS_KEYRING
689         LC_CONFIG_SUNRPC
690
691         AC_DEFINE([HAVE_GSS], [1], [Define this if you enable gss])
692
693         LB_LINUX_CONFIG_IM([CRYPTO_MD5],[],
694                            [AC_MSG_WARN([kernel MD5 support is recommended by using GSS.])])
695         LB_LINUX_CONFIG_IM([CRYPTO_SHA1],[],
696                            [AC_MSG_WARN([kernel SHA1 support is recommended by using GSS.])])
697         LB_LINUX_CONFIG_IM([CRYPTO_SHA256],[],
698                            [AC_MSG_WARN([kernel SHA256 support is recommended by using GSS.])])
699         LB_LINUX_CONFIG_IM([CRYPTO_SHA512],[],
700                            [AC_MSG_WARN([kernel SHA512 support is recommended by using GSS.])])
701
702         AC_CHECK_LIB([gssapi], [gss_init_sec_context],
703                      [GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssapi"],
704                      [AC_CHECK_LIB([gssglue], [gss_init_sec_context],
705                                    [GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssglue"],
706                                    [AC_MSG_ERROR([libgssapi or libgssglue is not found, which is required by GSS.])])],)
707
708         AC_SUBST(GSSAPI_LIBS)
709
710         AC_KERBEROS_V5
711  fi
712 ])
713
714 # LC_FUNC_MS_FLOCK_LOCK
715 #
716 # SLES9 kernel has MS_FLOCK_LOCK sb flag
717 #
718 AC_DEFUN([LC_FUNC_MS_FLOCK_LOCK],
719 [AC_MSG_CHECKING([if kernel has MS_FLOCK_LOCK sb flag])
720 LB_LINUX_TRY_COMPILE([
721         #include <linux/fs.h>
722 ],[
723         int flags = MS_FLOCK_LOCK;
724 ],[
725         AC_DEFINE(HAVE_MS_FLOCK_LOCK, 1,
726                 [kernel has MS_FLOCK_LOCK flag])
727         AC_MSG_RESULT([yes])
728 ],[
729         AC_MSG_RESULT([no])
730 ])
731 ])
732
733 #
734 # LC_FUNC_HAVE_CAN_SLEEP_ARG
735 #
736 # SLES9 kernel has third arg can_sleep
737 # in fs/locks.c: flock_lock_file_wait()
738 #
739 AC_DEFUN([LC_FUNC_HAVE_CAN_SLEEP_ARG],
740 [AC_MSG_CHECKING([if kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
741 LB_LINUX_TRY_COMPILE([
742         #include <linux/fs.h>
743 ],[
744         int cansleep;
745         struct file *file;
746         struct file_lock *file_lock;
747         flock_lock_file_wait(file, file_lock, cansleep);
748 ],[
749         AC_DEFINE(HAVE_CAN_SLEEP_ARG, 1,
750                 [kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
751         AC_MSG_RESULT([yes])
752 ],[
753         AC_MSG_RESULT([no])
754 ])
755 ])
756
757 #
758 # LC_FUNC_F_OP_FLOCK
759 #
760 # rhel4.2 kernel has f_op->flock field
761 #
762 AC_DEFUN([LC_FUNC_F_OP_FLOCK],
763 [AC_MSG_CHECKING([if struct file_operations has flock field])
764 LB_LINUX_TRY_COMPILE([
765         #include <linux/fs.h>
766 ],[
767         struct file_operations ll_file_operations_flock;
768         ll_file_operations_flock.flock = NULL;
769 ],[
770         AC_DEFINE(HAVE_F_OP_FLOCK, 1,
771                 [struct file_operations has flock field])
772         AC_MSG_RESULT([yes])
773 ],[
774         AC_MSG_RESULT([no])
775 ])
776 ])
777
778 #
779 # LC_TASK_PPTR
780 #
781 # task struct has p_pptr instead of parent
782 #
783 AC_DEFUN([LC_TASK_PPTR],
784 [AC_MSG_CHECKING([task p_pptr found])
785 LB_LINUX_TRY_COMPILE([
786         #include <linux/sched.h>
787 ],[
788         struct task_struct *p;
789         
790         p = p->p_pptr;
791 ],[
792         AC_MSG_RESULT([yes])
793         AC_DEFINE(HAVE_TASK_PPTR, 1, [task p_pptr found])
794 ],[
795         AC_MSG_RESULT([no])
796 ])
797 ])
798
799 #
800 # LC_FUNC_F_OP_FLOCK
801 #
802 # rhel4.2 kernel has f_op->flock field
803 #
804 AC_DEFUN([LC_FUNC_F_OP_FLOCK],
805 [AC_MSG_CHECKING([if struct file_operations has flock field])
806 LB_LINUX_TRY_COMPILE([
807         #include <linux/fs.h>
808 ],[
809         struct file_operations ll_file_operations_flock;
810         ll_file_operations_flock.flock = NULL;
811 ],[
812         AC_DEFINE(HAVE_F_OP_FLOCK, 1,
813                 [struct file_operations has flock field])
814         AC_MSG_RESULT([yes])
815 ],[
816         AC_MSG_RESULT([no])
817 ])
818 ])
819
820 # LC_INODE_I_MUTEX
821 # after 2.6.15 inode have i_mutex intead of i_sem
822 AC_DEFUN([LC_INODE_I_MUTEX],
823 [AC_MSG_CHECKING([if inode has i_mutex ])
824 LB_LINUX_TRY_COMPILE([
825         #include <linux/mutex.h>
826         #include <linux/fs.h>
827         #undef i_mutex
828 ],[
829         struct inode i;
830
831         mutex_unlock(&i.i_mutex);
832 ],[
833         AC_MSG_RESULT(yes)
834         AC_DEFINE(HAVE_INODE_I_MUTEX, 1,
835                 [after 2.6.15 inode have i_mutex intead of i_sem])
836 ],[
837         AC_MSG_RESULT(no)
838 ])
839 ])
840
841 # LC_SEQ_LOCK
842 # after 2.6.18 seq_file has lock intead of sem
843 AC_DEFUN([LC_SEQ_LOCK],
844 [AC_MSG_CHECKING([if struct seq_file has lock field])
845 LB_LINUX_TRY_COMPILE([
846         #include <linux/seq_file.h>
847 ],[
848         struct seq_file seq;
849
850         mutex_unlock(&seq.lock);
851 ],[
852         AC_MSG_RESULT(yes)
853         AC_DEFINE(HAVE_SEQ_LOCK, 1,
854                 [after 2.6.18 seq_file has lock intead of sem])
855 ],[
856         AC_MSG_RESULT(NO)
857 ])
858 ])
859
860 # LC_DQUOTOFF_MUTEX
861 # after 2.6.17 dquote use mutex instead if semaphore
862 AC_DEFUN([LC_DQUOTOFF_MUTEX],
863 [AC_MSG_CHECKING([use dqonoff_mutex])
864 LB_LINUX_TRY_COMPILE([
865         #include <linux/mutex.h>
866         #include <linux/fs.h>
867         #include <linux/quota.h>
868 ],[
869         struct quota_info dq;
870
871         mutex_unlock(&dq.dqonoff_mutex);
872 ],[
873         AC_MSG_RESULT(yes)
874         AC_DEFINE(HAVE_DQUOTOFF_MUTEX, 1,
875                 [after 2.6.17 dquote use mutex instead if semaphore])
876 ],[
877         AC_MSG_RESULT(no)
878 ])
879 ])
880
881 #
882 # LC_STATFS_DENTRY_PARAM
883 # starting from 2.6.18 linux kernel uses dentry instead of
884 # super_block for first vfs_statfs argument
885 #
886 AC_DEFUN([LC_STATFS_DENTRY_PARAM],
887 [AC_MSG_CHECKING([first vfs_statfs parameter is dentry])
888 LB_LINUX_TRY_COMPILE([
889         #include <linux/fs.h>
890 ],[
891         int vfs_statfs(struct dentry *, struct kstatfs *);
892 ],[
893         AC_DEFINE(HAVE_STATFS_DENTRY_PARAM, 1,
894                 [first parameter of vfs_statfs is dentry])
895         AC_MSG_RESULT([yes])
896 ],[
897         AC_MSG_RESULT([no])
898 ])
899 ])
900
901 #
902 # LC_VFS_KERN_MOUNT
903 # starting from 2.6.18 kernel don't export do_kern_mount
904 # and want to use vfs_kern_mount instead.
905 #
906 AC_DEFUN([LC_VFS_KERN_MOUNT],
907 [AC_MSG_CHECKING([vfs_kern_mount exist in kernel])
908 LB_LINUX_TRY_COMPILE([
909         #include <linux/mount.h>
910 ],[
911         vfs_kern_mount(NULL, 0, NULL, NULL);
912 ],[
913         AC_DEFINE(HAVE_VFS_KERN_MOUNT, 1,
914                 [vfs_kern_mount exist in kernel])
915         AC_MSG_RESULT([yes])
916 ],[
917         AC_MSG_RESULT([no])
918 ])
919 ])
920
921 #
922 # LC_INVALIDATEPAGE_RETURN_INT
923 # more 2.6 api changes.  return type for the invalidatepage
924 # address_space_operation is 'void' in new kernels but 'int' in old
925 #
926 AC_DEFUN([LC_INVALIDATEPAGE_RETURN_INT],
927 [AC_MSG_CHECKING([invalidatepage has return int])
928 LB_LINUX_TRY_COMPILE([
929         #include <linux/buffer_head.h>
930 ],[
931         int rc = block_invalidatepage(NULL, 0);
932 ],[
933         AC_MSG_RESULT(yes)
934         AC_DEFINE(HAVE_INVALIDATEPAGE_RETURN_INT, 1,
935                 [Define if return type of invalidatepage should be int])
936 ],[
937         AC_MSG_RESULT(no)
938 ])
939 ])
940
941 # LC_UMOUNTBEGIN_HAS_VFSMOUNT
942 # more 2.6 API changes. 2.6.18 umount_begin has different parameters
943 AC_DEFUN([LC_UMOUNTBEGIN_HAS_VFSMOUNT],
944 [AC_MSG_CHECKING([if umount_begin needs vfsmount parameter instead of super_block])
945 tmp_flags="$EXTRA_KCFLAGS"
946 EXTRA_KCFLAGS="-Werror"
947 LB_LINUX_TRY_COMPILE([
948         #include <linux/fs.h>
949
950         struct vfsmount;
951         static void cfg_umount_begin (struct vfsmount *v, int flags)
952         {
953                 ;
954         }
955
956         static struct super_operations cfg_super_operations = {
957                 .umount_begin   = cfg_umount_begin,
958         };
959 ],[
960         cfg_super_operations.umount_begin(NULL,0);
961 ],[
962         AC_MSG_RESULT(yes)
963         AC_DEFINE(HAVE_UMOUNTBEGIN_VFSMOUNT, 1,
964                 [Define umount_begin need second argument])
965 ],[
966         AC_MSG_RESULT(no)
967 ])
968 EXTRA_KCFLAGS="$tmp_flags"
969 ])
970
971 # 2.6.19 API changes
972 # inode don't have i_blksize field
973 AC_DEFUN([LC_INODE_BLKSIZE],
974 [AC_MSG_CHECKING([inode has i_blksize field])
975 LB_LINUX_TRY_COMPILE([
976 #include <linux/fs.h>
977 ],[
978         struct inode i;
979         i.i_blksize = 0;
980 ],[
981         AC_MSG_RESULT(yes)
982         AC_DEFINE(HAVE_INODE_BLKSIZE, 1,
983                 [struct inode has i_blksize field])
984 ],[
985         AC_MSG_RESULT(no)
986 ])
987 ])
988
989 # LC_VFS_READDIR_U64_INO
990 # 2.6.19 use u64 for inode number instead of inode_t
991 AC_DEFUN([LC_VFS_READDIR_U64_INO],
992 [AC_MSG_CHECKING([check vfs_readdir need 64bit inode number])
993 tmp_flags="$EXTRA_KCFLAGS"
994 EXTRA_KCFLAGS="-Werror"
995 LB_LINUX_TRY_COMPILE([
996 #include <linux/fs.h>
997         int fillonedir(void * __buf, const char * name, int namlen, loff_t offset,
998                       u64 ino, unsigned int d_type)
999         {
1000                 return 0;
1001         }
1002 ],[
1003         filldir_t filter;
1004
1005         filter = fillonedir;
1006         return 1;
1007 ],[
1008         AC_MSG_RESULT(yes)
1009         AC_DEFINE(HAVE_VFS_READDIR_U64_INO, 1,
1010                 [if vfs_readdir need 64bit inode number])
1011 ],[
1012         AC_MSG_RESULT(no)
1013 ])
1014 EXTRA_KCFLAGS="$tmp_flags"
1015 ])
1016
1017 # LC_FILE_WRITEV
1018 # 2.6.19 replaced writev with aio_write
1019 AC_DEFUN([LC_FILE_WRITEV],
1020 [AC_MSG_CHECKING([writev in fops])
1021 LB_LINUX_TRY_COMPILE([
1022         #include <linux/fs.h>
1023 ],[
1024         struct file_operations *fops = NULL;
1025         fops->writev = NULL;
1026 ],[
1027         AC_MSG_RESULT(yes)
1028         AC_DEFINE(HAVE_FILE_WRITEV, 1,
1029                 [use fops->writev])
1030 ],[
1031         AC_MSG_RESULT(no)
1032 ])
1033 ])
1034
1035 # LC_GENERIC_FILE_READ
1036 # 2.6.19 replaced readv with aio_read
1037 AC_DEFUN([LC_FILE_READV],
1038 [AC_MSG_CHECKING([readv in fops])
1039 LB_LINUX_TRY_COMPILE([
1040         #include <linux/fs.h>
1041 ],[
1042         struct file_operations *fops = NULL;
1043         fops->readv = NULL;
1044 ],[
1045         AC_MSG_RESULT(yes)
1046         AC_DEFINE(HAVE_FILE_READV, 1,
1047                 [use fops->readv])
1048 ],[
1049         AC_MSG_RESULT(no)
1050 ])
1051 ])
1052
1053 # LC_NR_PAGECACHE
1054 # 2.6.18 don't export nr_pagecahe
1055 AC_DEFUN([LC_NR_PAGECACHE],
1056 [AC_MSG_CHECKING([kernel export nr_pagecache])
1057 LB_LINUX_TRY_COMPILE([
1058         #include <linux/pagemap.h>
1059 ],[
1060         return atomic_read(&nr_pagecache);
1061 ],[
1062         AC_MSG_RESULT(yes)
1063         AC_DEFINE(HAVE_NR_PAGECACHE, 1,
1064                 [is kernel export nr_pagecache])
1065 ],[
1066         AC_MSG_RESULT(no)
1067 ])
1068 ])
1069
1070 # LC_CANCEL_DIRTY_PAGE
1071 # 2.6.20 introduse cancel_dirty_page instead of
1072 # clear_page_dirty.
1073 AC_DEFUN([LC_CANCEL_DIRTY_PAGE],
1074 [AC_MSG_CHECKING([kernel has cancel_dirty_page])
1075 LB_LINUX_TRY_COMPILE([
1076         #include <linux/mm.h>
1077         #include <linux/page-flags.h>
1078 ],[
1079         cancel_dirty_page(NULL, 0);
1080 ],[
1081         AC_MSG_RESULT(yes)
1082         AC_DEFINE(HAVE_CANCEL_DIRTY_PAGE, 1,
1083                   [kernel has cancel_dirty_page instead of clear_page_dirty])
1084 ],[
1085         AC_MSG_RESULT(no)
1086 ])
1087 ])
1088
1089 #
1090 # LC_PAGE_CONSTANT
1091 #
1092 # In order to support raid5 zerocopy patch, we have to patch the kernel to make
1093 # it support constant page, which means the page won't be modified during the
1094 # IO.
1095 #
1096 AC_DEFUN([LC_PAGE_CONSTANT],
1097 [AC_MSG_CHECKING([if kernel have PageConstant defined])
1098 LB_LINUX_TRY_COMPILE([
1099         #include <linux/mm.h>
1100         #include <linux/page-flags.h>
1101 ],[
1102         #ifndef PG_constant
1103         #error "Have no raid5 zcopy patch"
1104         #endif
1105 ],[
1106         AC_MSG_RESULT(yes)
1107         AC_DEFINE(HAVE_PAGE_CONSTANT, 1, [kernel have PageConstant supported])
1108 ],[
1109         AC_MSG_RESULT(no);
1110 ])
1111 ])
1112
1113 # RHEL5 in FS-cache patch rename PG_checked flag
1114 # into PG_fs_misc
1115 AC_DEFUN([LC_PG_FS_MISC],
1116 [AC_MSG_CHECKING([kernel has PG_fs_misc])
1117 LB_LINUX_TRY_COMPILE([
1118         #include <linux/mm.h>
1119         #include <linux/page-flags.h>
1120 ],[
1121         #ifndef PG_fs_misc
1122         #error PG_fs_misc not defined in kernel
1123         #endif
1124 ],[
1125         AC_MSG_RESULT(yes)
1126         AC_DEFINE(HAVE_PG_FS_MISC, 1,
1127                   [is kernel have PG_fs_misc])
1128 ],[
1129         AC_MSG_RESULT(no)
1130 ])
1131 ])
1132
1133 # RHEL5 PageChecked and SetPageChecked defined
1134 AC_DEFUN([LC_PAGE_CHECKED],
1135 [AC_MSG_CHECKING([kernel has PageChecked and SetPageChecked])
1136 LB_LINUX_TRY_COMPILE([
1137         #include <linux/mm.h>
1138         #include <linux/page-flags.h>
1139 ],[
1140         #ifndef PageChecked
1141         #error PageChecked not defined in kernel
1142         #endif
1143         #ifndef SetPageChecked
1144         #error SetPageChecked not defined in kernel
1145         #endif
1146 ],[
1147         AC_MSG_RESULT(yes)
1148         AC_DEFINE(HAVE_PAGE_CHECKED, 1,
1149                   [does kernel have PageChecked and SetPageChecked])
1150 ],[
1151         AC_MSG_RESULT(no)
1152 ])
1153 ])
1154
1155 AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE],
1156 [LB_CHECK_SYMBOL_EXPORT([truncate_complete_page],
1157 [mm/truncate.c],[
1158 AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
1159             [kernel export truncate_complete_page])
1160 ],[
1161 ])
1162 ])
1163
1164 AC_DEFUN([LC_EXPORT_D_REHASH_COND],
1165 [LB_CHECK_SYMBOL_EXPORT([d_rehash_cond],
1166 [fs/dcache.c],[
1167 AC_DEFINE(HAVE_D_REHASH_COND, 1,
1168             [d_rehash_cond is exported by the kernel])
1169 ],[
1170 ])
1171 ])
1172
1173 AC_DEFUN([LC_EXPORT___D_REHASH],
1174 [LB_CHECK_SYMBOL_EXPORT([__d_rehash],
1175 [fs/dcache.c],[
1176 AC_DEFINE(HAVE___D_REHASH, 1,
1177             [__d_rehash is exported by the kernel])
1178 ],[
1179 ])
1180 ])
1181
1182 AC_DEFUN([LC_EXPORT_D_MOVE_LOCKED],
1183 [LB_CHECK_SYMBOL_EXPORT([d_move_locked],
1184 [fs/dcache.c],[
1185 AC_DEFINE(HAVE_D_MOVE_LOCKED, 1,
1186             [d_move_locked is exported by the kernel])
1187 ],[
1188 ])
1189 ])
1190
1191 AC_DEFUN([LC_EXPORT___D_MOVE],
1192 [LB_CHECK_SYMBOL_EXPORT([__d_move],
1193 [fs/dcache.c],[
1194 AC_DEFINE(HAVE___D_MOVE, 1,
1195             [__d_move is exported by the kernel])
1196 ],[
1197 ])
1198 ])
1199
1200 #
1201 # LC_EXPORT_INVALIDATE_MAPPING_PAGES
1202 #
1203 # SLES9, RHEL4, RHEL5, vanilla 2.6.24 export invalidate_mapping_pages() but
1204 # SLES10 2.6.16 does not, for some reason.  For filter cache invalidation.
1205 #
1206 AC_DEFUN([LC_EXPORT_INVALIDATE_MAPPING_PAGES],
1207     [LB_CHECK_SYMBOL_EXPORT([invalidate_mapping_pages], [mm/truncate.c], [
1208          AC_DEFINE(HAVE_INVALIDATE_MAPPING_PAGES, 1,
1209                         [exported invalidate_mapping_pages])],
1210     [LB_CHECK_SYMBOL_EXPORT([invalidate_inode_pages], [mm/truncate.c], [
1211          AC_DEFINE(HAVE_INVALIDATE_INODE_PAGES, 1,
1212                         [exported invalidate_inode_pages])], [
1213        AC_MSG_ERROR([no way to invalidate pages])
1214   ])
1215     ],[])
1216 ])
1217
1218 #
1219 # LC_EXPORT_FILEMAP_FDATASYNC_RANGE
1220 #
1221 # No standard kernels export this
1222 #
1223 AC_DEFUN([LC_EXPORT_FILEMAP_FDATAWRITE_RANGE],
1224 [LB_CHECK_SYMBOL_EXPORT([filemap_fdatawrite_range],
1225 [mm/filemap.c],[
1226 AC_DEFINE(HAVE_FILEMAP_FDATAWRITE_RANGE, 1,
1227             [filemap_fdatawrite_range is exported by the kernel])
1228 ],[
1229 ])
1230 ])
1231
1232 # The actual symbol exported varies among architectures, so we need
1233 # to check many symbols (but only in the current architecture.)  No
1234 # matter what symbol is exported, the kernel #defines node_to_cpumask
1235 # to the appropriate function and that's what we use.
1236 AC_DEFUN([LC_EXPORT_NODE_TO_CPUMASK],
1237          [LB_CHECK_SYMBOL_EXPORT([node_to_cpumask],
1238                                  [arch/$LINUX_ARCH/mm/numa.c],
1239                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
1240                                             [node_to_cpumask is exported by
1241                                              the kernel])]) # x86_64
1242           LB_CHECK_SYMBOL_EXPORT([node_to_cpu_mask],
1243                                  [arch/$LINUX_ARCH/kernel/smpboot.c],
1244                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
1245                                             [node_to_cpumask is exported by
1246                                              the kernel])]) # ia64
1247           LB_CHECK_SYMBOL_EXPORT([node_2_cpu_mask],
1248                                  [arch/$LINUX_ARCH/kernel/smpboot.c],
1249                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
1250                                             [node_to_cpumask is exported by
1251                                              the kernel])]) # i386
1252           ])
1253
1254 # 2.6.22 lost second parameter for invalidate_bdev
1255 AC_DEFUN([LC_INVALIDATE_BDEV_2ARG],
1256 [AC_MSG_CHECKING([if invalidate_bdev has second argument])
1257 LB_LINUX_TRY_COMPILE([
1258         #include <linux/buffer_head.h>
1259 ],[
1260         invalidate_bdev(NULL,0);
1261 ],[
1262         AC_MSG_RESULT([yes])
1263         AC_DEFINE(HAVE_INVALIDATE_BDEV_2ARG, 1,
1264                 [invalidate_bdev has second argument])
1265 ],[
1266         AC_MSG_RESULT([no])
1267 ])
1268 ])
1269
1270 # 2.6.23 have return type 'void' for unregister_blkdev
1271 AC_DEFUN([LC_UNREGISTER_BLKDEV_RETURN_INT],
1272 [AC_MSG_CHECKING([if unregister_blkdev return int])
1273 LB_LINUX_TRY_COMPILE([
1274         #include <linux/fs.h>
1275 ],[
1276         int i = unregister_blkdev(0,NULL);
1277 ],[
1278         AC_MSG_RESULT([yes])
1279         AC_DEFINE(HAVE_UNREGISTER_BLKDEV_RETURN_INT, 1,
1280                 [unregister_blkdev return int])
1281 ],[
1282         AC_MSG_RESULT([no])
1283 ])
1284 ])
1285
1286 # 2.6.23 change .sendfile to .splice_read
1287 AC_DEFUN([LC_KERNEL_SPLICE_READ],
1288 [AC_MSG_CHECKING([if kernel has .splice_read])
1289 LB_LINUX_TRY_COMPILE([
1290         #include <linux/fs.h>
1291 ],[
1292         struct file_operations file;
1293
1294         file.splice_read = NULL;
1295 ], [
1296         AC_MSG_RESULT([yes])
1297         AC_DEFINE(HAVE_KERNEL_SPLICE_READ, 1,
1298                 [kernel has .slice_read])
1299 ],[
1300         AC_MSG_RESULT([no])
1301 ])
1302 ])
1303
1304 # 2.6.23 extract nfs export related data into exportfs.h
1305 AC_DEFUN([LC_HAVE_EXPORTFS_H],
1306 [
1307 tmpfl="$CFLAGS"
1308 CFLAGS="$CFLAGS -I$LINUX_OBJ/include"
1309 AC_CHECK_HEADERS([linux/exportfs.h])
1310 CFLAGS="$tmpfl"
1311 ])
1312
1313 #
1314 # LC_VFS_INTENT_PATCHES
1315 #
1316 # check if the kernel has the VFS intent patches
1317 AC_DEFUN([LC_VFS_INTENT_PATCHES],
1318 [AC_MSG_CHECKING([if the kernel has the VFS intent patches])
1319 LB_LINUX_TRY_COMPILE([
1320         #include <linux/fs.h>
1321         #include <linux/namei.h>
1322 ],[
1323         struct nameidata nd;
1324         struct lookup_intent *it;
1325
1326         it = &nd.intent;
1327         intent_init(it, IT_OPEN);
1328         it->d.lustre.it_disposition = 0;
1329         it->d.lustre.it_data = NULL;
1330 ],[
1331         AC_MSG_RESULT([yes])
1332         AC_DEFINE(HAVE_VFS_INTENT_PATCHES, 1, [VFS intent patches are applied])
1333 ],[
1334         AC_MSG_RESULT([no])
1335 ])
1336 ])
1337
1338 AC_DEFUN([LC_S_TIME_GRAN],
1339 [AC_MSG_CHECKING([if super block has s_time_gran member])
1340 LB_LINUX_TRY_COMPILE([
1341         #include <linux/fs.h>
1342 ],[
1343         struct super_block sb;
1344
1345         return sb.s_time_gran;
1346 ],[
1347         AC_MSG_RESULT([yes])
1348         AC_DEFINE(HAVE_S_TIME_GRAN, 1, [super block has s_time_gran member])
1349 ],[
1350         AC_MSG_RESULT([no])
1351 ])
1352 ])
1353
1354 AC_DEFUN([LC_SB_TIME_GRAN],
1355 [AC_MSG_CHECKING([if kernel has old get_sb_time_gran])
1356 LB_LINUX_TRY_COMPILE([
1357         #include <linux/fs.h>
1358 ],[
1359         return get_sb_time_gran(NULL);
1360 ],[
1361         AC_MSG_RESULT([yes])
1362         AC_DEFINE(HAVE_SB_TIME_GRAN, 1, [kernel has old get_sb_time_gran])
1363 ],[
1364         AC_MSG_RESULT([no])
1365 ])
1366 ])
1367
1368
1369 # ~2.6.12 merge patch from oracle to convert tree_lock from spinlock to rwlock
1370 AC_DEFUN([LC_RW_TREE_LOCK],
1371 [AC_MSG_CHECKING([if kernel has tree_lock as rwlock])
1372 tmp_flags="$EXTRA_KCFLAGS"
1373 EXTRA_KCFLAGS="-Werror"
1374 LB_LINUX_TRY_COMPILE([
1375         #include <linux/fs.h>
1376 ],[
1377         struct address_space a;
1378
1379         write_lock(&a.tree_lock);
1380 ],[
1381         AC_MSG_RESULT([yes])
1382         AC_DEFINE(HAVE_RW_TREE_LOCK, 1, [kernel has tree_lock as rw_lock])
1383 ],[
1384         AC_MSG_RESULT([no])
1385 ])
1386 EXTRA_KCFLAGS="$tmp_flags"
1387 ])
1388
1389 AC_DEFUN([LC_CONST_ACL_SIZE],
1390 [AC_MSG_CHECKING([calc acl size])
1391 tmp_flags="$CFLAGS"
1392 CFLAGS="$CFLAGS -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 $EXTRA_KCFLAGS"
1393 AC_TRY_RUN([
1394 #define __KERNEL__
1395 #include <linux/autoconf.h>
1396 #include <linux/types.h>
1397 #undef __KERNEL__
1398 // block include
1399 #define __LINUX_POSIX_ACL_H
1400
1401 # ifdef CONFIG_FS_POSIX_ACL
1402 #  ifdef HAVE_XATTR_ACL
1403 #   include <linux/xattr_acl.h>
1404 #  endif
1405 #  ifdef HAVE_LINUX_POSIX_ACL_XATTR_H
1406 #   include <linux/posix_acl_xattr.h>
1407 #  endif
1408 # endif
1409
1410 #include <lustre_acl.h>
1411
1412 #include <stdio.h>
1413
1414 int main(void)
1415 {
1416     int size = mds_xattr_acl_size(LUSTRE_POSIX_ACL_MAX_ENTRIES);
1417     FILE *f = fopen("acl.size","w+");
1418     fprintf(f,"%d", size);
1419     fclose(f);
1420
1421     return 0;
1422 }
1423
1424 ],[
1425         acl_size=`cat acl.size`
1426         AC_MSG_RESULT([ACL size $acl_size])
1427         AC_DEFINE_UNQUOTED(XATTR_ACL_SIZE, AS_TR_SH([$acl_size]), [size of xattr acl])
1428 ],[
1429         AC_ERROR([ACL size can't computed])
1430 ])
1431 CFLAGS="$tmp_flags"
1432 ])
1433
1434 #
1435 # check for crypto API
1436 #
1437 AC_DEFUN([LC_ASYNC_BLOCK_CIPHER],
1438 [AC_MSG_CHECKING([if kernel has block cipher support])
1439 LB_LINUX_TRY_COMPILE([
1440         #include <linux/crypto.h>
1441 ],[
1442         int v = CRYPTO_ALG_TYPE_BLKCIPHER;
1443 ],[
1444         AC_MSG_RESULT([yes])
1445         AC_DEFINE(HAVE_ASYNC_BLOCK_CIPHER, 1, [kernel has block cipher support])
1446 ],[
1447         AC_MSG_RESULT([no])
1448 ])
1449 ])
1450
1451 #
1452 # check for FS_RENAME_DOES_D_MOVE flag
1453 #
1454 AC_DEFUN([LC_FS_RENAME_DOES_D_MOVE],
1455 [AC_MSG_CHECKING([if kernel has FS_RENAME_DOES_D_MOVE flag])
1456 LB_LINUX_TRY_COMPILE([
1457         #include <linux/fs.h>
1458 ],[
1459         int v = FS_RENAME_DOES_D_MOVE;
1460 ],[
1461         AC_MSG_RESULT([yes])
1462         AC_DEFINE(HAVE_FS_RENAME_DOES_D_MOVE, 1, [kernel has FS_RENAME_DOES_D_MOVE flag])
1463 ],[
1464         AC_MSG_RESULT([no])
1465 ])
1466 ])
1467
1468 #
1469 # LC_PROG_LINUX
1470 #
1471 # Lustre linux kernel checks
1472 #
1473 AC_DEFUN([LC_PROG_LINUX],
1474          [LC_LUSTRE_VERSION_H
1475          if test x$enable_server = xyes ; then
1476              AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
1477              LC_CONFIG_BACKINGFS
1478          fi
1479          LC_CONFIG_PINGER
1480          LC_CONFIG_CHECKSUM
1481          LC_CONFIG_LIBLUSTRE_RECOVERY
1482          LC_CONFIG_HEALTH_CHECK_WRITE
1483          LC_CONFIG_LRU_RESIZE
1484          LC_QUOTA_MODULE
1485
1486          LC_TASK_PPTR
1487          # RHEL4 patches
1488          LC_EXPORT_TRUNCATE_COMPLETE
1489          LC_EXPORT_D_REHASH_COND
1490          LC_EXPORT___D_REHASH
1491          LC_EXPORT_D_MOVE_LOCKED
1492          LC_EXPORT___D_MOVE
1493          LC_EXPORT_NODE_TO_CPUMASK
1494
1495          LC_FUNC_RELEASEPAGE_WITH_INT
1496          LC_HEADER_MM_INLINE
1497          LC_STRUCT_INODE
1498          LC_FUNC_REGISTER_CACHE
1499          LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
1500          LC_FUNC_DEV_SET_RDONLY
1501          LC_FUNC_FILEMAP_FDATAWRITE
1502          LC_STRUCT_STATFS
1503          LC_FUNC_PAGE_MAPPED
1504          LC_STRUCT_FILE_OPS_UNLOCKED_IOCTL
1505          LC_FILEMAP_POPULATE
1506          LC_D_ADD_UNIQUE
1507          LC_BIT_SPINLOCK_H
1508
1509          LC_XATTR_ACL
1510          LC_POSIX_ACL_XATTR_H
1511          LC_CONST_ACL_SIZE
1512
1513          LC_STRUCT_INTENT_FILE
1514
1515          LC_FUNC_SET_FS_PWD
1516          LC_CAPA_CRYPTO
1517          LC_CONFIG_RMTCLIENT
1518          LC_CONFIG_GSS
1519          LC_FUNC_MS_FLOCK_LOCK
1520          LC_FUNC_HAVE_CAN_SLEEP_ARG
1521          LC_FUNC_F_OP_FLOCK
1522          LC_QUOTA_READ
1523          LC_COOKIE_FOLLOW_LINK
1524          LC_FUNC_RCU
1525          LC_PERCPU_COUNTER
1526          LC_QUOTA64
1527
1528          # does the kernel have VFS intent patches?
1529          LC_VFS_INTENT_PATCHES
1530
1531          # ~2.6.11
1532          LC_S_TIME_GRAN
1533          LC_SB_TIME_GRAN
1534
1535          # 2.6.12
1536          LC_RW_TREE_LOCK
1537
1538          # 2.6.15
1539          LC_INODE_I_MUTEX
1540
1541          # 2.6.16
1542          LC_SECURITY_PLUG  # for SLES10 SP2
1543
1544          # 2.6.17
1545          LC_DQUOTOFF_MUTEX
1546
1547          # 2.6.18
1548          LC_NR_PAGECACHE
1549          LC_STATFS_DENTRY_PARAM
1550          LC_VFS_KERN_MOUNT
1551          LC_INVALIDATEPAGE_RETURN_INT
1552          LC_UMOUNTBEGIN_HAS_VFSMOUNT
1553          LC_SEQ_LOCK
1554          if test x$enable_server = xyes ; then
1555                 LC_EXPORT_INVALIDATE_MAPPING_PAGES
1556                 LC_EXPORT_FILEMAP_FDATAWRITE_RANGE
1557          fi
1558
1559          #2.6.18 + RHEL5 (fc6)
1560          LC_PG_FS_MISC
1561          LC_PAGE_CHECKED
1562
1563          # 2.6.19
1564          LC_INODE_BLKSIZE
1565          LC_VFS_READDIR_U64_INO
1566          LC_FILE_WRITEV
1567          LC_FILE_READV
1568
1569          # 2.6.20
1570          LC_CANCEL_DIRTY_PAGE
1571
1572          # raid5-zerocopy patch
1573          LC_PAGE_CONSTANT
1574
1575          # 2.6.22
1576          LC_INVALIDATE_BDEV_2ARG
1577          LC_ASYNC_BLOCK_CIPHER
1578          LC_FS_RENAME_DOES_D_MOVE
1579          # 2.6.23
1580          LC_UNREGISTER_BLKDEV_RETURN_INT
1581          LC_KERNEL_SPLICE_READ
1582          LC_HAVE_EXPORTFS_H
1583 ])
1584
1585 #
1586 # LC_CONFIG_CLIENT_SERVER
1587 #
1588 # Build client/server sides of Lustre
1589 #
1590 AC_DEFUN([LC_CONFIG_CLIENT_SERVER],
1591 [AC_MSG_CHECKING([whether to build Lustre server support])
1592 AC_ARG_ENABLE([server],
1593         AC_HELP_STRING([--disable-server],
1594                         [disable Lustre server support]),
1595         [],[enable_server='yes'])
1596 AC_MSG_RESULT([$enable_server])
1597
1598 AC_MSG_CHECKING([whether to build Lustre client support])
1599 AC_ARG_ENABLE([client],
1600         AC_HELP_STRING([--disable-client],
1601                         [disable Lustre client support]),
1602         [],[enable_client='yes'])
1603 AC_MSG_RESULT([$enable_client])])
1604
1605 #
1606 # LC_CONFIG_LIBLUSTRE
1607 #
1608 # whether to build liblustre
1609 #
1610 AC_DEFUN([LC_CONFIG_LIBLUSTRE],
1611 [AC_MSG_CHECKING([whether to build Lustre library])
1612 AC_ARG_ENABLE([liblustre],
1613         AC_HELP_STRING([--disable-liblustre],
1614                         [disable building of Lustre library]),
1615         [],[enable_liblustre=$with_sysio])
1616 AC_MSG_RESULT([$enable_liblustre])
1617 # only build sysio if liblustre is built
1618 with_sysio="$enable_liblustre"
1619
1620 AC_MSG_CHECKING([whether to build liblustre tests])
1621 AC_ARG_ENABLE([liblustre-tests],
1622         AC_HELP_STRING([--enable-liblustre-tests],
1623                         [enable liblustre tests, if --disable-tests is used]),
1624         [],[enable_liblustre_tests=$enable_tests])
1625 if test x$enable_liblustre != xyes ; then
1626    enable_liblustre_tests='no'
1627 fi
1628 AC_MSG_RESULT([$enable_liblustre_tests])
1629
1630 AC_MSG_CHECKING([whether to enable liblustre acl])
1631 AC_ARG_ENABLE([liblustre-acl],
1632         AC_HELP_STRING([--disable-liblustre-acl],
1633                         [disable ACL support for liblustre]),
1634         [],[enable_liblustre_acl=yes])
1635 AC_MSG_RESULT([$enable_liblustre_acl])
1636 if test x$enable_liblustre_acl = xyes ; then
1637   AC_DEFINE(LIBLUSTRE_POSIX_ACL, 1, Liblustre Support ACL-enabled MDS)
1638 fi
1639
1640 #
1641 # --enable-mpitest
1642 #
1643 AC_ARG_ENABLE(mpitests,
1644         AC_HELP_STRING([--enable-mpitest=yes|no|mpich directory],
1645                            [include mpi tests]),
1646         [
1647          enable_mpitests=yes
1648          case $enableval in
1649          yes)
1650                 MPI_ROOT=/opt/mpich
1651                 LDFLAGS="$LDFLAGS -L$MPI_ROOT/ch-p4/lib -L$MPI_ROOT/ch-p4/lib64"
1652                 CFLAGS="$CFLAGS -I$MPI_ROOT/include"
1653                 ;;
1654          no)
1655                 enable_mpitests=no
1656                 ;;
1657          [[\\/$]]* | ?:[[\\/]]* )
1658                 MPI_ROOT=$enableval
1659                 LDFLAGS="$LDFLAGS -L$with_mpi/lib"
1660                 CFLAGS="$CFLAGS -I$MPI_ROOT/include"
1661                 ;;
1662          *)
1663                  AC_MSG_ERROR([expected absolute directory name for --enable-mpitests or yes or no])
1664                  ;;
1665          esac
1666         ],
1667         [
1668         MPI_ROOT=/opt/mpich
1669         LDFLAGS="$LDFLAGS -L$MPI_ROOT/ch-p4/lib -L$MPI_ROOT/ch-p4/lib64"
1670         CFLAGS="$CFLAGS -I$MPI_ROOT/include"
1671         enable_mpitests=yes
1672         ]
1673 )
1674 AC_SUBST(MPI_ROOT)
1675
1676 if test x$enable_mpitests != xno; then
1677         AC_MSG_CHECKING([whether to mpitests can be built])
1678         AC_CHECK_FILE([$MPI_ROOT/include/mpi.h],
1679                       [AC_CHECK_LIB([mpich],[MPI_Start],[enable_mpitests=yes],[enable_mpitests=no])],
1680                       [enable_mpitests=no])
1681 fi
1682 AC_MSG_RESULT([$enable_mpitests])
1683
1684
1685 AC_MSG_NOTICE([Enabling Lustre configure options for libsysio])
1686 ac_configure_args="$ac_configure_args --with-lustre-hack --with-sockets"
1687
1688 LC_CONFIG_PINGER
1689 LC_CONFIG_LIBLUSTRE_RECOVERY
1690 ])
1691
1692 AC_DEFUN([LC_CONFIG_LRU_RESIZE],
1693 [AC_MSG_CHECKING([whether to enable lru self-adjusting])
1694 AC_ARG_ENABLE([lru_resize],
1695         AC_HELP_STRING([--enable-lru-resize],
1696                         [enable lru resize support]),
1697         [],[enable_lru_resize='yes'])
1698 AC_MSG_RESULT([$enable_lru_resize])
1699 if test x$enable_lru_resize != xno; then
1700    AC_DEFINE(HAVE_LRU_RESIZE_SUPPORT, 1, [Enable lru resize support])
1701 fi
1702 ])
1703
1704 #
1705 # LC_CONFIG_QUOTA
1706 #
1707 # whether to enable quota support global control
1708 #
1709 AC_DEFUN([LC_CONFIG_QUOTA],
1710 [AC_ARG_ENABLE([quota],
1711         AC_HELP_STRING([--enable-quota],
1712                         [enable quota support]),
1713         [],[enable_quota='yes'])
1714 ])
1715
1716 # whether to enable quota support(kernel modules)
1717 AC_DEFUN([LC_QUOTA_MODULE],
1718 [if test x$enable_quota != xno; then
1719     LB_LINUX_CONFIG([QUOTA],[
1720         enable_quota_module='yes'
1721         AC_DEFINE(HAVE_QUOTA_SUPPORT, 1, [Enable quota support])
1722     ],[
1723         enable_quota_module='no'
1724         AC_MSG_WARN([quota is not enabled because the kernel - lacks quota support])
1725     ])
1726 fi
1727 ])
1728
1729 AC_DEFUN([LC_QUOTA],
1730 [#check global
1731 LC_CONFIG_QUOTA
1732 #check for utils
1733 AC_CHECK_HEADER(sys/quota.h,
1734                 [AC_DEFINE(HAVE_SYS_QUOTA_H, 1, [Define to 1 if you have <sys/quota.h>.])],
1735                 [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
1736 ])
1737
1738 AC_DEFUN([LC_QUOTA_READ],
1739 [AC_MSG_CHECKING([if kernel supports quota_read])
1740 LB_LINUX_TRY_COMPILE([
1741         #include <linux/fs.h>
1742 ],[
1743         struct super_operations sp;
1744         void *i = (void *)sp.quota_read;
1745 ],[
1746         AC_MSG_RESULT([yes])
1747         AC_DEFINE(KERNEL_SUPPORTS_QUOTA_READ, 1, [quota_read found])
1748 ],[
1749         AC_MSG_RESULT([no])
1750 ])
1751 ])
1752
1753 #
1754 # LC_CONFIG_SPLIT
1755 #
1756 # whether to enable split support
1757 #
1758 AC_DEFUN([LC_CONFIG_SPLIT],
1759 [AC_MSG_CHECKING([whether to enable split support])
1760 AC_ARG_ENABLE([split],
1761         AC_HELP_STRING([--enable-split],
1762                         [enable split support]),
1763         [],[enable_split='no'])
1764 AC_MSG_RESULT([$enable_split])
1765 if test x$enable_split != xno; then
1766    AC_DEFINE(HAVE_SPLIT_SUPPORT, 1, [enable split support])
1767 fi
1768 ])
1769
1770 #
1771 # LC_COOKIE_FOLLOW_LINK
1772 #
1773 # kernel 2.6.13+ ->follow_link returns a cookie
1774 #
1775
1776 AC_DEFUN([LC_COOKIE_FOLLOW_LINK],
1777 [AC_MSG_CHECKING([if inode_operations->follow_link returns a cookie])
1778 LB_LINUX_TRY_COMPILE([
1779         #include <linux/fs.h>
1780         #include <linux/namei.h>
1781 ],[
1782         struct dentry dentry;
1783         struct nameidata nd;
1784
1785         dentry.d_inode->i_op->put_link(&dentry, &nd, NULL);
1786 ],[
1787         AC_DEFINE(HAVE_COOKIE_FOLLOW_LINK, 1, [inode_operations->follow_link returns a cookie])
1788         AC_MSG_RESULT([yes])
1789 ],[
1790         AC_MSG_RESULT([no])
1791 ])
1792 ])
1793
1794 #
1795 # LC_FUNC_RCU
1796 #
1797 # kernels prior than 2.6.0(?) have no RCU supported; in kernel 2.6.5(SUSE),
1798 # call_rcu takes three parameters.
1799 #
1800 AC_DEFUN([LC_FUNC_RCU],
1801 [AC_MSG_CHECKING([if kernel have RCU supported])
1802 LB_LINUX_TRY_COMPILE([
1803         #include <linux/rcupdate.h>
1804 ],[],[
1805         AC_DEFINE(HAVE_RCU, 1, [have RCU defined])
1806         AC_MSG_RESULT([yes])
1807
1808         AC_MSG_CHECKING([if call_rcu takes three parameters])
1809         LB_LINUX_TRY_COMPILE([
1810                 #include <linux/rcupdate.h>
1811         ],[
1812                 struct rcu_head rh;
1813                 call_rcu(&rh, (void (*)(struct rcu_head *))1, NULL);
1814         ],[
1815                 AC_DEFINE(HAVE_CALL_RCU_PARAM, 1, [call_rcu takes three parameters])
1816                 AC_MSG_RESULT([yes])
1817         ],[
1818                 AC_MSG_RESULT([no])
1819         ])
1820 ],[
1821         AC_MSG_RESULT([no])
1822 ])
1823 ])
1824
1825 # LC_SECURITY_PLUG  # for SLES10 SP2
1826 # check security plug in sles10 sp2 kernel
1827 AC_DEFUN([LC_SECURITY_PLUG],
1828 [AC_MSG_CHECKING([If kernel has security plug support])
1829 LB_LINUX_TRY_COMPILE([
1830         #include <linux/fs.h>
1831 ],[
1832         struct dentry   *dentry;
1833         struct vfsmount *mnt;
1834         struct iattr    *iattr;
1835
1836         notify_change(dentry, mnt, iattr);
1837 ],[
1838         AC_MSG_RESULT(yes)
1839         AC_DEFINE(HAVE_SECURITY_PLUG, 1,
1840                 [SLES10 SP2 use extra parameter in vfs])
1841 ],[
1842         AC_MSG_RESULT(no)
1843 ])
1844 ])
1845
1846 AC_DEFUN([LC_PERCPU_COUNTER],
1847 [AC_MSG_CHECKING([if have struct percpu_counter defined])
1848 LB_LINUX_TRY_COMPILE([
1849         #include <linux/percpu_counter.h>
1850 ],[],[
1851         AC_DEFINE(HAVE_PERCPU_COUNTER, 1, [percpu_counter found])
1852         AC_MSG_RESULT([yes])
1853
1854         AC_MSG_CHECKING([if percpu_counter_inc takes the 2nd argument])
1855         LB_LINUX_TRY_COMPILE([
1856                 #include <linux/percpu_counter.h>
1857         ],[
1858                 struct percpu_counter c;
1859                 percpu_counter_init(&c, 0);
1860         ],[
1861                 AC_DEFINE(HAVE_PERCPU_2ND_ARG, 1, [percpu_counter_init has two
1862                                                    arguments])
1863                 AC_MSG_RESULT([yes])
1864         ],[
1865                 AC_MSG_RESULT([no])
1866         ])
1867 ],[
1868         AC_MSG_RESULT([no])
1869 ])
1870 ])
1871
1872 #
1873 # LC_QUOTA64
1874 # linux kernel have 64-bit limits support
1875 #
1876 AC_DEFUN([LC_QUOTA64],
1877 [if test x$enable_quota_module = xyes; then
1878         AC_MSG_CHECKING([if kernel has 64-bit quota limits support])
1879         LB_LINUX_TRY_COMPILE([
1880                 #include <linux/kernel.h>
1881                 #include <linux/fs.h>
1882                 #include <linux/quotaio_v2.h>
1883                 int versions[] = V2_INITQVERSIONS_R1;
1884                 struct v2_disk_dqblk_r1 dqblk_r1;
1885         ],[],[
1886                 AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
1887                 AC_MSG_RESULT([yes])
1888         ],[
1889                 LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
1890                         if test x$enable_server = xyes ; then
1891                                 AC_MSG_ERROR([You have got no 64-bit kernel quota support.])
1892                         fi
1893                 ],[])
1894                 AC_MSG_RESULT([no])
1895         ])
1896 fi
1897 ])
1898
1899 #
1900 # LC_CONFIGURE
1901 #
1902 # other configure checks
1903 #
1904 AC_DEFUN([LC_CONFIGURE],
1905 [LC_CONFIG_OBD_BUFFER_SIZE
1906
1907 if test $target_cpu == "i686" -o $target_cpu == "x86_64"; then
1908         CFLAGS="$CFLAGS -Werror"
1909 fi
1910
1911 # include/liblustre.h
1912 AC_CHECK_HEADERS([sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
1913
1914 # liblustre/llite_lib.h
1915 AC_CHECK_HEADERS([xtio.h file.h])
1916
1917 # liblustre/dir.c
1918 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
1919
1920 # liblustre/lutil.c
1921 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h catamount/data.h])
1922 AC_CHECK_FUNCS([inet_ntoa])
1923
1924 # libsysio/src/readlink.c
1925 LC_READLINK_SSIZE_T
1926
1927 # lvfs/prng.c - depends on linux/types.h from liblustre/dir.c
1928 AC_CHECK_HEADERS([linux/random.h], [], [],
1929                  [#ifdef HAVE_LINUX_TYPES_H
1930                   # include <linux/types.h>
1931                   #endif
1932                  ])
1933
1934 # utils/llverfs.c
1935 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
1936
1937 # check for -lz support
1938 ZLIB=""
1939 AC_CHECK_LIB([z],
1940              [adler32],
1941              [AC_CHECK_HEADERS([zlib.h],
1942                                [ZLIB="-lz"
1943                                 AC_DEFINE([HAVE_ADLER], 1,
1944                                           [support alder32 checksum type])],
1945                                [AC_MSG_WARN([No zlib-devel package found,
1946                                              unable to use adler32 checksum])])],
1947              [AC_MSG_WARN([No zlib package found, unable to use adler32 checksum])]
1948 )
1949 AC_SUBST(ZLIB)
1950
1951 # Super safe df
1952 AC_ARG_ENABLE([mindf],
1953       AC_HELP_STRING([--enable-mindf],
1954                       [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
1955       [],[])
1956 if test "$enable_mindf" = "yes" ;  then
1957       AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])
1958 fi
1959
1960 AC_ARG_ENABLE([fail_alloc],
1961         AC_HELP_STRING([--disable-fail-alloc],
1962                 [disable randomly alloc failure]),
1963         [],[enable_fail_alloc=yes])
1964 AC_MSG_CHECKING([whether to randomly failing memory alloc])
1965 AC_MSG_RESULT([$enable_fail_alloc])
1966 if test x$enable_fail_alloc != xno ; then
1967         AC_DEFINE([RANDOM_FAIL_ALLOC], 1, [enable randomly alloc failure])
1968 fi
1969
1970 AC_ARG_ENABLE([invariants],
1971         AC_HELP_STRING([--enable-invariants],
1972                 [enable invariant checking (cpu intensive)]),
1973         [],[])
1974 AC_MSG_CHECKING([whether to check invariants (expensive cpu-wise)])
1975 AC_MSG_RESULT([$enable_invariants])
1976 if test x$enable_invariants = xyes ; then
1977         AC_DEFINE([INVARIANT_CHECK], 1, [enable invariant checking])
1978 fi
1979
1980 AC_ARG_ENABLE([lu_ref],
1981         AC_HELP_STRING([--enable-lu_ref],
1982                 [enable lu_ref reference tracking code]),
1983         [],[])
1984 AC_MSG_CHECKING([whether to track references with lu_ref])
1985 AC_MSG_RESULT([$enable_lu_ref])
1986 if test x$enable_lu_ref = xyes ; then
1987         AC_DEFINE([USE_LU_REF], 1, [enable lu_ref reference tracking code])
1988 fi
1989
1990 ])
1991
1992 #
1993 # LC_CONDITIONALS
1994 #
1995 # AM_CONDITIONALS for lustre
1996 #
1997 AC_DEFUN([LC_CONDITIONALS],
1998 [AM_CONDITIONAL(LIBLUSTRE, test x$enable_liblustre = xyes)
1999 AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
2000 AM_CONDITIONAL(LIBLUSTRE_TESTS, test x$enable_liblustre_tests = xyes)
2001 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
2002 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
2003 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
2004 AM_CONDITIONAL(QUOTA, test x$enable_quota_module = xyes)
2005 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
2006 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
2007 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
2008 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
2009 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
2010 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
2011 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
2012 ])
2013
2014 #
2015 # LC_CONFIG_FILES
2016 #
2017 # files that should be generated with AC_OUTPUT
2018 #
2019 AC_DEFUN([LC_CONFIG_FILES],
2020 [AC_CONFIG_FILES([
2021 lustre/Makefile
2022 lustre/autoMakefile
2023 lustre/autoconf/Makefile
2024 lustre/contrib/Makefile
2025 lustre/doc/Makefile
2026 lustre/include/Makefile
2027 lustre/include/lustre_ver.h
2028 lustre/include/linux/Makefile
2029 lustre/include/lustre/Makefile
2030 lustre/kernel_patches/targets/2.6-vanilla.target
2031 lustre/kernel_patches/targets/2.6-rhel4.target
2032 lustre/kernel_patches/targets/2.6-rhel5.target
2033 lustre/kernel_patches/targets/2.6-fc5.target
2034 lustre/kernel_patches/targets/2.6-patchless.target
2035 lustre/kernel_patches/targets/2.6-sles10.target
2036 lustre/ldlm/Makefile
2037 lustre/fid/Makefile
2038 lustre/fid/autoMakefile
2039 lustre/liblustre/Makefile
2040 lustre/liblustre/tests/Makefile
2041 lustre/llite/Makefile
2042 lustre/llite/autoMakefile
2043 lustre/lclient/Makefile
2044 lustre/lov/Makefile
2045 lustre/lov/autoMakefile
2046 lustre/lvfs/Makefile
2047 lustre/lvfs/autoMakefile
2048 lustre/mdc/Makefile
2049 lustre/mdc/autoMakefile
2050 lustre/lmv/Makefile
2051 lustre/lmv/autoMakefile
2052 lustre/mds/Makefile
2053 lustre/mds/autoMakefile
2054 lustre/mdt/Makefile
2055 lustre/mdt/autoMakefile
2056 lustre/cmm/Makefile
2057 lustre/cmm/autoMakefile
2058 lustre/mdd/Makefile
2059 lustre/mdd/autoMakefile
2060 lustre/fld/Makefile
2061 lustre/fld/autoMakefile
2062 lustre/obdclass/Makefile
2063 lustre/obdclass/autoMakefile
2064 lustre/obdclass/linux/Makefile
2065 lustre/obdecho/Makefile
2066 lustre/obdecho/autoMakefile
2067 lustre/obdfilter/Makefile
2068 lustre/obdfilter/autoMakefile
2069 lustre/osc/Makefile
2070 lustre/osc/autoMakefile
2071 lustre/ost/Makefile
2072 lustre/ost/autoMakefile
2073 lustre/osd/Makefile
2074 lustre/osd/autoMakefile
2075 lustre/mgc/Makefile
2076 lustre/mgc/autoMakefile
2077 lustre/mgs/Makefile
2078 lustre/mgs/autoMakefile
2079 lustre/ptlrpc/Makefile
2080 lustre/ptlrpc/autoMakefile
2081 lustre/ptlrpc/gss/Makefile
2082 lustre/ptlrpc/gss/autoMakefile
2083 lustre/quota/Makefile
2084 lustre/quota/autoMakefile
2085 lustre/scripts/Makefile
2086 lustre/scripts/version_tag.pl
2087 lustre/tests/Makefile
2088 lustre/utils/Makefile
2089 lustre/utils/gss/Makefile
2090 ])
2091 case $lb_target_os in
2092         darwin)
2093                 AC_CONFIG_FILES([ lustre/obdclass/darwin/Makefile ])
2094                 ;;
2095 esac
2096
2097 ])