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