Whamcloud - gitweb
LU-2800 autoconf: remove vectored fops tests
[fs/lustre-release.git] / lustre / autoconf / lustre-core.m4
1 #
2 # LC_CONFIG_SRCDIR
3 #
4 # Wrapper for AC_CONFIG_SUBDIR
5 #
6 AC_DEFUN([LC_CONFIG_SRCDIR],
7 [AC_CONFIG_SRCDIR([lustre/obdclass/obdo.c])
8 libcfs_is_module=yes
9 ldiskfs_is_ext4=yes
10 ])
11
12 #
13 # LC_PATH_DEFAULTS
14 #
15 # lustre specific paths
16 #
17 AC_DEFUN([LC_PATH_DEFAULTS],
18 [# ptlrpc kernel build requires this
19 LUSTRE="$PWD/lustre"
20 AC_SUBST(LUSTRE)
21
22 # mount.lustre
23 rootsbindir='$(CROSS_PATH)/sbin'
24 AC_SUBST(rootsbindir)
25
26 demodir='$(docdir)/demo'
27 AC_SUBST(demodir)
28
29 pkgexampledir='${pkgdatadir}/examples'
30 AC_SUBST(pkgexampledir)
31 ])
32
33 #
34 # LC_TARGET_SUPPORTED
35 #
36 # is the target os supported?
37 #
38 AC_DEFUN([LC_TARGET_SUPPORTED],
39 [case $target_os in
40         linux* | darwin*)
41 $1
42                 ;;
43         *)
44 $2
45                 ;;
46 esac
47 ])
48
49 #
50 # LC_CONFIG_OBD_BUFFER_SIZE
51 #
52 # the maximum buffer size of lctl ioctls
53 #
54 AC_DEFUN([LC_CONFIG_OBD_BUFFER_SIZE],
55 [AC_MSG_CHECKING([maximum OBD ioctl size])
56 AC_ARG_WITH([obd-buffer-size],
57         AC_HELP_STRING([--with-obd-buffer-size=[size]],
58                         [set lctl ioctl maximum bytes (default=8192)]),
59         [
60                 OBD_BUFFER_SIZE=$with_obd_buffer_size
61         ],[
62                 OBD_BUFFER_SIZE=8192
63         ])
64 AC_MSG_RESULT([$OBD_BUFFER_SIZE bytes])
65 AC_DEFINE_UNQUOTED(CONFIG_LUSTRE_OBD_MAX_IOCTL_BUFFER, $OBD_BUFFER_SIZE, [IOCTL Buffer Size])
66 ])
67
68 #
69 # LC_READLINK_SSIZE_T
70 #
71 AC_DEFUN([LC_READLINK_SSIZE_T],
72 [AC_MSG_CHECKING([if readlink returns ssize_t])
73 AC_TRY_COMPILE([
74         #include <unistd.h>
75 ],[
76         ssize_t readlink(const char *, char *, size_t);
77 ],[
78         AC_MSG_RESULT([yes])
79         AC_DEFINE(HAVE_POSIX_1003_READLINK, 1, [readlink returns ssize_t])
80 ],[
81         AC_MSG_RESULT([no])
82 ])
83 ])
84
85 #
86 # LC_FUNC_DEV_SET_RDONLY
87 #
88 # check whether dev_set_rdonly is exported.  This is needed until we
89 # have another mechanism to fence IO from the underlying device.
90 #
91 AC_DEFUN([LC_FUNC_DEV_SET_RDONLY],
92 [LB_CHECK_SYMBOL_EXPORT([dev_set_rdonly],
93 [block/ll_rw_block.c,block/blk-core.c],[
94         AC_DEFINE(HAVE_DEV_SET_RDONLY, 1, [kernel exports dev_set_rdonly])
95 ],[
96         AC_MSG_WARN([kernel missing dev_set_rdonly patch for testing])
97 ])
98 ])
99
100 #
101 # Ensure stack size big than 8k in Lustre server (all kernels)
102 #
103 AC_DEFUN([LC_STACK_SIZE],
104 [AC_MSG_CHECKING([stack size big than 8k])
105 LB_LINUX_TRY_COMPILE([
106         #include <linux/thread_info.h>
107 ],[
108         #if THREAD_SIZE < 8192
109         #error "stack size < 8192"
110         #endif
111 ],[
112         AC_MSG_RESULT(yes)
113 ],[
114         AC_MSG_ERROR([Lustre requires that Linux is configured with at least a 8KB stack.])
115 ])
116 ])
117
118 #
119 # Allow the user to set the MDS thread upper limit
120 #
121 AC_DEFUN([LC_MDS_MAX_THREADS],
122 [
123         AC_ARG_WITH([mds_max_threads],
124         AC_HELP_STRING([--with-mds-max-threads=count],
125                        [maximum threads available on the MDS: (default=512)]),
126         [
127                 MDS_THREAD_COUNT=$with_mds_max_threads
128                 AC_DEFINE_UNQUOTED(MDS_MAX_THREADS, $MDS_THREAD_COUNT, [maximum number of MDS threads])
129         ])
130 ])
131
132 #
133 # LC_CONFIG_PINGER
134 #
135 # the pinger is temporary, until we have the recovery node in place
136 #
137 AC_DEFUN([LC_CONFIG_PINGER],
138 [AC_MSG_CHECKING([whether to enable pinger support])
139 AC_ARG_ENABLE([pinger],
140         AC_HELP_STRING([--disable-pinger],
141                         [disable recovery pinger support]),
142         [],[enable_pinger='yes'])
143 AC_MSG_RESULT([$enable_pinger])
144 if test x$enable_pinger != xno ; then
145   AC_DEFINE(ENABLE_PINGER, 1, Use the Pinger)
146 fi
147 ])
148
149 #
150 # LC_CONFIG_CHECKSUM
151 #
152 # do checksum of bulk data between client and OST
153 #
154 AC_DEFUN([LC_CONFIG_CHECKSUM],
155 [AC_MSG_CHECKING([whether to enable data checksum support])
156 AC_ARG_ENABLE([checksum],
157        AC_HELP_STRING([--disable-checksum],
158                        [disable data checksum support]),
159        [],[enable_checksum='yes'])
160 AC_MSG_RESULT([$enable_checksum])
161 if test x$enable_checksum != xno ; then
162   AC_DEFINE(ENABLE_CHECKSUM, 1, do data checksums)
163 fi
164 ])
165
166 #
167 # LC_CONFIG_LIBLUSTRE_RECOVERY
168 #
169 AC_DEFUN([LC_CONFIG_LIBLUSTRE_RECOVERY],
170 [AC_MSG_CHECKING([whether to enable liblustre recovery support])
171 AC_ARG_ENABLE([liblustre-recovery],
172         AC_HELP_STRING([--disable-liblustre-recovery],
173                         [disable liblustre recovery support]),
174         [],[enable_liblustre_recovery='yes'])
175 AC_MSG_RESULT([$enable_liblustre_recovery])
176 if test x$enable_liblustre_recovery != xno ; then
177   AC_DEFINE(ENABLE_LIBLUSTRE_RECOVERY, 1, Liblustre Can Recover)
178 fi
179 ])
180
181 #
182 # LC_CONFIG_HEALTH_CHECK_WRITE
183 #
184 # Turn off the actual write to the disk
185 #
186 AC_DEFUN([LC_CONFIG_HEALTH_CHECK_WRITE],
187 [AC_MSG_CHECKING([whether to enable a write with the health check])
188 AC_ARG_ENABLE([health_write],
189         AC_HELP_STRING([--enable-health_write],
190                         [enable disk writes when doing health check]),
191         [],[enable_health_write='no'])
192 AC_MSG_RESULT([$enable_health_write])
193 if test x$enable_health_write != xno ; then
194   AC_DEFINE(USE_HEALTH_CHECK_WRITE, 1, Write when Checking Health)
195 fi
196 ])
197
198 AC_DEFUN([LC_CONFIG_LRU_RESIZE],
199 [AC_MSG_CHECKING([whether to enable lru self-adjusting])
200 AC_ARG_ENABLE([lru_resize],
201         AC_HELP_STRING([--enable-lru-resize],
202                         [enable lru resize support]),
203         [],[enable_lru_resize='yes'])
204 AC_MSG_RESULT([$enable_lru_resize])
205 if test x$enable_lru_resize != xno; then
206    AC_DEFINE(HAVE_LRU_RESIZE_SUPPORT, 1, [Enable lru resize support])
207 fi
208 ])
209
210 #
211 # Quota support. The kernel must support CONFIG_QUOTA.
212 #
213 AC_DEFUN([LC_QUOTA_CONFIG],
214 [LB_LINUX_CONFIG_IM([QUOTA],[],[
215         AC_MSG_ERROR([Lustre quota requires that CONFIG_QUOTA is enabled in your kernel.])
216         ])
217 ])
218
219 # truncate_complete_page() was exported from RHEL5/SLES10, but not in SLES11 SP0 (2.6.27)
220 # remove_from_page_cache() was exported between 2.6.35 and 2.6.38
221 # delete_from_page_cache() is exported from 2.6.39
222 AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE],
223          [LB_CHECK_SYMBOL_EXPORT([truncate_complete_page],
224                                  [mm/truncate.c],
225                                  [AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
226                                             [kernel export truncate_complete_page])])
227           LB_CHECK_SYMBOL_EXPORT([remove_from_page_cache],
228                                  [mm/filemap.c],
229                                  [AC_DEFINE(HAVE_REMOVE_FROM_PAGE_CACHE, 1,
230                                             [kernel export remove_from_page_cache])])
231           LB_CHECK_SYMBOL_EXPORT([delete_from_page_cache],
232                                  [mm/filemap.c],
233                                  [AC_DEFINE(HAVE_DELETE_FROM_PAGE_CACHE, 1,
234                                             [kernel export delete_from_page_cache])])
235          ])
236
237 #
238 # added in 2.6.17
239 #
240 AC_DEFUN([LC_BIT_SPINLOCK_H],
241 [LB_CHECK_FILE([$LINUX/include/linux/bit_spinlock.h],[
242         AC_MSG_CHECKING([if bit_spinlock.h can be compiled])
243         LB_LINUX_TRY_COMPILE([
244                 #include <asm/processor.h>
245                 #include <linux/spinlock.h>
246                 #include <linux/bit_spinlock.h>
247         ],[],[
248                 AC_MSG_RESULT([yes])
249                 AC_DEFINE(HAVE_BIT_SPINLOCK_H, 1, [Kernel has bit_spinlock.h])
250         ],[
251                 AC_MSG_RESULT([no])
252         ])
253 ],
254 [])
255 ])
256
257 #
258 # LC_CAPA_CRYPTO
259 #
260 AC_DEFUN([LC_CAPA_CRYPTO],
261 [LB_LINUX_CONFIG_IM([CRYPTO],[],[
262         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO is enabled in your kernel.])
263 ])
264 LB_LINUX_CONFIG_IM([CRYPTO_HMAC],[],[
265         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO_HMAC is enabled in your kernel.])
266 ])
267 LB_LINUX_CONFIG_IM([CRYPTO_SHA1],[],[
268         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO_SHA1 is enabled in your kernel.])
269 ])
270 ])
271
272 #
273 # LC_CONFIG_RMTCLIENT
274 #
275 dnl FIXME
276 dnl the AES symbol usually tied with arch, e.g. CRYPTO_AES_586
277 dnl FIXME
278 AC_DEFUN([LC_CONFIG_RMTCLIENT],
279 [LB_LINUX_CONFIG_IM([CRYPTO_AES],[],[
280         AC_MSG_WARN([Lustre remote client require that CONFIG_CRYPTO_AES is enabled in your kernel.])
281 ])
282 ])
283
284 #
285 # LC_CONFIG_GSS_KEYRING (default enabled, if gss is enabled)
286 #
287 AC_DEFUN([LC_CONFIG_GSS_KEYRING],
288 [AC_MSG_CHECKING([whether to enable gss keyring backend])
289  AC_ARG_ENABLE([gss_keyring],
290                [AC_HELP_STRING([--disable-gss-keyring],
291                                [disable gss keyring backend])],
292                [],[enable_gss_keyring='yes'])
293  AC_MSG_RESULT([$enable_gss_keyring])
294
295  if test x$enable_gss_keyring != xno; then
296         LB_LINUX_CONFIG_IM([KEYS],[],
297                            [AC_MSG_ERROR([GSS keyring backend require that CONFIG_KEYS be enabled in your kernel.])])
298
299         AC_CHECK_LIB([keyutils], [keyctl_search], [],
300                      [AC_MSG_ERROR([libkeyutils is not found, which is required by gss keyring backend])],)
301
302         AC_DEFINE([HAVE_GSS_KEYRING], [1],
303                   [Define this if you enable gss keyring backend])
304  fi
305 ])
306
307 AC_DEFUN([LC_CONFIG_SUNRPC],
308 [LB_LINUX_CONFIG_IM([SUNRPC],[],
309                     [AC_MSG_ERROR([kernel SUNRPC support is required by using GSS.])])
310 ])
311
312 #
313 # LC_CONFIG_GSS (default disabled)
314 #
315 # Build gss and related tools of Lustre. Currently both kernel and user space
316 # parts are depend on linux platform.
317 #
318 AC_DEFUN([LC_CONFIG_GSS],
319 [AC_MSG_CHECKING([whether to enable gss/krb5 support])
320  AC_ARG_ENABLE([gss],
321                [AC_HELP_STRING([--enable-gss], [enable gss/krb5 support])],
322                [],[enable_gss='no'])
323  AC_MSG_RESULT([$enable_gss])
324
325  if test x$enable_gss == xyes; then
326         LC_CONFIG_GSS_KEYRING
327         LC_CONFIG_SUNRPC
328
329         AC_DEFINE([HAVE_GSS], [1], [Define this if you enable gss])
330
331         LB_LINUX_CONFIG_IM([CRYPTO_MD5],[],
332                            [AC_MSG_WARN([kernel MD5 support is recommended by using GSS.])])
333         LB_LINUX_CONFIG_IM([CRYPTO_SHA1],[],
334                            [AC_MSG_WARN([kernel SHA1 support is recommended by using GSS.])])
335         LB_LINUX_CONFIG_IM([CRYPTO_SHA256],[],
336                            [AC_MSG_WARN([kernel SHA256 support is recommended by using GSS.])])
337         LB_LINUX_CONFIG_IM([CRYPTO_SHA512],[],
338                            [AC_MSG_WARN([kernel SHA512 support is recommended by using GSS.])])
339
340         AC_CHECK_LIB([gssapi], [gss_export_lucid_sec_context],
341                      [GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssapi"],
342                      [AC_CHECK_LIB([gssglue], [gss_export_lucid_sec_context],
343                                    [GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssglue"],
344                                    [AC_MSG_ERROR([libgssapi or libgssglue is not found, which is required by GSS.])])],)
345
346         AC_SUBST(GSSAPI_LIBS)
347
348         AC_KERBEROS_V5
349  fi
350 ])
351
352 # 2.6.12
353
354 # ~2.6.12 merge patch from oracle to convert tree_lock from spinlock to rwlock
355 # yet tree_lock is converted from rwlock to spin_lock since v2.6.26
356 AC_DEFUN([LC_RW_TREE_LOCK],
357 [AC_MSG_CHECKING([if kernel has tree_lock as rwlock])
358 tmp_flags="$EXTRA_KCFLAGS"
359 EXTRA_KCFLAGS="-Werror"
360 LB_LINUX_TRY_COMPILE([
361         #include <linux/fs.h>
362 ],[
363         struct address_space a;
364
365         write_lock(&a.tree_lock);
366 ],[
367         AC_MSG_RESULT([yes])
368         AC_DEFINE(HAVE_RW_TREE_LOCK, 1, [kernel has tree_lock as rw_lock])
369 ],[
370         AC_MSG_RESULT([no])
371 ])
372 EXTRA_KCFLAGS="$tmp_flags"
373 ])
374
375 #2.6.18 + RHEL5 (fc6)
376
377 #
378 # LC_LINUX_FIEMAP_H
379 #
380 # fiemap.h is added since v2.6.28
381 # RHEL5 2.6.18 has it, while SLES10 2.6.27 does not
382 #
383 AC_DEFUN([LC_LINUX_FIEMAP_H],
384 [LB_CHECK_FILE([$LINUX/include/linux/fiemap.h],[
385         AC_MSG_CHECKING([if fiemap.h can be compiled])
386         LB_LINUX_TRY_COMPILE([
387                 #include <linux/types.h>
388                 #include <linux/fiemap.h>
389         ],[],[
390                 AC_MSG_RESULT([yes])
391                 AC_DEFINE(HAVE_LINUX_FIEMAP_H, 1, [Kernel has fiemap.h])
392         ],[
393                 AC_MSG_RESULT([no])
394         ])
395 ],
396 [])
397 ])
398
399 # raid5-zerocopy patch
400
401 #
402 # LC_PAGE_CONSTANT
403 #
404 # In order to support raid5 zerocopy patch, we have to patch the kernel to make
405 # it support constant page, which means the page won't be modified during the
406 # IO.
407 #
408 AC_DEFUN([LC_PAGE_CONSTANT],
409 [AC_MSG_CHECKING([if kernel have PageConstant defined])
410 LB_LINUX_TRY_COMPILE([
411         #include <linux/mm.h>
412         #include <linux/page-flags.h>
413 ],[
414         #ifndef PG_constant
415         #error "Have no raid5 zcopy patch"
416         #endif
417 ],[
418         AC_MSG_RESULT(yes)
419         AC_DEFINE(HAVE_PAGE_CONSTANT, 1, [kernel have PageConstant supported])
420 ],[
421         AC_MSG_RESULT(no);
422 ])
423 ])
424
425 # 2.6.22
426
427 # 2.6.22 lost second parameter for invalidate_bdev
428 AC_DEFUN([LC_INVALIDATE_BDEV_2ARG],
429 [AC_MSG_CHECKING([if invalidate_bdev has second argument])
430 LB_LINUX_TRY_COMPILE([
431         #include <linux/buffer_head.h>
432 ],[
433         invalidate_bdev(NULL,0);
434 ],[
435         AC_MSG_RESULT([yes])
436         AC_DEFINE(HAVE_INVALIDATE_BDEV_2ARG, 1,
437                 [invalidate_bdev has second argument])
438 ],[
439         AC_MSG_RESULT([no])
440 ])
441 ])
442
443 #
444 # 2.6.19 check for FS_RENAME_DOES_D_MOVE flag
445 #
446 AC_DEFUN([LC_FS_RENAME_DOES_D_MOVE],
447 [AC_MSG_CHECKING([if kernel has FS_RENAME_DOES_D_MOVE flag])
448 LB_LINUX_TRY_COMPILE([
449         #include <linux/fs.h>
450 ],[
451         int v __attribute__ ((unused));
452         v = FS_RENAME_DOES_D_MOVE;
453 ],[
454         AC_MSG_RESULT([yes])
455         AC_DEFINE(HAVE_FS_RENAME_DOES_D_MOVE, 1, [kernel has FS_RENAME_DOES_D_MOVE flag])
456 ],[
457         AC_MSG_RESULT([no])
458 ])
459 ])
460
461 # 2.6.23
462
463 # 2.6.23 have return type 'void' for unregister_blkdev
464 AC_DEFUN([LC_UNREGISTER_BLKDEV_RETURN_INT],
465 [AC_MSG_CHECKING([if unregister_blkdev return int])
466 LB_LINUX_TRY_COMPILE([
467         #include <linux/fs.h>
468 ],[
469         int i __attribute__ ((unused));
470         i = unregister_blkdev(0,NULL);
471 ],[
472         AC_MSG_RESULT([yes])
473         AC_DEFINE(HAVE_UNREGISTER_BLKDEV_RETURN_INT, 1,
474                 [unregister_blkdev return int])
475 ],[
476         AC_MSG_RESULT([no])
477 ])
478 ])
479
480 # 2.6.23 add code to wait other users to complete before removing procfs entry
481 AC_DEFUN([LC_PROCFS_USERS],
482 [AC_MSG_CHECKING([if kernel has pde_users member in procfs entry struct])
483 LB_LINUX_TRY_COMPILE([
484         #include <linux/proc_fs.h>
485 ],[
486         struct proc_dir_entry pde;
487
488         pde.pde_users   = 0;
489 ],[
490         AC_MSG_RESULT([yes])
491         AC_DEFINE(HAVE_PROCFS_USERS, 1,
492                 [kernel has pde_users member in procfs entry struct])
493 ],[
494         LB_LINUX_TRY_COMPILE([
495                 #include "$LINUX/fs/proc/internal.h"
496         ],[
497                 struct proc_dir_entry_aux pde_aux;
498
499                 pde_aux.pde_users = 0;
500         ],[
501                 AC_MSG_RESULT([yes])
502                 AC_DEFINE(HAVE_PROCFS_USERS, 1,
503                         [kernel has pde_users member in proc_dir_entry_aux])
504         ],[
505                 AC_MSG_RESULT([no])
506         ])
507 ])
508 ])
509
510 # 2.6.24
511
512 # 2.6.24 has bio_endio with 2 args
513 AC_DEFUN([LC_BIO_ENDIO_2ARG],
514 [AC_MSG_CHECKING([if kernel has bio_endio with 2 args])
515 LB_LINUX_TRY_COMPILE([
516         #include <linux/bio.h>
517 ],[
518         bio_endio(NULL, 0);
519 ], [
520         AC_MSG_RESULT([yes])
521         AC_DEFINE(HAVE_BIO_ENDIO_2ARG, 1,
522                 [kernel has bio_endio with 2 args])
523 ],[
524         AC_MSG_RESULT([no])
525 ])
526 ])
527
528 # 2.6.24 removes long aged procfs entry -> deleted member
529 AC_DEFUN([LC_PROCFS_DELETED],
530 [AC_MSG_CHECKING([if kernel has deleted member in procfs entry struct])
531 LB_LINUX_TRY_COMPILE([
532         #include <linux/proc_fs.h>
533 ],[
534         struct proc_dir_entry pde;
535
536         pde.deleted = sizeof(pde);
537 ], [
538         AC_MSG_RESULT([yes])
539         AC_DEFINE(HAVE_PROCFS_DELETED, 1,
540                 [kernel has deleted member in procfs entry struct])
541 ],[
542         AC_MSG_RESULT([no])
543 ])
544 ])
545
546 # 2.6.26
547
548 # 2.6.26 isn't export set_fs_pwd and change paramter in fs struct
549 AC_DEFUN([LC_FS_STRUCT_USE_PATH],
550 [AC_MSG_CHECKING([fs_struct use path structure])
551 LB_LINUX_TRY_COMPILE([
552         #include <asm/atomic.h>
553         #include <linux/spinlock.h>
554         #include <linux/fs_struct.h>
555 ],[
556         struct fs_struct fs;
557
558         fs.pwd = *((struct path *)sizeof(fs));
559 ], [
560         AC_MSG_RESULT([yes])
561         AC_DEFINE(HAVE_FS_STRUCT_USE_PATH, 1,
562                 [fs_struct use path structure])
563 ],[
564         AC_MSG_RESULT([no])
565 ])
566 ])
567
568 #
569 # 2.6.27
570 #
571
572 # LC_SECURITY_PLUG  # for SLES10 SP2 (2.6.27)
573 # check security plug in sles10 sp2 kernel
574 AC_DEFUN([LC_SECURITY_PLUG],
575 [AC_MSG_CHECKING([If kernel has security plug support])
576 LB_LINUX_TRY_COMPILE([
577         #include <linux/fs.h>
578         #include <linux/stddef.h>
579 ],[
580         notify_change(NULL, NULL, NULL);
581 ],[
582         AC_MSG_RESULT(yes)
583         AC_DEFINE(HAVE_SECURITY_PLUG, 1,
584                 [SLES10 SP2 use extra parameter in vfs])
585 ],[
586         AC_MSG_RESULT(no)
587 ])
588 ])
589
590 AC_DEFUN([LC_INODE_PERMISION_2ARGS],
591 [AC_MSG_CHECKING([inode_operations->permission has two args])
592 LB_LINUX_TRY_COMPILE([
593         #include <linux/fs.h>
594 ],[
595         struct inode *inode __attribute__ ((unused));
596
597         inode = NULL;
598         inode->i_op->permission(NULL, 0);
599 ],[
600         AC_DEFINE(HAVE_INODE_PERMISION_2ARGS, 1,
601                   [inode_operations->permission has two args])
602         AC_MSG_RESULT([yes])
603 ],[
604         AC_MSG_RESULT([no])
605 ])
606 ])
607
608 # 2.6.27 use 5th parameter in quota_on for remount.
609 AC_DEFUN([LC_QUOTA_ON_5ARGS],
610 [AC_MSG_CHECKING([quota_on needs 5 parameters])
611 LB_LINUX_TRY_COMPILE([
612         #include <linux/fs.h>
613         #include <linux/quota.h>
614 ],[
615         struct quotactl_ops *qop = NULL;
616         qop->quota_on(NULL, 0, 0, NULL, 0);
617 ],[
618         AC_DEFINE(HAVE_QUOTA_ON_5ARGS, 1,
619                 [quota_on needs 5 paramters])
620         AC_MSG_RESULT([yes])
621 ],[
622         AC_MSG_RESULT([no])
623 ])
624 ])
625
626 # 2.6.27 use 3th parameter in quota_off for remount.
627 AC_DEFUN([LC_QUOTA_OFF_3ARGS],
628 [AC_MSG_CHECKING([quota_off needs 3 parameters])
629 LB_LINUX_TRY_COMPILE([
630         #include <linux/fs.h>
631         #include <linux/quota.h>
632 ],[
633         struct quotactl_ops *qop = NULL;
634         qop->quota_off(NULL, 0, 0);
635 ],[
636         AC_DEFINE(HAVE_QUOTA_OFF_3ARGS, 1,
637                 [quota_off needs 3 paramters])
638         AC_MSG_RESULT([yes])
639 ],[
640         AC_MSG_RESULT([no])
641 ])
642 ])
643
644 # 2.6.34 has quotactl_ops->[sg]et_dqblk that take struct fs_disk_quota
645 AC_DEFUN([LC_HAVE_DQUOT_FS_DISK_QUOTA],
646 tmp_flags="$EXTRA_KCFLAGS"
647 EXTRA_KCFLAGS="-Werror"
648 [AC_MSG_CHECKING([if quotactl_ops.set_dqblk takes struct fs_disk_quota])
649 LB_LINUX_TRY_COMPILE([
650         #include <linux/fs.h>
651         #include <linux/quota.h>
652 ],[
653         struct quotactl_ops qops = {};
654         struct fs_disk_quota fdq;
655         qops.set_dqblk(NULL, 0, 0, &fdq);
656 ],[
657         AC_DEFINE(HAVE_DQUOT_FS_DISK_QUOTA, 1, [quotactl_ops.set_dqblk takes struct fs_disk_quota])
658         AC_MSG_RESULT([yes])
659 ],[
660         AC_MSG_RESULT([no])
661 ])
662 EXTRA_KCFLAGS="$tmp_flags"
663 ])
664
665 # 2.6.34 has renamed dquot options to dquot_*, check for dquot_suspend
666 AC_DEFUN([LC_HAVE_DQUOT_SUSPEND],
667 [AC_MSG_CHECKING([if dquot_suspend is defined])
668 LB_LINUX_TRY_COMPILE([
669         #include <linux/quotaops.h>
670 ],[
671         dquot_suspend(NULL, -1);
672 ],[
673         AC_DEFINE(HAVE_DQUOT_SUSPEND, 1, [dquot_suspend is defined])
674         AC_MSG_RESULT([yes])
675 ],[
676         AC_MSG_RESULT([no])
677 ])
678 ])
679
680 # LC_LOCK_MAP_ACQUIRE
681 # after 2.6.27 lock_map_acquire replaces lock_acquire
682 AC_DEFUN([LC_LOCK_MAP_ACQUIRE],
683 [AC_MSG_CHECKING([if lock_map_acquire is defined])
684 LB_LINUX_TRY_COMPILE([
685         #include <linux/lockdep.h>
686 ],[
687         lock_map_acquire(NULL);
688 ],[
689         AC_MSG_RESULT(yes)
690         AC_DEFINE(HAVE_LOCK_MAP_ACQUIRE, 1,
691                 [lock_map_acquire is defined])
692 ],[
693         AC_MSG_RESULT(no)
694 ])
695 ])
696
697 # 2.6.27.15-2 sles11
698
699 # 2.6.27 sles11 remove the bi_hw_segments
700 AC_DEFUN([LC_BI_HW_SEGMENTS],
701 [AC_MSG_CHECKING([struct bio has a bi_hw_segments field])
702 LB_LINUX_TRY_COMPILE([
703         #include <linux/bio.h>
704 ],[
705         struct bio io;
706         io.bi_hw_segments = sizeof(io);
707 ],[
708         AC_DEFINE(HAVE_BI_HW_SEGMENTS, 1,
709                 [struct bio has a bi_hw_segments field])
710         AC_MSG_RESULT([yes])
711 ],[
712         AC_MSG_RESULT([no])
713 ])
714 ])
715
716 #
717 # 2.6.27 sles11 move the quotaio_v1{2}.h from include/linux to fs
718 # 2.6.32 move the quotaio_v1{2}.h from fs to fs/quota
719 AC_DEFUN([LC_HAVE_QUOTAIO_H],
720 [LB_CHECK_FILE([$LINUX/include/linux/quotaio_v2.h],[
721         AC_DEFINE(HAVE_QUOTAIO_H, 1,
722                 [kernel has include/linux/quotaio_v2.h])
723 ],[LB_CHECK_FILE([$LINUX/fs/quotaio_v2.h],[
724                AC_DEFINE(HAVE_FS_QUOTAIO_H, 1,
725                 [kernel has fs/quotaio_v1.h])
726 ],[LB_CHECK_FILE([$LINUX/fs/quota/quotaio_v2.h],[
727                AC_DEFINE(HAVE_FS_QUOTA_QUOTAIO_H, 1,
728                 [kernel has fs/quota/quotaio_v2.h])
729 ],[
730         AC_MSG_RESULT([no])
731 ])
732 ])
733 ])
734 ])
735
736 # 2.6.32
737
738 # 2.6.32 replaces 2 functions blk_queue_max_phys_segments and blk_queue_max_hw_segments by blk_queue_max_segments
739 AC_DEFUN([LC_BLK_QUEUE_MAX_SEGMENTS],
740 [AC_MSG_CHECKING([if blk_queue_max_segments is defined])
741 LB_LINUX_TRY_COMPILE([
742         #include <linux/blkdev.h>
743 ],[
744         blk_queue_max_segments(NULL, 0);
745 ],[
746         AC_MSG_RESULT(yes)
747         AC_DEFINE(HAVE_BLK_QUEUE_MAX_SEGMENTS, 1,
748                   [blk_queue_max_segments is defined])
749 ],[
750         AC_MSG_RESULT(no)
751 ])
752 ])
753
754 #
755 # LC_QUOTA64
756 #
757 # Check if kernel has been patched for 64-bit quota limits support.
758 # The upstream version of this patch in RHEL6 2.6.32 kernels introduces
759 # the constant QFMT_VFS_V1 in include/linux/quota.h, so we can check for
760 # that in the absence of quotaio_v1.h in the kernel headers.
761 #
762 AC_DEFUN([LC_QUOTA64],[
763         AC_MSG_CHECKING([if kernel has 64-bit quota limits support])
764 tmp_flags="$EXTRA_KCFLAGS"
765 EXTRA_KCFLAGS="-I$LINUX/fs"
766         LB_LINUX_TRY_COMPILE([
767                 #include <linux/kernel.h>
768                 #include <linux/fs.h>
769                 #if defined(HAVE_FS_QUOTA_QUOTAIO_H)
770                 # include <quota/quotaio_v2.h>
771                 struct v2r1_disk_dqblk dqblk_r1;
772                 #else
773                 #include <linux/quota.h>
774                 int ver = QFMT_VFS_V1;
775                 #endif
776         ],[],[
777                 AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
778                 AC_MSG_RESULT([yes])
779         ],[
780                 LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
781                         AC_MSG_ERROR([You have got no 64-bit kernel quota support.])
782                 ],[])
783                 AC_MSG_RESULT([no])
784         ])
785 EXTRA_KCFLAGS=$tmp_flags
786 ])
787
788 # 2.6.32 set_cpus_allowed is no more defined if CONFIG_CPUMASK_OFFSTACK=yes
789 AC_DEFUN([LC_SET_CPUS_ALLOWED],
790          [AC_MSG_CHECKING([if kernel defines set_cpus_allowed])
791           LB_LINUX_TRY_COMPILE(
792                 [#include <linux/sched.h>],
793                 [struct task_struct *p = NULL;
794                  cpumask_t mask = { { 0 } };
795                  (void) set_cpus_allowed(p, mask);],
796                 [AC_MSG_RESULT([yes])
797                  AC_DEFINE(HAVE_SET_CPUS_ALLOWED, 1,
798                            [set_cpus_allowed is exported by the kernel])],
799                 [AC_MSG_RESULT([no])] )])
800
801 #
802 # 2.6.36 fs_struct.lock use spinlock instead of rwlock.
803 #
804 AC_DEFUN([LC_FS_STRUCT_RWLOCK],
805 [AC_MSG_CHECKING([if fs_struct.lock use rwlock])
806 LB_LINUX_TRY_COMPILE([
807         #include <asm/atomic.h>
808         #include <linux/spinlock.h>
809         #include <linux/fs_struct.h>
810 ],[
811         ((struct fs_struct *)0)->lock = (rwlock_t){ 0 };
812 ],[
813         AC_DEFINE(HAVE_FS_STRUCT_RWLOCK, 1,
814                   [fs_struct.lock use rwlock])
815         AC_MSG_RESULT([yes])
816 ],[
817         AC_MSG_RESULT([no])
818 ])
819 ])
820
821 #
822 # 2.6.36 super_operations add evict_inode method. it hybird of
823 # delete_inode & clear_inode.
824 #
825 AC_DEFUN([LC_SBOPS_EVICT_INODE],
826 [AC_MSG_CHECKING([if super_operations.evict_inode exist])
827 LB_LINUX_TRY_COMPILE([
828         #include <linux/fs.h>
829 ],[
830         ((struct super_operations *)0)->evict_inode(NULL);
831 ],[
832         AC_DEFINE(HAVE_SBOPS_EVICT_INODE, 1,
833                 [super_operations.evict_inode() is exist in kernel])
834         AC_MSG_RESULT([yes])
835 ],[
836         AC_MSG_RESULT([no])
837 ])
838 ])
839
840 #
841 # 2.6.35 file_operations.fsync taken 2 arguments.
842 # 3.0.0 file_operations.fsync takes 4 arguments.
843 #
844 AC_DEFUN([LC_FILE_FSYNC],
845 [AC_MSG_CHECKING([if file_operations.fsync takes 4 or 2 arguments])
846 LB_LINUX_TRY_COMPILE([
847         #include <linux/fs.h>
848 ],[
849         ((struct file_operations *)0)->fsync(NULL, 0, 0, 0);
850 ],[
851         AC_DEFINE(HAVE_FILE_FSYNC_4ARGS, 1,
852                 [file_operations.fsync takes 4 arguments])
853         AC_MSG_RESULT([yes, 4 args])
854 ],[
855         LB_LINUX_TRY_COMPILE([
856                 #include <linux/fs.h>
857         ],[
858            ((struct file_operations *)0)->fsync(NULL, 0);
859         ],[
860                 AC_DEFINE(HAVE_FILE_FSYNC_2ARGS, 1,
861                         [file_operations.fsync takes 2 arguments])
862                 AC_MSG_RESULT([yes, 2 args])
863         ],[
864                 AC_MSG_RESULT([no])
865         ])
866 ])
867 ])
868
869 #
870 # 2.6.37 remove kernel_locked
871 #
872 AC_DEFUN([LC_KERNEL_LOCKED],
873 [AC_MSG_CHECKING([if kernel_locked is defined])
874 LB_LINUX_TRY_COMPILE([
875         #include <linux/smp_lock.h>
876 ],[
877         kernel_locked();
878 ],[
879         AC_MSG_RESULT([yes])
880         AC_DEFINE(HAVE_KERNEL_LOCKED, 1,
881                 [kernel_locked is defined])
882 ],[
883         AC_MSG_RESULT([no])
884 ])
885 ])
886
887 #
888 # 2.6.38 dentry_operations.d_compare() taken 7 arguments.
889 #
890 AC_DEFUN([LC_D_COMPARE_7ARGS],
891 [AC_MSG_CHECKING([if d_compare taken 7 arguments])
892 LB_LINUX_TRY_COMPILE([
893         #include <linux/dcache.h>
894 ],[
895         ((struct dentry_operations*)0)->d_compare(NULL,NULL,NULL,NULL,0,NULL,NULL);
896 ],[
897         AC_DEFINE(HAVE_D_COMPARE_7ARGS, 1,
898                 [d_compare need 7 arguments])
899         AC_MSG_RESULT([yes])
900 ],[
901         AC_MSG_RESULT([no])
902 ])
903 ])
904
905 #
906 # 2.6.38 dentry_operations.d_delete() defined 'const' for 1st parameter.
907 #
908 AC_DEFUN([LC_D_DELETE_CONST],
909 [AC_MSG_CHECKING([if d_delete has const declare on first parameter])
910 tmp_flags="$EXTRA_KCFLAGS"
911 EXTRA_KCFLAGS="-Werror"
912 LB_LINUX_TRY_COMPILE([
913         #include <linux/dcache.h>
914 ],[
915         const struct dentry *d = NULL;
916         ((struct dentry_operations*)0)->d_delete(d);
917 ],[
918         AC_DEFINE(HAVE_D_DELETE_CONST, const,
919                 [d_delete first parameter declared const])
920         AC_MSG_RESULT([yes])
921 ],[
922         AC_DEFINE(HAVE_D_DELETE_CONST, , [])
923         AC_MSG_RESULT([no])
924 ])
925 EXTRA_KCFLAGS="$tmp_flags"
926 ])
927
928 #
929 # 2.6.38 dcache_lock removed. rcu-walk commited.
930 #
931 AC_DEFUN([LC_DCACHE_LOCK],
932 [AC_MSG_CHECKING([if dcache_lock is exist])
933 LB_LINUX_TRY_COMPILE([
934         #include <linux/dcache.h>
935 ],[
936         spin_lock(&dcache_lock);
937 ],[
938         AC_DEFINE(HAVE_DCACHE_LOCK, 1,
939                 [dcache_lock is exist])
940         AC_MSG_RESULT([yes])
941 ],[
942         AC_MSG_RESULT([no])
943 ])
944 ])
945
946 #
947 # 2.6.38 inode.i_rcu added.
948 #
949 AC_DEFUN([LC_INODE_I_RCU],
950 [AC_MSG_CHECKING([if inode.i_rcu exists])
951 LB_LINUX_TRY_COMPILE([
952         #include <linux/fs.h>
953 ],[
954         struct inode ino;
955         struct rcu_head rcu = {};
956         ino.i_rcu = rcu;
957 ],[
958         AC_DEFINE(HAVE_INODE_I_RCU, 1,
959                 [inode.i_rcu exists])
960         AC_MSG_RESULT([yes])
961 ],[
962         AC_MSG_RESULT([no])
963 ])
964 ])
965
966 #
967 # 2.6.38 export blkdev_get_by_dev
968 #
969 AC_DEFUN([LC_BLKDEV_GET_BY_DEV],
970 [LB_CHECK_SYMBOL_EXPORT([blkdev_get_by_dev],
971 [fs/block_dev.c],[
972 AC_DEFINE(HAVE_BLKDEV_GET_BY_DEV, 1,
973             [blkdev_get_by_dev is exported by the kernel])
974 ],[
975 ])
976 ])
977
978 #
979 # 2.6.38 use path as 4th parameter in quota_on.
980 #
981 AC_DEFUN([LC_QUOTA_ON_USE_PATH],
982 [AC_MSG_CHECKING([quota_on use path as parameter])
983 tmp_flags="$EXTRA_KCFLAGS"
984 EXTRA_KCFLAGS="-Werror"
985 LB_LINUX_TRY_COMPILE([
986         #include <linux/fs.h>
987         #include <linux/quota.h>
988 ],[
989         ((struct quotactl_ops *)0)->quota_on(NULL, 0, 0, ((struct path*)0));
990 ],[
991         AC_DEFINE(HAVE_QUOTA_ON_USE_PATH, 1,
992                 [quota_on use path as 4th paramter])
993         AC_MSG_RESULT([yes])
994 ],[
995         AC_MSG_RESULT([no])
996 ])
997 EXTRA_KCFLAGS="$tmp_flags"
998 ])
999
1000 #
1001 # 2.6.38 export simple_setattr
1002 #
1003 AC_DEFUN([LC_EXPORT_SIMPLE_SETATTR],
1004 [LB_CHECK_SYMBOL_EXPORT([simple_setattr],
1005 [fs/libfs.c],[
1006 AC_DEFINE(HAVE_SIMPLE_SETATTR, 1,
1007             [simple_setattr is exported by the kernel])
1008 ],[
1009 ])
1010 ])
1011
1012 #
1013 # 2.6.39 remove unplug_fn from request_queue.
1014 #
1015 AC_DEFUN([LC_REQUEST_QUEUE_UNPLUG_FN],
1016 [AC_MSG_CHECKING([if request_queue has unplug_fn field])
1017 LB_LINUX_TRY_COMPILE([
1018         #include <linux/blkdev.h>
1019 ],[
1020         do{ }while(sizeof(((struct request_queue *)0)->unplug_fn));
1021 ],[
1022         AC_DEFINE(HAVE_REQUEST_QUEUE_UNPLUG_FN, 1,
1023                   [request_queue has unplug_fn field])
1024         AC_MSG_RESULT([yes])
1025 ],[
1026         AC_MSG_RESULT([no])
1027 ])
1028 ])
1029
1030 #
1031 # 2.6.39 replace get_sb with mount in struct file_system_type
1032 #
1033 AC_DEFUN([LC_HAVE_FSTYPE_MOUNT],
1034 [AC_MSG_CHECKING([if file_system_type has mount field])
1035 LB_LINUX_TRY_COMPILE([
1036         #include <linux/fs.h>
1037 ],[
1038         struct file_system_type fst;
1039         void *i = (void *) fst.mount;
1040 ],[
1041         AC_DEFINE(HAVE_FSTYPE_MOUNT, 1,
1042                 [struct file_system_type has mount field])
1043         AC_MSG_RESULT([yes])
1044 ],[
1045         AC_MSG_RESULT([no])
1046 ])
1047 ])
1048
1049 #
1050 # 3.0 dirty_inode() has a flag parameter
1051 # see kernel commit aa38572954ade525817fe88c54faebf85e5a61c0
1052 #
1053 AC_DEFUN([LC_DIRTY_INODE_WITH_FLAG],
1054 [AC_MSG_CHECKING([if dirty_inode super_operation takes flag])
1055 LB_LINUX_TRY_COMPILE([
1056         #include <linux/fs.h>
1057 ],[
1058         struct inode *inode;
1059         inode->i_sb->s_op->dirty_inode(NULL, 0);
1060 ],[
1061         AC_DEFINE(HAVE_DIRTY_INODE_HAS_FLAG, 1,
1062                   [dirty_inode super_operation takes flag])
1063         AC_MSG_RESULT([yes])
1064 ],[
1065         AC_MSG_RESULT([no])
1066 ])
1067 ])
1068
1069 #
1070 # 2.6.38 generic_permission taken 4 parameters.
1071 # in fact, it means rcu-walk aware permission bring.
1072 #
1073 # 3.1 generic_permission taken 2 parameters.
1074 # see kernel commit 2830ba7f34ebb27c4e5b8b6ef408cd6d74860890
1075 #
1076 AC_DEFUN([LC_GENERIC_PERMISSION],
1077 [AC_MSG_CHECKING([if generic_permission take 2 or 4 arguments])
1078 LB_LINUX_TRY_COMPILE([
1079         #include <linux/fs.h>
1080 ],[
1081         generic_permission(NULL, 0);
1082 ],[
1083         AC_DEFINE(HAVE_GENERIC_PERMISSION_2ARGS, 1,
1084                   [generic_permission taken 2 arguments])
1085         AC_MSG_RESULT([yes, 2 args])
1086 ],[
1087         LB_LINUX_TRY_COMPILE([
1088                 #include <linux/fs.h>
1089         ],[
1090                 generic_permission(NULL, 0, 0, NULL);
1091         ],[
1092                 AC_DEFINE(HAVE_GENERIC_PERMISSION_4ARGS, 1,
1093                           [generic_permission taken 4 arguments])
1094                 AC_MSG_RESULT([yes, 4 args])
1095         ],[
1096                 AC_MSG_RESULT([no])
1097         ])
1098 ])
1099 ])
1100
1101 #
1102 # 3.1 renames lock-manager ops(lock_manager_operations) from fl_xxx to lm_xxx
1103 # see kernel commit 8fb47a4fbf858a164e973b8ea8ef5e83e61f2e50
1104 #
1105 AC_DEFUN([LC_LM_XXX_LOCK_MANAGER_OPS],
1106 [AC_MSG_CHECKING([if lock-manager ops renamed to lm_xxx])
1107 LB_LINUX_TRY_COMPILE([
1108         #include <linux/fs.h>
1109 ],[
1110         struct lock_manager_operations lm_ops;
1111         lm_ops.lm_compare_owner = NULL;
1112 ],[
1113         AC_DEFINE(HAVE_LM_XXX_LOCK_MANAGER_OPS, 1,
1114                   [lock-manager ops renamed to lm_xxx])
1115         AC_MSG_RESULT([yes])
1116 ],[
1117         AC_MSG_RESULT([no])
1118 ])
1119 ])
1120
1121 #
1122 # 3.1 kills inode->i_alloc_sem, use i_dio_count and inode_dio_wait/
1123 #     inode_dio_done instead.
1124 # see kernel commit bd5fe6c5eb9c548d7f07fe8f89a150bb6705e8e3
1125 #
1126 AC_DEFUN([LC_INODE_DIO_WAIT],
1127 [AC_MSG_CHECKING([if inode->i_alloc_sem is killed and use inode_dio_wait/done.])
1128 LB_LINUX_TRY_COMPILE([
1129         #include <linux/fs.h>
1130 ],[
1131         inode_dio_wait((struct inode *)0);
1132         inode_dio_done((struct inode *)0);
1133 ],[
1134         AC_DEFINE(HAVE_INODE_DIO_WAIT, 1,
1135                   [inode->i_alloc_sem is killed and use inode_dio_wait/done])
1136         AC_MSG_RESULT([yes])
1137 ],[
1138         AC_MSG_RESULT([no])
1139 ])
1140 ])
1141
1142 #
1143 # 3.1 adds get_acl method to inode_operations to read ACL from disk.
1144 # see kernel commit 4e34e719e457f2e031297175410fc0bd4016a085
1145 #
1146 AC_DEFUN([LC_IOP_GET_ACL],
1147 [AC_MSG_CHECKING([inode_operations has .get_acl member function])
1148 LB_LINUX_TRY_COMPILE([
1149         #include <linux/fs.h>
1150 ],[
1151         struct inode_operations iop;
1152         iop.get_acl = NULL;
1153 ],[
1154         AC_DEFINE(HAVE_IOP_GET_ACL, 1,
1155                   [inode_operations has .get_acl member function])
1156         AC_MSG_RESULT([yes])
1157 ],[
1158         AC_MSG_RESULT([no])
1159 ])
1160 ])
1161
1162 #
1163 # 3.1.1 has ext4_blocks_for_truncate
1164 #
1165 AC_DEFUN([LC_BLOCKS_FOR_TRUNCATE],
1166 [AC_MSG_CHECKING([if kernel has ext4_blocks_for_truncate])
1167 LB_LINUX_TRY_COMPILE([
1168         #include <linux/fs.h>
1169         #include "$LINUX/fs/ext4/ext4_jbd2.h"
1170         #include "$LINUX/fs/ext4/truncate.h"
1171 ],[
1172         ext4_blocks_for_truncate(NULL);
1173 ],[
1174         AC_MSG_RESULT([yes])
1175         AC_DEFINE(HAVE_BLOCKS_FOR_TRUNCATE, 1,
1176                   [kernel has ext4_blocks_for_truncate])
1177 ],[
1178         AC_MSG_RESULT([no])
1179 ])
1180 ])
1181
1182 #
1183 # 3.1 introduced generic_file_llseek_size()
1184 #
1185 AC_DEFUN([LC_FILE_LLSEEK_SIZE],
1186         [LB_CHECK_SYMBOL_EXPORT([generic_file_llseek_size],
1187         [fs/read_write.c],
1188         [AC_DEFINE(HAVE_FILE_LLSEEK_SIZE, 1,
1189                    [generic_file_llseek_size is exported by the kernel])])
1190 ])
1191
1192 #
1193 # 3.2 request_queue.make_request_fn defined as function returns with void
1194 # see kernel commit 5a7bbad27a410350e64a2d7f5ec18fc73836c14f
1195 #
1196 AC_DEFUN([LC_HAVE_VOID_MAKE_REQUEST_FN],
1197 [AC_MSG_CHECKING([if request_queue.make_request_fn returns void but not int])
1198 LB_LINUX_TRY_COMPILE([
1199         #include <linux/blkdev.h>
1200 ],[
1201         int ret;
1202         make_request_fn         *mrf;
1203         ret = mrf(NULL, NULL);
1204 ],[
1205         AC_MSG_RESULT([no])
1206 ],[
1207         AC_DEFINE(HAVE_VOID_MAKE_REQUEST_FN, 1,
1208                   [request_queue.make_request_fn returns void but not int])
1209         AC_MSG_RESULT([yes])
1210 ])
1211 ])
1212
1213 #
1214 # 3.2 protects inode->i_nlink from direct modification
1215 # see kernel commit a78ef704a8dd430225955f0709b22d4a6ba21deb
1216 # at the same time adds set_nlink(), so checks set_nlink() for it.
1217 #
1218 AC_DEFUN([LC_HAVE_PROTECT_I_NLINK],
1219 [AC_MSG_CHECKING([if inode->i_nlink is protected from direct modification])
1220 LB_LINUX_TRY_COMPILE([
1221         #include <linux/fs.h>
1222 ],[
1223         struct inode i;
1224         set_nlink(&i, 1);
1225 ],[
1226         AC_DEFINE(HAVE_PROTECT_I_NLINK, 1,
1227                   [inode->i_nlink is protected from direct modification])
1228         AC_MSG_RESULT([yes])
1229 ],[
1230         AC_MSG_RESULT([no])
1231 ])
1232 ])
1233
1234 #
1235 # 3.3 introduces migrate_mode.h and migratepage has 4 args
1236 #
1237 AC_DEFUN([LC_HAVE_MIGRATE_HEADER],
1238 [LB_CHECK_FILE([$LINUX/include/linux/migrate.h],[
1239                 AC_DEFINE(HAVE_MIGRATE_H, 1,
1240                 [kernel has include/linux/migrate.h])
1241 ],[LB_CHECK_FILE([$LINUX/include/linux/migrate_mode.h],[
1242                 AC_DEFINE(HAVE_MIGRATE_MODE_H, 1,
1243                         [kernel has include/linux/migrate_mode.h])
1244 ],[
1245         AC_MSG_RESULT([no])
1246 ])
1247 ])
1248 ])
1249
1250 AC_DEFUN([LC_MIGRATEPAGE_4ARGS],
1251 [AC_MSG_CHECKING([if address_space_operations.migratepage has 4 args])
1252 LB_LINUX_TRY_COMPILE([
1253         #include <linux/fs.h>
1254 #ifdef HAVE_MIGRATE_H
1255         #include <linux/migrate.h>
1256 #elif defined(HAVE_MIGRATE_MODE_H)
1257         #include <linux/migrate_mode.h>
1258 #endif
1259 ],[
1260         struct address_space_operations aops;
1261
1262         aops.migratepage(NULL, NULL, NULL, MIGRATE_ASYNC);
1263 ],[
1264         AC_DEFINE(HAVE_MIGRATEPAGE_4ARGS, 1,
1265                 [address_space_operations.migratepage has 4 args])
1266         AC_MSG_RESULT([yes])
1267 ],[
1268         AC_MSG_RESULT([no])
1269 ])
1270 ])
1271
1272 #
1273 # 3.3 switchs super_operations to use dentry as parameter (but not vfsmount)
1274 # see kernel commit 34c80b1d93e6e20ca9dea0baf583a5b5510d92d4
1275 #
1276 AC_DEFUN([LC_SUPEROPS_USE_DENTRY],
1277 [AC_MSG_CHECKING([if super_operations use dentry as parameter])
1278 tmp_flags="$EXTRA_KCFLAGS"
1279 EXTRA_KCFLAGS="-Werror"
1280 LB_LINUX_TRY_COMPILE([
1281         #include <linux/fs.h>
1282         int show_options(struct seq_file *seq, struct dentry *root){
1283                 return 0;
1284         }
1285 ],[
1286         struct super_operations ops;
1287         ops.show_options = show_options;
1288 ],[
1289         AC_DEFINE(HAVE_SUPEROPS_USE_DENTRY, 1,
1290                   [super_operations use dentry as parameter])
1291         AC_MSG_RESULT([yes])
1292 ],[
1293         AC_MSG_RESULT([no])
1294 ])
1295 EXTRA_KCFLAGS="$tmp_flags"
1296 ])
1297
1298 #
1299 # 3.3 switchs inode_operations to use umode_t as parameter (but not int)
1300 # see kernel commit 1a67aafb5f72a436ca044293309fa7e6351d6a35
1301 #
1302 AC_DEFUN([LC_INODEOPS_USE_UMODE_T],
1303 [AC_MSG_CHECKING([if inode_operations use umode_t as parameter])
1304 tmp_flags="$EXTRA_KCFLAGS"
1305 EXTRA_KCFLAGS="-Werror"
1306 LB_LINUX_TRY_COMPILE([
1307         #include <linux/fs.h>
1308         #include <linux/types.h>
1309         int my_mknod(struct inode *dir, struct dentry *dchild,
1310                      umode_t mode, dev_t dev)
1311         {
1312                 return 0;
1313         }
1314 ],[
1315         struct inode_operations ops;
1316         ops.mknod = my_mknod;
1317 ],[
1318         AC_DEFINE(HAVE_INODEOPS_USE_UMODE_T, 1,
1319                   [inode_operations use umode_t as parameter])
1320         AC_MSG_RESULT([yes])
1321 ],[
1322         AC_MSG_RESULT([no])
1323 ])
1324 EXTRA_KCFLAGS="$tmp_flags"
1325 ])
1326
1327 # 3.4 kmap_atomic removes second argument
1328 # see kernel commit 1ec9c5ddc17aa398f05646abfcbaf315b544e62f
1329 #
1330 AC_DEFUN([LC_KMAP_ATOMIC_HAS_1ARG],
1331 [AC_MSG_CHECKING([if kmap_atomic has only 1 argument])
1332 LB_LINUX_TRY_COMPILE([
1333         #include <linux/highmem.h>
1334 ],[
1335         kmap_atomic(NULL);
1336 ],[
1337         AC_DEFINE(HAVE_KMAP_ATOMIC_HAS_1ARG, 1,
1338                   [have kmap_atomic has only 1 argument])
1339         AC_MSG_RESULT([yes])
1340 ],[
1341         AC_MSG_RESULT([no])
1342 ])
1343 ])
1344
1345 #
1346 # 3.4 switchs touch_atime to struct path
1347 # see kernel commit 68ac1234fb949b66941d94dce4157742799fc581
1348 #
1349 AC_DEFUN([LC_TOUCH_ATIME_1ARG],
1350 [AC_MSG_CHECKING([if touch_atime use one argument])
1351 LB_LINUX_TRY_COMPILE([
1352         #include <linux/fs.h>
1353 ],[
1354         touch_atime((struct path *)NULL);
1355 ],[
1356         AC_DEFINE(HAVE_TOUCH_ATIME_1ARG, 1,
1357                   [touch_atime use one argument])
1358         AC_MSG_RESULT([yes])
1359 ],[
1360         AC_MSG_RESULT([no])
1361 ])
1362 ])
1363
1364 #
1365 # 3.4 converts d_alloc_root to d_make_root
1366 # see kernel commit 32991ab305ace7017c62f8eecbe5eb36dc32e13b
1367 #
1368 AC_DEFUN([LC_HAVE_D_MAKE_ROOT],
1369 [AC_MSG_CHECKING([if have d_make_root])
1370 LB_LINUX_TRY_COMPILE([
1371         #include <linux/fs.h>
1372 ],[
1373         d_make_root((struct inode *)NULL);
1374 ],[
1375         AC_DEFINE(HAVE_D_MAKE_ROOT, 1,
1376                   [have d_make_root])
1377         AC_MSG_RESULT([yes])
1378 ],[
1379         AC_MSG_RESULT([no])
1380 ])
1381 ])
1382
1383 #
1384 # 3.5 renames end_writeback() back to clear_inode()...
1385 # see kernel commit dbd5768f87ff6fb0a4fe09c4d7b6c4a24de99430
1386 #
1387 AC_DEFUN([LC_HAVE_CLEAR_INODE],
1388 [AC_MSG_CHECKING([if have clear_inode])
1389 LB_LINUX_TRY_COMPILE([
1390         #include <linux/fs.h>
1391 ],[
1392         clear_inode((struct inode *)NULL);
1393 ],[
1394         AC_DEFINE(HAVE_CLEAR_INODE, 1,
1395                   [have clear_inode])
1396         AC_MSG_RESULT([yes])
1397 ],[
1398         AC_MSG_RESULT([no])
1399 ])
1400 ])
1401
1402 #
1403 # 3.5 encode_fh has parent inode passed in directly
1404 # see kernel commit b0b0382b
1405 #
1406 AC_DEFUN([LC_HAVE_ENCODE_FH_PARENT],
1407 [AC_MSG_CHECKING([if encode_fh have parent inode as parameter])
1408 tmp_flags="$EXTRA_KCFLAGS"
1409 EXTRA_KCFLAGS="-Werror"
1410 LB_LINUX_TRY_COMPILE([
1411         #include <linux/exportfs.h>
1412         #include <linux/fs.h>
1413         #include <linux/types.h>
1414         int ll_encode_fh(struct inode *i, __u32 *a, int *b, struct inode *p)
1415         {
1416                 return 0;
1417         }
1418 ],[
1419         struct export_operations exp_op;
1420         exp_op.encode_fh = ll_encode_fh;
1421 ],[
1422         AC_DEFINE(HAVE_ENCODE_FH_PARENT, 1,
1423                   [have parent inode as parameter])
1424         AC_MSG_RESULT([yes])
1425 ],[
1426         AC_MSG_RESULT([no])
1427 ])
1428 EXTRA_KCFLAGS="$tmp_flags"
1429 ])
1430
1431 # 3.5 has generic_file_llseek_size with 5 args
1432 AC_DEFUN([LC_FILE_LLSEEK_SIZE_5ARG],
1433 [AC_MSG_CHECKING([if kernel has generic_file_llseek_size with 5 args])
1434 LB_LINUX_TRY_COMPILE([
1435         #include <linux/fs.h>
1436 ],[
1437         generic_file_llseek_size(NULL, 0, 0, 0, 0);
1438 ], [
1439         AC_MSG_RESULT([yes])
1440         AC_DEFINE(HAVE_FILE_LLSEEK_SIZE_5ARGS, 1,
1441                 [kernel has generic_file_llseek_size with 5 args])
1442 ],[
1443         AC_MSG_RESULT([no])
1444 ])
1445 ])
1446
1447 #
1448 # 3.6 switch i_dentry/d_alias from list to hlist
1449 #
1450 AC_DEFUN([LC_HAVE_DENTRY_D_ALIAS_HLIST],
1451 [AC_MSG_CHECKING([if i_dentry/d_alias uses hlist])
1452 tmp_flags="$EXTRA_KCFLAGS"
1453 EXTRA_KCFLAGS="-Werror"
1454 LB_LINUX_TRY_COMPILE([
1455         #include <linux/fs.h>
1456         #include <linux/list.h>
1457 ],[
1458         struct inode inode;
1459         struct dentry dentry;
1460         struct hlist_head head;
1461         struct hlist_node node;
1462         inode.i_dentry = head;
1463         dentry.d_alias = node;
1464 ],[
1465         AC_DEFINE(HAVE_DENTRY_D_ALIAS_HLIST, 1,
1466                   [have i_dentry/d_alias uses hlist])
1467         AC_MSG_RESULT([yes])
1468 ],[
1469         AC_MSG_RESULT([no])
1470 ])
1471 EXTRA_KCFLAGS="$tmp_flags"
1472 ])
1473
1474 #
1475 # 3.6 dentry_open uses struct path as first argument
1476 # see kernel commit 765927b2
1477 #
1478 AC_DEFUN([LC_DENTRY_OPEN_USE_PATH],
1479 [AC_MSG_CHECKING([if dentry_open uses struct path as first argument])
1480 tmp_flags="$EXTRA_KCFLAGS"
1481 EXTRA_KCFLAGS="-Werror"
1482 LB_LINUX_TRY_COMPILE([
1483         #include <linux/fs.h>
1484         #include <linux/path.h>
1485 ],[
1486         struct path path;
1487         dentry_open(&path, 0, NULL);
1488 ],[
1489         AC_DEFINE(HAVE_DENTRY_OPEN_USE_PATH, 1,
1490                   [dentry_open uses struct path as first argument])
1491         AC_MSG_RESULT([yes])
1492 ],[
1493         AC_MSG_RESULT([no])
1494 ])
1495 EXTRA_KCFLAGS="$tmp_flags"
1496 ])
1497
1498 #
1499 # 3.6 vfs adds iop->atomic_open
1500 #
1501 AC_DEFUN([LC_HAVE_IOP_ATOMIC_OPEN],
1502 [AC_MSG_CHECKING([if iop has atomic_open])
1503 LB_LINUX_TRY_COMPILE([
1504         #include <linux/fs.h>
1505 ],[
1506         struct inode_operations iop;
1507         iop.atomic_open = NULL;
1508 ],[
1509         AC_DEFINE(HAVE_IOP_ATOMIC_OPEN, 1,
1510                   [have iop atomic_open])
1511         AC_MSG_RESULT([yes])
1512 ],[
1513         AC_MSG_RESULT([no])
1514 ])
1515 ])
1516
1517 #
1518 # 3.7 posix_acl_{to,from}_xattr take struct user_namespace
1519 #
1520 AC_DEFUN([LC_HAVE_POSIXACL_USER_NS],
1521 [AC_MSG_CHECKING([if posix_acl_to_xattr takes struct user_namespace])
1522 LB_LINUX_TRY_COMPILE([
1523         #include <linux/fs.h>
1524         #include <linux/posix_acl_xattr.h>
1525 ],[
1526         posix_acl_to_xattr((struct user_namespace *)NULL, NULL, NULL, 0);
1527 ],[
1528         AC_DEFINE(HAVE_POSIXACL_USER_NS, 1,
1529                   [posix_acl_to_xattr takes struct user_namespace])
1530         AC_MSG_RESULT([yes])
1531 ],[
1532         AC_MSG_RESULT([no])
1533 ])
1534 ])
1535
1536 #
1537 # 3.9 uses hlist_for_each_entry with 3 args
1538 # b67bfe0d42cac56c512dd5da4b1b347a23f4b70a
1539 #
1540 AC_DEFUN([LC_HAVE_HLIST_FOR_EACH_3ARG],
1541 [AC_MSG_CHECKING([if hlist_for_each_entry has 3 args])
1542 LB_LINUX_TRY_COMPILE([
1543         #include <linux/list.h>
1544         #include <linux/fs.h>
1545 ],[
1546         struct inode *inode;
1547         struct dentry *dentry;
1548         hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) {
1549                 continue;
1550         }
1551 ],[
1552         AC_DEFINE(HAVE_HLIST_FOR_EACH_3ARG, 1, [3 args])
1553         AC_MSG_RESULT([yes])
1554 ],[
1555         AC_MSG_RESULT([no])
1556 ])
1557 ])
1558
1559 #
1560 # LC_PROG_LINUX
1561 #
1562 # Lustre linux kernel checks
1563 #
1564 AC_DEFUN([LC_PROG_LINUX],
1565          [
1566          LC_CONFIG_PINGER
1567          LC_CONFIG_CHECKSUM
1568          LC_CONFIG_LIBLUSTRE_RECOVERY
1569          LC_CONFIG_HEALTH_CHECK_WRITE
1570          LC_CONFIG_LRU_RESIZE
1571          LC_LLITE_LLOOP_MODULE
1572
1573          # RHEL4 patches
1574          LC_EXPORT_TRUNCATE_COMPLETE
1575
1576          LC_BIT_SPINLOCK_H
1577
1578          LC_CAPA_CRYPTO
1579          LC_CONFIG_RMTCLIENT
1580          LC_CONFIG_GSS
1581
1582          # 2.6.12
1583          LC_RW_TREE_LOCK
1584
1585          #2.6.18 + RHEL5 (fc6)
1586          LC_LINUX_FIEMAP_H
1587
1588          # raid5-zerocopy patch
1589          LC_PAGE_CONSTANT
1590
1591          # 2.6.22
1592          LC_INVALIDATE_BDEV_2ARG
1593          LC_FS_RENAME_DOES_D_MOVE
1594
1595          # 2.6.23
1596          LC_UNREGISTER_BLKDEV_RETURN_INT
1597          LC_PROCFS_USERS
1598
1599          # 2.6.24
1600          LC_BIO_ENDIO_2ARG
1601          LC_PROCFS_DELETED
1602
1603          # 2.6.26
1604          LC_FS_STRUCT_USE_PATH
1605
1606          # 2.6.27
1607          LC_SECURITY_PLUG  # for SLES10 SP2
1608          LC_INODE_PERMISION_2ARGS
1609          LC_QUOTA_ON_5ARGS
1610          LC_QUOTA_OFF_3ARGS
1611          LC_LOCK_MAP_ACQUIRE
1612
1613          # 2.6.27.15-2 sles11
1614          LC_BI_HW_SEGMENTS
1615          LC_HAVE_QUOTAIO_H
1616
1617          # 2.6.32
1618          LC_BLK_QUEUE_MAX_SEGMENTS
1619          LC_SET_CPUS_ALLOWED
1620
1621          # 2.6.34
1622          LC_HAVE_DQUOT_FS_DISK_QUOTA
1623          LC_HAVE_DQUOT_SUSPEND
1624
1625          # 2.6.35, 3.0.0
1626          LC_FILE_FSYNC
1627          LC_EXPORT_SIMPLE_SETATTR
1628
1629          # 2.6.36
1630          LC_FS_STRUCT_RWLOCK
1631          LC_SBOPS_EVICT_INODE
1632
1633          # 2.6.37
1634          LC_KERNEL_LOCKED
1635
1636          # 2.6.38
1637          LC_BLKDEV_GET_BY_DEV
1638          LC_GENERIC_PERMISSION
1639          LC_QUOTA_ON_USE_PATH
1640          LC_DCACHE_LOCK
1641          LC_INODE_I_RCU
1642          LC_D_COMPARE_7ARGS
1643          LC_D_DELETE_CONST
1644
1645          # 2.6.39
1646          LC_REQUEST_QUEUE_UNPLUG_FN
1647          LC_HAVE_FSTYPE_MOUNT
1648
1649          # 3.0
1650          LC_DIRTY_INODE_WITH_FLAG
1651
1652          # 3.1
1653          LC_LM_XXX_LOCK_MANAGER_OPS
1654          LC_INODE_DIO_WAIT
1655          LC_IOP_GET_ACL
1656          LC_FILE_LLSEEK_SIZE
1657
1658          # 3.1.1
1659          LC_BLOCKS_FOR_TRUNCATE
1660
1661          # 3.2
1662          LC_HAVE_VOID_MAKE_REQUEST_FN
1663          LC_HAVE_PROTECT_I_NLINK
1664
1665          # 3.3
1666          LC_HAVE_MIGRATE_HEADER
1667          LC_MIGRATEPAGE_4ARGS
1668          LC_SUPEROPS_USE_DENTRY
1669          LC_INODEOPS_USE_UMODE_T
1670
1671          # 3.4
1672          LC_TOUCH_ATIME_1ARG
1673          LC_HAVE_D_MAKE_ROOT
1674          LC_KMAP_ATOMIC_HAS_1ARG
1675
1676          # 3.5
1677          LC_HAVE_CLEAR_INODE
1678          LC_HAVE_ENCODE_FH_PARENT
1679          LC_FILE_LLSEEK_SIZE_5ARG
1680
1681          # 3.6
1682          LC_HAVE_DENTRY_D_ALIAS_HLIST
1683          LC_DENTRY_OPEN_USE_PATH
1684          LC_HAVE_IOP_ATOMIC_OPEN
1685
1686          # 3.7
1687          LC_HAVE_POSIXACL_USER_NS
1688
1689          # 3.9
1690          LC_HAVE_HLIST_FOR_EACH_3ARG
1691
1692          #
1693          if test x$enable_server = xyes ; then
1694                 AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
1695                 LC_FUNC_DEV_SET_RDONLY
1696                 LC_STACK_SIZE
1697                 LC_QUOTA64
1698                 LC_QUOTA_CONFIG
1699          fi
1700 ])
1701
1702 #
1703 # LC_CONFIG_CLIENT_SERVER
1704 #
1705 # Build client/server sides of Lustre
1706 #
1707 AC_DEFUN([LC_CONFIG_CLIENT_SERVER],
1708 [AC_MSG_CHECKING([whether to build Lustre server support])
1709 AC_ARG_ENABLE([server],
1710         AC_HELP_STRING([--disable-server],
1711                         [disable Lustre server support]),
1712         [],[enable_server='yes'])
1713 AC_MSG_RESULT([$enable_server])
1714
1715 AC_MSG_CHECKING([whether to build Lustre client support])
1716 AC_ARG_ENABLE([client],
1717         AC_HELP_STRING([--disable-client],
1718                         [disable Lustre client support]),
1719         [],[enable_client='yes'])
1720 AC_MSG_RESULT([$enable_client])])
1721
1722 #
1723 # LC_CONFIG_LIBLUSTRE
1724 #
1725 # whether to build liblustre
1726 #
1727 AC_DEFUN([LC_CONFIG_LIBLUSTRE],
1728 [AC_MSG_CHECKING([whether to build Lustre library])
1729 AC_ARG_ENABLE([liblustre],
1730         AC_HELP_STRING([--disable-liblustre],
1731                         [disable building of Lustre library]),
1732         [],[enable_liblustre=$with_sysio])
1733 AC_MSG_RESULT([$enable_liblustre])
1734 # only build sysio if liblustre is built
1735 with_sysio="$enable_liblustre"
1736
1737 AC_MSG_CHECKING([whether to build liblustre tests])
1738 AC_ARG_ENABLE([liblustre-tests],
1739         AC_HELP_STRING([--enable-liblustre-tests],
1740                         [enable liblustre tests, if --disable-tests is used]),
1741         [],[enable_liblustre_tests=$enable_tests])
1742 if test x$enable_liblustre != xyes ; then
1743    enable_liblustre_tests='no'
1744 fi
1745 AC_MSG_RESULT([$enable_liblustre_tests])
1746
1747 AC_MSG_CHECKING([whether to enable liblustre acl])
1748 AC_ARG_ENABLE([liblustre-acl],
1749         AC_HELP_STRING([--disable-liblustre-acl],
1750                         [disable ACL support for liblustre]),
1751         [],[enable_liblustre_acl=yes])
1752 AC_MSG_RESULT([$enable_liblustre_acl])
1753 if test x$enable_liblustre_acl = xyes ; then
1754   AC_DEFINE(LIBLUSTRE_POSIX_ACL, 1, Liblustre Support ACL-enabled MDS)
1755 fi
1756
1757 # 2.6.29 blkdev_put has 2 arguments
1758 AC_DEFUN([LC_BLKDEV_PUT_2ARGS],
1759 [AC_MSG_CHECKING([blkdev_put needs 2 parameters])
1760 LB_LINUX_TRY_COMPILE([
1761         #include <linux/fs.h>
1762 ],[
1763         blkdev_put(NULL, 0);
1764 ],[
1765         AC_DEFINE(HAVE_BLKDEV_PUT_2ARGS, 1,
1766                 [blkdev_put needs 2 paramters])
1767         AC_MSG_RESULT([yes])
1768 ],[
1769         AC_MSG_RESULT([no])
1770 ])
1771 ])
1772
1773 #
1774 # --enable-mpitest
1775 #
1776 AC_ARG_ENABLE(mpitests,
1777         AC_HELP_STRING([--enable-mpitests=yes|no|mpicc wrapper],
1778                            [include mpi tests]),
1779         [
1780          enable_mpitests=yes
1781          case $enableval in
1782          yes)
1783                 MPICC_WRAPPER=mpicc
1784                 ;;
1785          no)
1786                 enable_mpitests=no
1787                 ;;
1788          *)
1789                 MPICC_WRAPPER=$enableval
1790                  ;;
1791          esac
1792         ],
1793         [
1794         MPICC_WRAPPER=mpicc
1795         enable_mpitests=yes
1796         ]
1797 )
1798
1799 if test x$enable_mpitests != xno; then
1800         AC_MSG_CHECKING([whether mpitests can be built])
1801         oldcc=$CC
1802         CC=$MPICC_WRAPPER
1803         AC_LINK_IFELSE(
1804             [AC_LANG_PROGRAM([[
1805                     #include <mpi.h>
1806                 ]],[[
1807                     int flag;
1808                     MPI_Initialized(&flag);
1809                 ]])],
1810             [
1811                     AC_MSG_RESULT([yes])
1812             ],[
1813                     AC_MSG_RESULT([no])
1814                     enable_mpitests=no
1815         ])
1816         CC=$oldcc
1817 fi
1818 AC_SUBST(MPICC_WRAPPER)
1819
1820 AC_MSG_NOTICE([Enabling Lustre configure options for libsysio])
1821 ac_configure_args="$ac_configure_args --with-lustre-hack --with-sockets"
1822
1823 LC_CONFIG_PINGER
1824 LC_CONFIG_LIBLUSTRE_RECOVERY
1825 ])
1826
1827 #
1828 # LC_CONFIG_QUOTA
1829 #
1830 # whether to enable quota support global control
1831 #
1832 AC_DEFUN([LC_CONFIG_QUOTA],
1833 [AC_ARG_ENABLE([quota],
1834         AC_HELP_STRING([--enable-quota],
1835                         [enable quota support]),
1836         [],[enable_quota='yes'])
1837 ])
1838
1839 AC_DEFUN([LC_QUOTA],
1840 [#check global
1841 LC_CONFIG_QUOTA
1842 #check for utils
1843 AC_CHECK_HEADER(sys/quota.h,
1844                 [AC_DEFINE(HAVE_SYS_QUOTA_H, 1, [Define to 1 if you have <sys/quota.h>.])],
1845                 [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
1846 ])
1847
1848 #
1849 # LC_CONFIG_SPLIT
1850 #
1851 # whether to enable split support
1852 #
1853 AC_DEFUN([LC_CONFIG_SPLIT],
1854 [AC_MSG_CHECKING([whether to enable split support])
1855 AC_ARG_ENABLE([split],
1856         AC_HELP_STRING([--enable-split],
1857                         [enable split support]),
1858         [],[enable_split='no'])
1859 AC_MSG_RESULT([$enable_split])
1860 if test x$enable_split != xno; then
1861    AC_DEFINE(HAVE_SPLIT_SUPPORT, 1, [enable split support])
1862 fi
1863 ])
1864
1865 #
1866 # LC_LLITE_LLOOP_MODULE
1867 # lloop_llite.ko does not currently work with page sizes
1868 # of 64k or larger.
1869 #
1870 AC_DEFUN([LC_LLITE_LLOOP_MODULE],
1871 [AC_MSG_CHECKING([whether to enable llite_lloop module])
1872 LB_LINUX_TRY_COMPILE([
1873         #include <asm/page.h>
1874 ],[
1875         #if PAGE_SIZE >= 65536
1876         #error "PAGE_SIZE >= 65536"
1877         #endif
1878 ],[
1879         enable_llite_lloop_module='yes'
1880         AC_MSG_RESULT([yes])
1881 ],[
1882         enable_llite_lloop_module='no'
1883         AC_MSG_RESULT([no])
1884 ])
1885 ])
1886
1887 #
1888 # LC_OSD_ADDON
1889 #
1890 # configure support for optional OSD implementation
1891 #
1892 AC_DEFUN([LC_OSD_ADDON],
1893 [AC_MSG_CHECKING([for osd])
1894 AC_ARG_WITH([osd],
1895         AC_HELP_STRING([--with-osd=path],
1896                        [set path to optional osd]),
1897         [
1898                 case $with_osd in
1899                         no)     ENABLEOSDADDON=0
1900                                 ;;
1901                         *)      OSDADDON="${with_osd}"
1902                                 ENABLEOSDADDON=1
1903                                 ;;
1904                 esac
1905         ], [
1906                 ENABLEOSDADDON=0
1907         ])
1908 if test $ENABLEOSDADDON -eq 0; then
1909         AC_MSG_RESULT([no])
1910         OSDADDON=
1911 else
1912         OSDMODNAME=`basename $OSDADDON`
1913         if test -e $LUSTRE/$OSDMODNAME; then
1914                 AC_MSG_RESULT([can't link])
1915                 OSDADDON=
1916         elif ln -s $OSDADDON $LUSTRE/$OSDMODNAME; then
1917                 AC_MSG_RESULT([$OSDMODNAME])
1918                 OSDADDON="subdir-m += $OSDMODNAME"
1919         else
1920                 AC_MSG_RESULT([can't link])
1921                 OSDADDON=
1922         fi
1923 fi
1924 AC_SUBST(OSDADDON)
1925 ])
1926
1927 #
1928 # LC_CONFIGURE
1929 #
1930 # other configure checks
1931 #
1932 AC_DEFUN([LC_CONFIGURE],
1933 [LC_CONFIG_OBD_BUFFER_SIZE
1934
1935 if test $target_cpu == "i686" -o $target_cpu == "x86_64"; then
1936         CFLAGS="$CFLAGS -Werror"
1937 fi
1938
1939 # maximum MDS thread count
1940 LC_MDS_MAX_THREADS
1941
1942 # include/liblustre.h
1943 AC_CHECK_HEADERS([sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
1944
1945 # liblustre/llite_lib.h
1946 AC_CHECK_HEADERS([xtio.h file.h])
1947
1948 # liblustre/dir.c
1949 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
1950
1951 # liblustre/lutil.c
1952 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h catamount/data.h])
1953 AC_CHECK_FUNCS([inet_ntoa])
1954
1955 # libsysio/src/readlink.c
1956 LC_READLINK_SSIZE_T
1957
1958 # lvfs/prng.c - depends on linux/types.h from liblustre/dir.c
1959 AC_CHECK_HEADERS([linux/random.h], [], [],
1960                  [#ifdef HAVE_LINUX_TYPES_H
1961                   # include <linux/types.h>
1962                   #endif
1963                  ])
1964
1965 # utils/llverfs.c
1966 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
1967
1968 # check for -lz support
1969 ZLIB=""
1970 AC_CHECK_LIB([z],
1971              [adler32],
1972              [AC_CHECK_HEADERS([zlib.h],
1973                                [ZLIB="-lz"
1974                                 AC_DEFINE([HAVE_ADLER], 1,
1975                                           [support alder32 checksum type])],
1976                                [AC_MSG_WARN([No zlib-devel package found,
1977                                              unable to use adler32 checksum])])],
1978              [AC_MSG_WARN([No zlib package found, unable to use adler32 checksum])]
1979 )
1980 AC_SUBST(ZLIB)
1981
1982 SELINUX=""
1983 AC_CHECK_LIB([selinux],
1984                 [is_selinux_enabled],
1985                 [AC_CHECK_HEADERS([selinux.h],
1986                                 [SELINUX="-lselinux"
1987                                 AC_DEFINE([HAVE_SELINUX], 1,
1988                                                 [support for selinux ])],
1989                                 [AC_MSG_WARN([No selinux-devel package found,
1990                                                 unable to build selinux enabled
1991                                                 tools])])],
1992                 [AC_MSG_WARN([No selinux package found, unable to build selinux
1993                                 enabled tools])]
1994 )
1995 AC_SUBST(SELINUX)
1996
1997 # Super safe df
1998 AC_ARG_ENABLE([mindf],
1999       AC_HELP_STRING([--enable-mindf],
2000                       [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
2001       [],[])
2002 if test "$enable_mindf" = "yes" ;  then
2003       AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])
2004 fi
2005
2006 AC_ARG_ENABLE([fail_alloc],
2007         AC_HELP_STRING([--disable-fail-alloc],
2008                 [disable randomly alloc failure]),
2009         [],[enable_fail_alloc=yes])
2010 AC_MSG_CHECKING([whether to randomly failing memory alloc])
2011 AC_MSG_RESULT([$enable_fail_alloc])
2012 if test x$enable_fail_alloc != xno ; then
2013         AC_DEFINE([RANDOM_FAIL_ALLOC], 1, [enable randomly alloc failure])
2014 fi
2015
2016 AC_ARG_ENABLE([invariants],
2017         AC_HELP_STRING([--enable-invariants],
2018                 [enable invariant checking (cpu intensive)]),
2019         [],[])
2020 AC_MSG_CHECKING([whether to check invariants (expensive cpu-wise)])
2021 AC_MSG_RESULT([$enable_invariants])
2022 if test x$enable_invariants = xyes ; then
2023         AC_DEFINE([CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK], 1, [enable invariant checking])
2024 fi
2025
2026 AC_ARG_ENABLE([lu_ref],
2027         AC_HELP_STRING([--enable-lu_ref],
2028                 [enable lu_ref reference tracking code]),
2029         [],[])
2030 AC_MSG_CHECKING([whether to track references with lu_ref])
2031 AC_MSG_RESULT([$enable_lu_ref])
2032 if test x$enable_lu_ref = xyes ; then
2033         AC_DEFINE([USE_LU_REF], 1, [enable lu_ref reference tracking code])
2034 fi
2035
2036 AC_ARG_ENABLE([pgstate-track],
2037               AC_HELP_STRING([--enable-pgstate-track],
2038                              [enable page state tracking]),
2039               [enable_pgstat_track='yes'],[])
2040 AC_MSG_CHECKING([whether to enable page state tracking])
2041 AC_MSG_RESULT([$enable_pgstat_track])
2042 if test x$enable_pgstat_track = xyes ; then
2043         AC_DEFINE([CONFIG_DEBUG_PAGESTATE_TRACKING], 1,
2044                   [enable page state tracking code])
2045 fi
2046
2047          #2.6.29
2048          LC_BLKDEV_PUT_2ARGS
2049
2050 ])
2051
2052 #
2053 # LC_CONDITIONALS
2054 #
2055 # AM_CONDITIONALS for lustre
2056 #
2057 AC_DEFUN([LC_CONDITIONALS],
2058 [AM_CONDITIONAL(LIBLUSTRE, test x$enable_liblustre = xyes)
2059 AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
2060 AM_CONDITIONAL(LIBLUSTRE_TESTS, test x$enable_liblustre_tests = xyes)
2061 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
2062 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
2063 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
2064 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
2065 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
2066 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
2067 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
2068 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
2069 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
2070 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
2071 AM_CONDITIONAL(LLITE_LLOOP, test x$enable_llite_lloop_module = xyes)
2072 ])
2073
2074 #
2075 # LC_CONFIG_FILES
2076 #
2077 # files that should be generated with AC_OUTPUT
2078 #
2079 AC_DEFUN([LC_CONFIG_FILES],
2080 [AC_CONFIG_FILES([
2081 lustre/Makefile
2082 lustre/autoMakefile
2083 lustre/autoconf/Makefile
2084 lustre/conf/Makefile
2085 lustre/contrib/Makefile
2086 lustre/doc/Makefile
2087 lustre/include/Makefile
2088 lustre/include/lustre_ver.h
2089 lustre/include/linux/Makefile
2090 lustre/include/darwin/Makefile
2091 lustre/include/lustre/Makefile
2092 lustre/kernel_patches/targets/2.6-rhel6.target
2093 lustre/kernel_patches/targets/2.6-rhel5.target
2094 lustre/kernel_patches/targets/2.6-sles11.target
2095 lustre/kernel_patches/targets/3.0-sles11.target
2096 lustre/kernel_patches/targets/2.6-fc11.target
2097 lustre/kernel_patches/targets/2.6-fc12.target
2098 lustre/kernel_patches/targets/2.6-fc15.target
2099 lustre/kernel_patches/targets/3.x-fc18.target
2100 lustre/ldlm/Makefile
2101 lustre/fid/Makefile
2102 lustre/fid/autoMakefile
2103 lustre/liblustre/Makefile
2104 lustre/liblustre/tests/Makefile
2105 lustre/liblustre/tests/mpi/Makefile
2106 lustre/llite/Makefile
2107 lustre/llite/autoMakefile
2108 lustre/lclient/Makefile
2109 lustre/lov/Makefile
2110 lustre/lov/autoMakefile
2111 lustre/lvfs/Makefile
2112 lustre/lvfs/autoMakefile
2113 lustre/mdc/Makefile
2114 lustre/mdc/autoMakefile
2115 lustre/lmv/Makefile
2116 lustre/lmv/autoMakefile
2117 lustre/lfsck/Makefile
2118 lustre/lfsck/autoMakefile
2119 lustre/mdt/Makefile
2120 lustre/mdt/autoMakefile
2121 lustre/mdd/Makefile
2122 lustre/mdd/autoMakefile
2123 lustre/fld/Makefile
2124 lustre/fld/autoMakefile
2125 lustre/obdclass/Makefile
2126 lustre/obdclass/autoMakefile
2127 lustre/obdclass/linux/Makefile
2128 lustre/obdecho/Makefile
2129 lustre/obdecho/autoMakefile
2130 lustre/ofd/Makefile
2131 lustre/ofd/autoMakefile
2132 lustre/osc/Makefile
2133 lustre/osc/autoMakefile
2134 lustre/ost/Makefile
2135 lustre/ost/autoMakefile
2136 lustre/osd-ldiskfs/Makefile
2137 lustre/osd-ldiskfs/autoMakefile
2138 lustre/osd-zfs/Makefile
2139 lustre/osd-zfs/autoMakefile
2140 lustre/mgc/Makefile
2141 lustre/mgc/autoMakefile
2142 lustre/mgs/Makefile
2143 lustre/mgs/autoMakefile
2144 lustre/target/Makefile
2145 lustre/ptlrpc/Makefile
2146 lustre/ptlrpc/autoMakefile
2147 lustre/ptlrpc/gss/Makefile
2148 lustre/ptlrpc/gss/autoMakefile
2149 lustre/quota/Makefile
2150 lustre/quota/autoMakefile
2151 lustre/scripts/Makefile
2152 lustre/tests/Makefile
2153 lustre/tests/mpi/Makefile
2154 lustre/utils/Makefile
2155 lustre/utils/gss/Makefile
2156 lustre/osp/Makefile
2157 lustre/osp/autoMakefile
2158 lustre/lod/Makefile
2159 lustre/lod/autoMakefile
2160 lustre/obdclass/darwin/Makefile
2161 ])
2162 ])