Whamcloud - gitweb
LU-3079 kernel: 3.9 hlist_for_each_entry uses 3 args
[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 # 2.6.19
400
401 # LC_FILE_WRITEV
402 # 2.6.19 replaced writev with aio_write
403 AC_DEFUN([LC_FILE_WRITEV],
404 [AC_MSG_CHECKING([writev in fops])
405 LB_LINUX_TRY_COMPILE([
406         #include <linux/fs.h>
407 ],[
408         struct file_operations *fops = NULL;
409         fops->writev = NULL;
410 ],[
411         AC_MSG_RESULT(yes)
412         AC_DEFINE(HAVE_FILE_WRITEV, 1,
413                 [use fops->writev])
414 ],[
415         AC_MSG_RESULT(no)
416 ])
417 ])
418
419 # LC_FILE_READV
420 # 2.6.19 replaced readv with aio_read
421 AC_DEFUN([LC_FILE_READV],
422 [AC_MSG_CHECKING([readv in fops])
423 LB_LINUX_TRY_COMPILE([
424         #include <linux/fs.h>
425 ],[
426         struct file_operations *fops = NULL;
427         fops->readv = NULL;
428 ],[
429         AC_MSG_RESULT(yes)
430         AC_DEFINE(HAVE_FILE_READV, 1,
431                 [use fops->readv])
432 ],[
433         AC_MSG_RESULT(no)
434 ])
435 ])
436
437 # raid5-zerocopy patch
438
439 #
440 # LC_PAGE_CONSTANT
441 #
442 # In order to support raid5 zerocopy patch, we have to patch the kernel to make
443 # it support constant page, which means the page won't be modified during the
444 # IO.
445 #
446 AC_DEFUN([LC_PAGE_CONSTANT],
447 [AC_MSG_CHECKING([if kernel have PageConstant defined])
448 LB_LINUX_TRY_COMPILE([
449         #include <linux/mm.h>
450         #include <linux/page-flags.h>
451 ],[
452         #ifndef PG_constant
453         #error "Have no raid5 zcopy patch"
454         #endif
455 ],[
456         AC_MSG_RESULT(yes)
457         AC_DEFINE(HAVE_PAGE_CONSTANT, 1, [kernel have PageConstant supported])
458 ],[
459         AC_MSG_RESULT(no);
460 ])
461 ])
462
463 # 2.6.22
464
465 # 2.6.22 lost second parameter for invalidate_bdev
466 AC_DEFUN([LC_INVALIDATE_BDEV_2ARG],
467 [AC_MSG_CHECKING([if invalidate_bdev has second argument])
468 LB_LINUX_TRY_COMPILE([
469         #include <linux/buffer_head.h>
470 ],[
471         invalidate_bdev(NULL,0);
472 ],[
473         AC_MSG_RESULT([yes])
474         AC_DEFINE(HAVE_INVALIDATE_BDEV_2ARG, 1,
475                 [invalidate_bdev has second argument])
476 ],[
477         AC_MSG_RESULT([no])
478 ])
479 ])
480
481 #
482 # 2.6.19 check for FS_RENAME_DOES_D_MOVE flag
483 #
484 AC_DEFUN([LC_FS_RENAME_DOES_D_MOVE],
485 [AC_MSG_CHECKING([if kernel has FS_RENAME_DOES_D_MOVE flag])
486 LB_LINUX_TRY_COMPILE([
487         #include <linux/fs.h>
488 ],[
489         int v __attribute__ ((unused));
490         v = FS_RENAME_DOES_D_MOVE;
491 ],[
492         AC_MSG_RESULT([yes])
493         AC_DEFINE(HAVE_FS_RENAME_DOES_D_MOVE, 1, [kernel has FS_RENAME_DOES_D_MOVE flag])
494 ],[
495         AC_MSG_RESULT([no])
496 ])
497 ])
498
499 # 2.6.23
500
501 # 2.6.23 have return type 'void' for unregister_blkdev
502 AC_DEFUN([LC_UNREGISTER_BLKDEV_RETURN_INT],
503 [AC_MSG_CHECKING([if unregister_blkdev return int])
504 LB_LINUX_TRY_COMPILE([
505         #include <linux/fs.h>
506 ],[
507         int i __attribute__ ((unused));
508         i = unregister_blkdev(0,NULL);
509 ],[
510         AC_MSG_RESULT([yes])
511         AC_DEFINE(HAVE_UNREGISTER_BLKDEV_RETURN_INT, 1,
512                 [unregister_blkdev return int])
513 ],[
514         AC_MSG_RESULT([no])
515 ])
516 ])
517
518 # 2.6.23 add code to wait other users to complete before removing procfs entry
519 AC_DEFUN([LC_PROCFS_USERS],
520 [AC_MSG_CHECKING([if kernel has pde_users member in procfs entry struct])
521 LB_LINUX_TRY_COMPILE([
522         #include <linux/proc_fs.h>
523 ],[
524         struct proc_dir_entry pde;
525
526         pde.pde_users   = 0;
527 ],[
528         AC_MSG_RESULT([yes])
529         AC_DEFINE(HAVE_PROCFS_USERS, 1,
530                 [kernel has pde_users member in procfs entry struct])
531 ],[
532         LB_LINUX_TRY_COMPILE([
533                 #include "$LINUX/fs/proc/internal.h"
534         ],[
535                 struct proc_dir_entry_aux pde_aux;
536
537                 pde_aux.pde_users = 0;
538         ],[
539                 AC_MSG_RESULT([yes])
540                 AC_DEFINE(HAVE_PROCFS_USERS, 1,
541                         [kernel has pde_users member in proc_dir_entry_aux])
542         ],[
543                 AC_MSG_RESULT([no])
544         ])
545 ])
546 ])
547
548 # 2.6.24
549
550 # 2.6.24 has bio_endio with 2 args
551 AC_DEFUN([LC_BIO_ENDIO_2ARG],
552 [AC_MSG_CHECKING([if kernel has bio_endio with 2 args])
553 LB_LINUX_TRY_COMPILE([
554         #include <linux/bio.h>
555 ],[
556         bio_endio(NULL, 0);
557 ], [
558         AC_MSG_RESULT([yes])
559         AC_DEFINE(HAVE_BIO_ENDIO_2ARG, 1,
560                 [kernel has bio_endio with 2 args])
561 ],[
562         AC_MSG_RESULT([no])
563 ])
564 ])
565
566 # 2.6.24 removes long aged procfs entry -> deleted member
567 AC_DEFUN([LC_PROCFS_DELETED],
568 [AC_MSG_CHECKING([if kernel has deleted member in procfs entry struct])
569 LB_LINUX_TRY_COMPILE([
570         #include <linux/proc_fs.h>
571 ],[
572         struct proc_dir_entry pde;
573
574         pde.deleted = sizeof(pde);
575 ], [
576         AC_MSG_RESULT([yes])
577         AC_DEFINE(HAVE_PROCFS_DELETED, 1,
578                 [kernel has deleted member in procfs entry struct])
579 ],[
580         AC_MSG_RESULT([no])
581 ])
582 ])
583
584 # 2.6.26
585
586 # 2.6.26 isn't export set_fs_pwd and change paramter in fs struct
587 AC_DEFUN([LC_FS_STRUCT_USE_PATH],
588 [AC_MSG_CHECKING([fs_struct use path structure])
589 LB_LINUX_TRY_COMPILE([
590         #include <asm/atomic.h>
591         #include <linux/spinlock.h>
592         #include <linux/fs_struct.h>
593 ],[
594         struct fs_struct fs;
595
596         fs.pwd = *((struct path *)sizeof(fs));
597 ], [
598         AC_MSG_RESULT([yes])
599         AC_DEFINE(HAVE_FS_STRUCT_USE_PATH, 1,
600                 [fs_struct use path structure])
601 ],[
602         AC_MSG_RESULT([no])
603 ])
604 ])
605
606 #
607 # 2.6.27
608 #
609
610 # LC_SECURITY_PLUG  # for SLES10 SP2 (2.6.27)
611 # check security plug in sles10 sp2 kernel
612 AC_DEFUN([LC_SECURITY_PLUG],
613 [AC_MSG_CHECKING([If kernel has security plug support])
614 LB_LINUX_TRY_COMPILE([
615         #include <linux/fs.h>
616         #include <linux/stddef.h>
617 ],[
618         notify_change(NULL, NULL, NULL);
619 ],[
620         AC_MSG_RESULT(yes)
621         AC_DEFINE(HAVE_SECURITY_PLUG, 1,
622                 [SLES10 SP2 use extra parameter in vfs])
623 ],[
624         AC_MSG_RESULT(no)
625 ])
626 ])
627
628 AC_DEFUN([LC_INODE_PERMISION_2ARGS],
629 [AC_MSG_CHECKING([inode_operations->permission has two args])
630 LB_LINUX_TRY_COMPILE([
631         #include <linux/fs.h>
632 ],[
633         struct inode *inode __attribute__ ((unused));
634
635         inode = NULL;
636         inode->i_op->permission(NULL, 0);
637 ],[
638         AC_DEFINE(HAVE_INODE_PERMISION_2ARGS, 1,
639                   [inode_operations->permission has two args])
640         AC_MSG_RESULT([yes])
641 ],[
642         AC_MSG_RESULT([no])
643 ])
644 ])
645
646 # 2.6.27 use 5th parameter in quota_on for remount.
647 AC_DEFUN([LC_QUOTA_ON_5ARGS],
648 [AC_MSG_CHECKING([quota_on needs 5 parameters])
649 LB_LINUX_TRY_COMPILE([
650         #include <linux/fs.h>
651         #include <linux/quota.h>
652 ],[
653         struct quotactl_ops *qop = NULL;
654         qop->quota_on(NULL, 0, 0, NULL, 0);
655 ],[
656         AC_DEFINE(HAVE_QUOTA_ON_5ARGS, 1,
657                 [quota_on needs 5 paramters])
658         AC_MSG_RESULT([yes])
659 ],[
660         AC_MSG_RESULT([no])
661 ])
662 ])
663
664 # 2.6.27 use 3th parameter in quota_off for remount.
665 AC_DEFUN([LC_QUOTA_OFF_3ARGS],
666 [AC_MSG_CHECKING([quota_off needs 3 parameters])
667 LB_LINUX_TRY_COMPILE([
668         #include <linux/fs.h>
669         #include <linux/quota.h>
670 ],[
671         struct quotactl_ops *qop = NULL;
672         qop->quota_off(NULL, 0, 0);
673 ],[
674         AC_DEFINE(HAVE_QUOTA_OFF_3ARGS, 1,
675                 [quota_off needs 3 paramters])
676         AC_MSG_RESULT([yes])
677 ],[
678         AC_MSG_RESULT([no])
679 ])
680 ])
681
682 # 2.6.34 has quotactl_ops->[sg]et_dqblk that take struct fs_disk_quota
683 AC_DEFUN([LC_HAVE_DQUOT_FS_DISK_QUOTA],
684 tmp_flags="$EXTRA_KCFLAGS"
685 EXTRA_KCFLAGS="-Werror"
686 [AC_MSG_CHECKING([if quotactl_ops.set_dqblk takes struct fs_disk_quota])
687 LB_LINUX_TRY_COMPILE([
688         #include <linux/fs.h>
689         #include <linux/quota.h>
690 ],[
691         struct quotactl_ops qops = {};
692         struct fs_disk_quota fdq;
693         qops.set_dqblk(NULL, 0, 0, &fdq);
694 ],[
695         AC_DEFINE(HAVE_DQUOT_FS_DISK_QUOTA, 1, [quotactl_ops.set_dqblk takes struct fs_disk_quota])
696         AC_MSG_RESULT([yes])
697 ],[
698         AC_MSG_RESULT([no])
699 ])
700 EXTRA_KCFLAGS="$tmp_flags"
701 ])
702
703 # 2.6.34 has renamed dquot options to dquot_*, check for dquot_suspend
704 AC_DEFUN([LC_HAVE_DQUOT_SUSPEND],
705 [AC_MSG_CHECKING([if dquot_suspend is defined])
706 LB_LINUX_TRY_COMPILE([
707         #include <linux/quotaops.h>
708 ],[
709         dquot_suspend(NULL, -1);
710 ],[
711         AC_DEFINE(HAVE_DQUOT_SUSPEND, 1, [dquot_suspend is defined])
712         AC_MSG_RESULT([yes])
713 ],[
714         AC_MSG_RESULT([no])
715 ])
716 ])
717
718 # LC_LOCK_MAP_ACQUIRE
719 # after 2.6.27 lock_map_acquire replaces lock_acquire
720 AC_DEFUN([LC_LOCK_MAP_ACQUIRE],
721 [AC_MSG_CHECKING([if lock_map_acquire is defined])
722 LB_LINUX_TRY_COMPILE([
723         #include <linux/lockdep.h>
724 ],[
725         lock_map_acquire(NULL);
726 ],[
727         AC_MSG_RESULT(yes)
728         AC_DEFINE(HAVE_LOCK_MAP_ACQUIRE, 1,
729                 [lock_map_acquire is defined])
730 ],[
731         AC_MSG_RESULT(no)
732 ])
733 ])
734
735 # 2.6.27.15-2 sles11
736
737 # 2.6.27 sles11 remove the bi_hw_segments
738 AC_DEFUN([LC_BI_HW_SEGMENTS],
739 [AC_MSG_CHECKING([struct bio has a bi_hw_segments field])
740 LB_LINUX_TRY_COMPILE([
741         #include <linux/bio.h>
742 ],[
743         struct bio io;
744         io.bi_hw_segments = sizeof(io);
745 ],[
746         AC_DEFINE(HAVE_BI_HW_SEGMENTS, 1,
747                 [struct bio has a bi_hw_segments field])
748         AC_MSG_RESULT([yes])
749 ],[
750         AC_MSG_RESULT([no])
751 ])
752 ])
753
754 #
755 # 2.6.27 sles11 move the quotaio_v1{2}.h from include/linux to fs
756 # 2.6.32 move the quotaio_v1{2}.h from fs to fs/quota
757 AC_DEFUN([LC_HAVE_QUOTAIO_H],
758 [LB_CHECK_FILE([$LINUX/include/linux/quotaio_v2.h],[
759         AC_DEFINE(HAVE_QUOTAIO_H, 1,
760                 [kernel has include/linux/quotaio_v2.h])
761 ],[LB_CHECK_FILE([$LINUX/fs/quotaio_v2.h],[
762                AC_DEFINE(HAVE_FS_QUOTAIO_H, 1,
763                 [kernel has fs/quotaio_v1.h])
764 ],[LB_CHECK_FILE([$LINUX/fs/quota/quotaio_v2.h],[
765                AC_DEFINE(HAVE_FS_QUOTA_QUOTAIO_H, 1,
766                 [kernel has fs/quota/quotaio_v2.h])
767 ],[
768         AC_MSG_RESULT([no])
769 ])
770 ])
771 ])
772 ])
773
774 # 2.6.32
775
776 # 2.6.32 replaces 2 functions blk_queue_max_phys_segments and blk_queue_max_hw_segments by blk_queue_max_segments
777 AC_DEFUN([LC_BLK_QUEUE_MAX_SEGMENTS],
778 [AC_MSG_CHECKING([if blk_queue_max_segments is defined])
779 LB_LINUX_TRY_COMPILE([
780         #include <linux/blkdev.h>
781 ],[
782         blk_queue_max_segments(NULL, 0);
783 ],[
784         AC_MSG_RESULT(yes)
785         AC_DEFINE(HAVE_BLK_QUEUE_MAX_SEGMENTS, 1,
786                   [blk_queue_max_segments is defined])
787 ],[
788         AC_MSG_RESULT(no)
789 ])
790 ])
791
792 #
793 # LC_QUOTA64
794 #
795 # Check if kernel has been patched for 64-bit quota limits support.
796 # The upstream version of this patch in RHEL6 2.6.32 kernels introduces
797 # the constant QFMT_VFS_V1 in include/linux/quota.h, so we can check for
798 # that in the absence of quotaio_v1.h in the kernel headers.
799 #
800 AC_DEFUN([LC_QUOTA64],[
801         AC_MSG_CHECKING([if kernel has 64-bit quota limits support])
802 tmp_flags="$EXTRA_KCFLAGS"
803 EXTRA_KCFLAGS="-I$LINUX/fs"
804         LB_LINUX_TRY_COMPILE([
805                 #include <linux/kernel.h>
806                 #include <linux/fs.h>
807                 #if defined(HAVE_FS_QUOTA_QUOTAIO_H)
808                 # include <quota/quotaio_v2.h>
809                 struct v2r1_disk_dqblk dqblk_r1;
810                 #else
811                 #include <linux/quota.h>
812                 int ver = QFMT_VFS_V1;
813                 #endif
814         ],[],[
815                 AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
816                 AC_MSG_RESULT([yes])
817         ],[
818                 LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
819                         AC_MSG_ERROR([You have got no 64-bit kernel quota support.])
820                 ],[])
821                 AC_MSG_RESULT([no])
822         ])
823 EXTRA_KCFLAGS=$tmp_flags
824 ])
825
826 # 2.6.32 set_cpus_allowed is no more defined if CONFIG_CPUMASK_OFFSTACK=yes
827 AC_DEFUN([LC_SET_CPUS_ALLOWED],
828          [AC_MSG_CHECKING([if kernel defines set_cpus_allowed])
829           LB_LINUX_TRY_COMPILE(
830                 [#include <linux/sched.h>],
831                 [struct task_struct *p = NULL;
832                  cpumask_t mask = { { 0 } };
833                  (void) set_cpus_allowed(p, mask);],
834                 [AC_MSG_RESULT([yes])
835                  AC_DEFINE(HAVE_SET_CPUS_ALLOWED, 1,
836                            [set_cpus_allowed is exported by the kernel])],
837                 [AC_MSG_RESULT([no])] )])
838
839 #
840 # 2.6.36 fs_struct.lock use spinlock instead of rwlock.
841 #
842 AC_DEFUN([LC_FS_STRUCT_RWLOCK],
843 [AC_MSG_CHECKING([if fs_struct.lock use rwlock])
844 LB_LINUX_TRY_COMPILE([
845         #include <asm/atomic.h>
846         #include <linux/spinlock.h>
847         #include <linux/fs_struct.h>
848 ],[
849         ((struct fs_struct *)0)->lock = (rwlock_t){ 0 };
850 ],[
851         AC_DEFINE(HAVE_FS_STRUCT_RWLOCK, 1,
852                   [fs_struct.lock use rwlock])
853         AC_MSG_RESULT([yes])
854 ],[
855         AC_MSG_RESULT([no])
856 ])
857 ])
858
859 #
860 # 2.6.36 super_operations add evict_inode method. it hybird of
861 # delete_inode & clear_inode.
862 #
863 AC_DEFUN([LC_SBOPS_EVICT_INODE],
864 [AC_MSG_CHECKING([if super_operations.evict_inode exist])
865 LB_LINUX_TRY_COMPILE([
866         #include <linux/fs.h>
867 ],[
868         ((struct super_operations *)0)->evict_inode(NULL);
869 ],[
870         AC_DEFINE(HAVE_SBOPS_EVICT_INODE, 1,
871                 [super_operations.evict_inode() is exist in kernel])
872         AC_MSG_RESULT([yes])
873 ],[
874         AC_MSG_RESULT([no])
875 ])
876 ])
877
878 #
879 # 2.6.35 file_operations.fsync taken 2 arguments.
880 # 3.0.0 file_operations.fsync takes 4 arguments.
881 #
882 AC_DEFUN([LC_FILE_FSYNC],
883 [AC_MSG_CHECKING([if file_operations.fsync takes 4 or 2 arguments])
884 LB_LINUX_TRY_COMPILE([
885         #include <linux/fs.h>
886 ],[
887         ((struct file_operations *)0)->fsync(NULL, 0, 0, 0);
888 ],[
889         AC_DEFINE(HAVE_FILE_FSYNC_4ARGS, 1,
890                 [file_operations.fsync takes 4 arguments])
891         AC_MSG_RESULT([yes, 4 args])
892 ],[
893         LB_LINUX_TRY_COMPILE([
894                 #include <linux/fs.h>
895         ],[
896            ((struct file_operations *)0)->fsync(NULL, 0);
897         ],[
898                 AC_DEFINE(HAVE_FILE_FSYNC_2ARGS, 1,
899                         [file_operations.fsync takes 2 arguments])
900                 AC_MSG_RESULT([yes, 2 args])
901         ],[
902                 AC_MSG_RESULT([no])
903         ])
904 ])
905 ])
906
907 #
908 # 2.6.37 remove kernel_locked
909 #
910 AC_DEFUN([LC_KERNEL_LOCKED],
911 [AC_MSG_CHECKING([if kernel_locked is defined])
912 LB_LINUX_TRY_COMPILE([
913         #include <linux/smp_lock.h>
914 ],[
915         kernel_locked();
916 ],[
917         AC_MSG_RESULT([yes])
918         AC_DEFINE(HAVE_KERNEL_LOCKED, 1,
919                 [kernel_locked is defined])
920 ],[
921         AC_MSG_RESULT([no])
922 ])
923 ])
924
925 #
926 # 2.6.38 dentry_operations.d_compare() taken 7 arguments.
927 #
928 AC_DEFUN([LC_D_COMPARE_7ARGS],
929 [AC_MSG_CHECKING([if d_compare taken 7 arguments])
930 LB_LINUX_TRY_COMPILE([
931         #include <linux/dcache.h>
932 ],[
933         ((struct dentry_operations*)0)->d_compare(NULL,NULL,NULL,NULL,0,NULL,NULL);
934 ],[
935         AC_DEFINE(HAVE_D_COMPARE_7ARGS, 1,
936                 [d_compare need 7 arguments])
937         AC_MSG_RESULT([yes])
938 ],[
939         AC_MSG_RESULT([no])
940 ])
941 ])
942
943 #
944 # 2.6.38 dentry_operations.d_delete() defined 'const' for 1st parameter.
945 #
946 AC_DEFUN([LC_D_DELETE_CONST],
947 [AC_MSG_CHECKING([if d_delete has const declare on first parameter])
948 tmp_flags="$EXTRA_KCFLAGS"
949 EXTRA_KCFLAGS="-Werror"
950 LB_LINUX_TRY_COMPILE([
951         #include <linux/dcache.h>
952 ],[
953         const struct dentry *d = NULL;
954         ((struct dentry_operations*)0)->d_delete(d);
955 ],[
956         AC_DEFINE(HAVE_D_DELETE_CONST, const,
957                 [d_delete first parameter declared const])
958         AC_MSG_RESULT([yes])
959 ],[
960         AC_DEFINE(HAVE_D_DELETE_CONST, , [])
961         AC_MSG_RESULT([no])
962 ])
963 EXTRA_KCFLAGS="$tmp_flags"
964 ])
965
966 #
967 # 2.6.38 dcache_lock removed. rcu-walk commited.
968 #
969 AC_DEFUN([LC_DCACHE_LOCK],
970 [AC_MSG_CHECKING([if dcache_lock is exist])
971 LB_LINUX_TRY_COMPILE([
972         #include <linux/dcache.h>
973 ],[
974         spin_lock(&dcache_lock);
975 ],[
976         AC_DEFINE(HAVE_DCACHE_LOCK, 1,
977                 [dcache_lock is exist])
978         AC_MSG_RESULT([yes])
979 ],[
980         AC_MSG_RESULT([no])
981 ])
982 ])
983
984 #
985 # 2.6.38 inode.i_rcu added.
986 #
987 AC_DEFUN([LC_INODE_I_RCU],
988 [AC_MSG_CHECKING([if inode.i_rcu exists])
989 LB_LINUX_TRY_COMPILE([
990         #include <linux/fs.h>
991 ],[
992         struct inode ino;
993         struct rcu_head rcu = {};
994         ino.i_rcu = rcu;
995 ],[
996         AC_DEFINE(HAVE_INODE_I_RCU, 1,
997                 [inode.i_rcu exists])
998         AC_MSG_RESULT([yes])
999 ],[
1000         AC_MSG_RESULT([no])
1001 ])
1002 ])
1003
1004 #
1005 # 2.6.38 export blkdev_get_by_dev
1006 #
1007 AC_DEFUN([LC_BLKDEV_GET_BY_DEV],
1008 [LB_CHECK_SYMBOL_EXPORT([blkdev_get_by_dev],
1009 [fs/block_dev.c],[
1010 AC_DEFINE(HAVE_BLKDEV_GET_BY_DEV, 1,
1011             [blkdev_get_by_dev is exported by the kernel])
1012 ],[
1013 ])
1014 ])
1015
1016 #
1017 # 2.6.38 use path as 4th parameter in quota_on.
1018 #
1019 AC_DEFUN([LC_QUOTA_ON_USE_PATH],
1020 [AC_MSG_CHECKING([quota_on use path as parameter])
1021 tmp_flags="$EXTRA_KCFLAGS"
1022 EXTRA_KCFLAGS="-Werror"
1023 LB_LINUX_TRY_COMPILE([
1024         #include <linux/fs.h>
1025         #include <linux/quota.h>
1026 ],[
1027         ((struct quotactl_ops *)0)->quota_on(NULL, 0, 0, ((struct path*)0));
1028 ],[
1029         AC_DEFINE(HAVE_QUOTA_ON_USE_PATH, 1,
1030                 [quota_on use path as 4th paramter])
1031         AC_MSG_RESULT([yes])
1032 ],[
1033         AC_MSG_RESULT([no])
1034 ])
1035 EXTRA_KCFLAGS="$tmp_flags"
1036 ])
1037
1038 #
1039 # 2.6.38 export simple_setattr
1040 #
1041 AC_DEFUN([LC_EXPORT_SIMPLE_SETATTR],
1042 [LB_CHECK_SYMBOL_EXPORT([simple_setattr],
1043 [fs/libfs.c],[
1044 AC_DEFINE(HAVE_SIMPLE_SETATTR, 1,
1045             [simple_setattr is exported by the kernel])
1046 ],[
1047 ])
1048 ])
1049
1050 #
1051 # 2.6.39 remove unplug_fn from request_queue.
1052 #
1053 AC_DEFUN([LC_REQUEST_QUEUE_UNPLUG_FN],
1054 [AC_MSG_CHECKING([if request_queue has unplug_fn field])
1055 LB_LINUX_TRY_COMPILE([
1056         #include <linux/blkdev.h>
1057 ],[
1058         do{ }while(sizeof(((struct request_queue *)0)->unplug_fn));
1059 ],[
1060         AC_DEFINE(HAVE_REQUEST_QUEUE_UNPLUG_FN, 1,
1061                   [request_queue has unplug_fn field])
1062         AC_MSG_RESULT([yes])
1063 ],[
1064         AC_MSG_RESULT([no])
1065 ])
1066 ])
1067
1068 #
1069 # 2.6.39 replace get_sb with mount in struct file_system_type
1070 #
1071 AC_DEFUN([LC_HAVE_FSTYPE_MOUNT],
1072 [AC_MSG_CHECKING([if file_system_type has mount field])
1073 LB_LINUX_TRY_COMPILE([
1074         #include <linux/fs.h>
1075 ],[
1076         struct file_system_type fst;
1077         void *i = (void *) fst.mount;
1078 ],[
1079         AC_DEFINE(HAVE_FSTYPE_MOUNT, 1,
1080                 [struct file_system_type has mount field])
1081         AC_MSG_RESULT([yes])
1082 ],[
1083         AC_MSG_RESULT([no])
1084 ])
1085 ])
1086
1087 #
1088 # 3.0 dirty_inode() has a flag parameter
1089 # see kernel commit aa38572954ade525817fe88c54faebf85e5a61c0
1090 #
1091 AC_DEFUN([LC_DIRTY_INODE_WITH_FLAG],
1092 [AC_MSG_CHECKING([if dirty_inode super_operation takes flag])
1093 LB_LINUX_TRY_COMPILE([
1094         #include <linux/fs.h>
1095 ],[
1096         struct inode *inode;
1097         inode->i_sb->s_op->dirty_inode(NULL, 0);
1098 ],[
1099         AC_DEFINE(HAVE_DIRTY_INODE_HAS_FLAG, 1,
1100                   [dirty_inode super_operation takes flag])
1101         AC_MSG_RESULT([yes])
1102 ],[
1103         AC_MSG_RESULT([no])
1104 ])
1105 ])
1106
1107 #
1108 # 2.6.38 generic_permission taken 4 parameters.
1109 # in fact, it means rcu-walk aware permission bring.
1110 #
1111 # 3.1 generic_permission taken 2 parameters.
1112 # see kernel commit 2830ba7f34ebb27c4e5b8b6ef408cd6d74860890
1113 #
1114 AC_DEFUN([LC_GENERIC_PERMISSION],
1115 [AC_MSG_CHECKING([if generic_permission take 2 or 4 arguments])
1116 LB_LINUX_TRY_COMPILE([
1117         #include <linux/fs.h>
1118 ],[
1119         generic_permission(NULL, 0);
1120 ],[
1121         AC_DEFINE(HAVE_GENERIC_PERMISSION_2ARGS, 1,
1122                   [generic_permission taken 2 arguments])
1123         AC_MSG_RESULT([yes, 2 args])
1124 ],[
1125         LB_LINUX_TRY_COMPILE([
1126                 #include <linux/fs.h>
1127         ],[
1128                 generic_permission(NULL, 0, 0, NULL);
1129         ],[
1130                 AC_DEFINE(HAVE_GENERIC_PERMISSION_4ARGS, 1,
1131                           [generic_permission taken 4 arguments])
1132                 AC_MSG_RESULT([yes, 4 args])
1133         ],[
1134                 AC_MSG_RESULT([no])
1135         ])
1136 ])
1137 ])
1138
1139 #
1140 # 3.1 renames lock-manager ops(lock_manager_operations) from fl_xxx to lm_xxx
1141 # see kernel commit 8fb47a4fbf858a164e973b8ea8ef5e83e61f2e50
1142 #
1143 AC_DEFUN([LC_LM_XXX_LOCK_MANAGER_OPS],
1144 [AC_MSG_CHECKING([if lock-manager ops renamed to lm_xxx])
1145 LB_LINUX_TRY_COMPILE([
1146         #include <linux/fs.h>
1147 ],[
1148         struct lock_manager_operations lm_ops;
1149         lm_ops.lm_compare_owner = NULL;
1150 ],[
1151         AC_DEFINE(HAVE_LM_XXX_LOCK_MANAGER_OPS, 1,
1152                   [lock-manager ops renamed to lm_xxx])
1153         AC_MSG_RESULT([yes])
1154 ],[
1155         AC_MSG_RESULT([no])
1156 ])
1157 ])
1158
1159 #
1160 # 3.1 kills inode->i_alloc_sem, use i_dio_count and inode_dio_wait/
1161 #     inode_dio_done instead.
1162 # see kernel commit bd5fe6c5eb9c548d7f07fe8f89a150bb6705e8e3
1163 #
1164 AC_DEFUN([LC_INODE_DIO_WAIT],
1165 [AC_MSG_CHECKING([if inode->i_alloc_sem is killed and use inode_dio_wait/done.])
1166 LB_LINUX_TRY_COMPILE([
1167         #include <linux/fs.h>
1168 ],[
1169         inode_dio_wait((struct inode *)0);
1170         inode_dio_done((struct inode *)0);
1171 ],[
1172         AC_DEFINE(HAVE_INODE_DIO_WAIT, 1,
1173                   [inode->i_alloc_sem is killed and use inode_dio_wait/done])
1174         AC_MSG_RESULT([yes])
1175 ],[
1176         AC_MSG_RESULT([no])
1177 ])
1178 ])
1179
1180 #
1181 # 3.1 adds get_acl method to inode_operations to read ACL from disk.
1182 # see kernel commit 4e34e719e457f2e031297175410fc0bd4016a085
1183 #
1184 AC_DEFUN([LC_IOP_GET_ACL],
1185 [AC_MSG_CHECKING([inode_operations has .get_acl member function])
1186 LB_LINUX_TRY_COMPILE([
1187         #include <linux/fs.h>
1188 ],[
1189         struct inode_operations iop;
1190         iop.get_acl = NULL;
1191 ],[
1192         AC_DEFINE(HAVE_IOP_GET_ACL, 1,
1193                   [inode_operations has .get_acl member function])
1194         AC_MSG_RESULT([yes])
1195 ],[
1196         AC_MSG_RESULT([no])
1197 ])
1198 ])
1199
1200 #
1201 # 3.1.1 has ext4_blocks_for_truncate
1202 #
1203 AC_DEFUN([LC_BLOCKS_FOR_TRUNCATE],
1204 [AC_MSG_CHECKING([if kernel has ext4_blocks_for_truncate])
1205 LB_LINUX_TRY_COMPILE([
1206         #include <linux/fs.h>
1207         #include "$LINUX/fs/ext4/ext4_jbd2.h"
1208         #include "$LINUX/fs/ext4/truncate.h"
1209 ],[
1210         ext4_blocks_for_truncate(NULL);
1211 ],[
1212         AC_MSG_RESULT([yes])
1213         AC_DEFINE(HAVE_BLOCKS_FOR_TRUNCATE, 1,
1214                   [kernel has ext4_blocks_for_truncate])
1215 ],[
1216         AC_MSG_RESULT([no])
1217 ])
1218 ])
1219
1220 #
1221 # 3.1 introduced generic_file_llseek_size()
1222 #
1223 AC_DEFUN([LC_FILE_LLSEEK_SIZE],
1224         [LB_CHECK_SYMBOL_EXPORT([generic_file_llseek_size],
1225         [fs/read_write.c],
1226         [AC_DEFINE(HAVE_FILE_LLSEEK_SIZE, 1,
1227                    [generic_file_llseek_size is exported by the kernel])])
1228 ])
1229
1230 #
1231 # 3.2 request_queue.make_request_fn defined as function returns with void
1232 # see kernel commit 5a7bbad27a410350e64a2d7f5ec18fc73836c14f
1233 #
1234 AC_DEFUN([LC_HAVE_VOID_MAKE_REQUEST_FN],
1235 [AC_MSG_CHECKING([if request_queue.make_request_fn returns void but not int])
1236 LB_LINUX_TRY_COMPILE([
1237         #include <linux/blkdev.h>
1238 ],[
1239         int ret;
1240         make_request_fn         *mrf;
1241         ret = mrf(NULL, NULL);
1242 ],[
1243         AC_MSG_RESULT([no])
1244 ],[
1245         AC_DEFINE(HAVE_VOID_MAKE_REQUEST_FN, 1,
1246                   [request_queue.make_request_fn returns void but not int])
1247         AC_MSG_RESULT([yes])
1248 ])
1249 ])
1250
1251 #
1252 # 3.2 protects inode->i_nlink from direct modification
1253 # see kernel commit a78ef704a8dd430225955f0709b22d4a6ba21deb
1254 # at the same time adds set_nlink(), so checks set_nlink() for it.
1255 #
1256 AC_DEFUN([LC_HAVE_PROTECT_I_NLINK],
1257 [AC_MSG_CHECKING([if inode->i_nlink is protected from direct modification])
1258 LB_LINUX_TRY_COMPILE([
1259         #include <linux/fs.h>
1260 ],[
1261         struct inode i;
1262         set_nlink(&i, 1);
1263 ],[
1264         AC_DEFINE(HAVE_PROTECT_I_NLINK, 1,
1265                   [inode->i_nlink is protected from direct modification])
1266         AC_MSG_RESULT([yes])
1267 ],[
1268         AC_MSG_RESULT([no])
1269 ])
1270 ])
1271
1272 #
1273 # 3.3 introduces migrate_mode.h and migratepage has 4 args
1274 #
1275 AC_DEFUN([LC_HAVE_MIGRATE_HEADER],
1276 [LB_CHECK_FILE([$LINUX/include/linux/migrate.h],[
1277                 AC_DEFINE(HAVE_MIGRATE_H, 1,
1278                 [kernel has include/linux/migrate.h])
1279 ],[LB_CHECK_FILE([$LINUX/include/linux/migrate_mode.h],[
1280                 AC_DEFINE(HAVE_MIGRATE_MODE_H, 1,
1281                         [kernel has include/linux/migrate_mode.h])
1282 ],[
1283         AC_MSG_RESULT([no])
1284 ])
1285 ])
1286 ])
1287
1288 AC_DEFUN([LC_MIGRATEPAGE_4ARGS],
1289 [AC_MSG_CHECKING([if address_space_operations.migratepage has 4 args])
1290 LB_LINUX_TRY_COMPILE([
1291         #include <linux/fs.h>
1292 #ifdef HAVE_MIGRATE_H
1293         #include <linux/migrate.h>
1294 #elif defined(HAVE_MIGRATE_MODE_H)
1295         #include <linux/migrate_mode.h>
1296 #endif
1297 ],[
1298         struct address_space_operations aops;
1299
1300         aops.migratepage(NULL, NULL, NULL, MIGRATE_ASYNC);
1301 ],[
1302         AC_DEFINE(HAVE_MIGRATEPAGE_4ARGS, 1,
1303                 [address_space_operations.migratepage has 4 args])
1304         AC_MSG_RESULT([yes])
1305 ],[
1306         AC_MSG_RESULT([no])
1307 ])
1308 ])
1309
1310 #
1311 # 3.3 switchs super_operations to use dentry as parameter (but not vfsmount)
1312 # see kernel commit 34c80b1d93e6e20ca9dea0baf583a5b5510d92d4
1313 #
1314 AC_DEFUN([LC_SUPEROPS_USE_DENTRY],
1315 [AC_MSG_CHECKING([if super_operations use dentry as parameter])
1316 tmp_flags="$EXTRA_KCFLAGS"
1317 EXTRA_KCFLAGS="-Werror"
1318 LB_LINUX_TRY_COMPILE([
1319         #include <linux/fs.h>
1320         int show_options(struct seq_file *seq, struct dentry *root){
1321                 return 0;
1322         }
1323 ],[
1324         struct super_operations ops;
1325         ops.show_options = show_options;
1326 ],[
1327         AC_DEFINE(HAVE_SUPEROPS_USE_DENTRY, 1,
1328                   [super_operations use dentry as parameter])
1329         AC_MSG_RESULT([yes])
1330 ],[
1331         AC_MSG_RESULT([no])
1332 ])
1333 EXTRA_KCFLAGS="$tmp_flags"
1334 ])
1335
1336 #
1337 # 3.3 switchs inode_operations to use umode_t as parameter (but not int)
1338 # see kernel commit 1a67aafb5f72a436ca044293309fa7e6351d6a35
1339 #
1340 AC_DEFUN([LC_INODEOPS_USE_UMODE_T],
1341 [AC_MSG_CHECKING([if inode_operations use umode_t as parameter])
1342 tmp_flags="$EXTRA_KCFLAGS"
1343 EXTRA_KCFLAGS="-Werror"
1344 LB_LINUX_TRY_COMPILE([
1345         #include <linux/fs.h>
1346         #include <linux/types.h>
1347         int my_mknod(struct inode *dir, struct dentry *dchild,
1348                      umode_t mode, dev_t dev)
1349         {
1350                 return 0;
1351         }
1352 ],[
1353         struct inode_operations ops;
1354         ops.mknod = my_mknod;
1355 ],[
1356         AC_DEFINE(HAVE_INODEOPS_USE_UMODE_T, 1,
1357                   [inode_operations use umode_t as parameter])
1358         AC_MSG_RESULT([yes])
1359 ],[
1360         AC_MSG_RESULT([no])
1361 ])
1362 EXTRA_KCFLAGS="$tmp_flags"
1363 ])
1364
1365 # 3.4 kmap_atomic removes second argument
1366 # see kernel commit 1ec9c5ddc17aa398f05646abfcbaf315b544e62f
1367 #
1368 AC_DEFUN([LC_KMAP_ATOMIC_HAS_1ARG],
1369 [AC_MSG_CHECKING([if kmap_atomic has only 1 argument])
1370 LB_LINUX_TRY_COMPILE([
1371         #include <linux/highmem.h>
1372 ],[
1373         kmap_atomic(NULL);
1374 ],[
1375         AC_DEFINE(HAVE_KMAP_ATOMIC_HAS_1ARG, 1,
1376                   [have kmap_atomic has only 1 argument])
1377         AC_MSG_RESULT([yes])
1378 ],[
1379         AC_MSG_RESULT([no])
1380 ])
1381 ])
1382
1383 #
1384 # 3.4 switchs touch_atime to struct path
1385 # see kernel commit 68ac1234fb949b66941d94dce4157742799fc581
1386 #
1387 AC_DEFUN([LC_TOUCH_ATIME_1ARG],
1388 [AC_MSG_CHECKING([if touch_atime use one argument])
1389 LB_LINUX_TRY_COMPILE([
1390         #include <linux/fs.h>
1391 ],[
1392         touch_atime((struct path *)NULL);
1393 ],[
1394         AC_DEFINE(HAVE_TOUCH_ATIME_1ARG, 1,
1395                   [touch_atime use one argument])
1396         AC_MSG_RESULT([yes])
1397 ],[
1398         AC_MSG_RESULT([no])
1399 ])
1400 ])
1401
1402 #
1403 # 3.4 converts d_alloc_root to d_make_root
1404 # see kernel commit 32991ab305ace7017c62f8eecbe5eb36dc32e13b
1405 #
1406 AC_DEFUN([LC_HAVE_D_MAKE_ROOT],
1407 [AC_MSG_CHECKING([if have d_make_root])
1408 LB_LINUX_TRY_COMPILE([
1409         #include <linux/fs.h>
1410 ],[
1411         d_make_root((struct inode *)NULL);
1412 ],[
1413         AC_DEFINE(HAVE_D_MAKE_ROOT, 1,
1414                   [have d_make_root])
1415         AC_MSG_RESULT([yes])
1416 ],[
1417         AC_MSG_RESULT([no])
1418 ])
1419 ])
1420
1421 #
1422 # 3.5 renames end_writeback() back to clear_inode()...
1423 # see kernel commit dbd5768f87ff6fb0a4fe09c4d7b6c4a24de99430
1424 #
1425 AC_DEFUN([LC_HAVE_CLEAR_INODE],
1426 [AC_MSG_CHECKING([if have clear_inode])
1427 LB_LINUX_TRY_COMPILE([
1428         #include <linux/fs.h>
1429 ],[
1430         clear_inode((struct inode *)NULL);
1431 ],[
1432         AC_DEFINE(HAVE_CLEAR_INODE, 1,
1433                   [have clear_inode])
1434         AC_MSG_RESULT([yes])
1435 ],[
1436         AC_MSG_RESULT([no])
1437 ])
1438 ])
1439
1440 #
1441 # 3.5 encode_fh has parent inode passed in directly
1442 # see kernel commit b0b0382b
1443 #
1444 AC_DEFUN([LC_HAVE_ENCODE_FH_PARENT],
1445 [AC_MSG_CHECKING([if encode_fh have parent inode as parameter])
1446 tmp_flags="$EXTRA_KCFLAGS"
1447 EXTRA_KCFLAGS="-Werror"
1448 LB_LINUX_TRY_COMPILE([
1449         #include <linux/exportfs.h>
1450         #include <linux/fs.h>
1451         #include <linux/types.h>
1452         int ll_encode_fh(struct inode *i, __u32 *a, int *b, struct inode *p)
1453         {
1454                 return 0;
1455         }
1456 ],[
1457         struct export_operations exp_op;
1458         exp_op.encode_fh = ll_encode_fh;
1459 ],[
1460         AC_DEFINE(HAVE_ENCODE_FH_PARENT, 1,
1461                   [have parent inode as parameter])
1462         AC_MSG_RESULT([yes])
1463 ],[
1464         AC_MSG_RESULT([no])
1465 ])
1466 EXTRA_KCFLAGS="$tmp_flags"
1467 ])
1468
1469 # 3.5 has generic_file_llseek_size with 5 args
1470 AC_DEFUN([LC_FILE_LLSEEK_SIZE_5ARG],
1471 [AC_MSG_CHECKING([if kernel has generic_file_llseek_size with 5 args])
1472 LB_LINUX_TRY_COMPILE([
1473         #include <linux/fs.h>
1474 ],[
1475         generic_file_llseek_size(NULL, 0, 0, 0, 0);
1476 ], [
1477         AC_MSG_RESULT([yes])
1478         AC_DEFINE(HAVE_FILE_LLSEEK_SIZE_5ARGS, 1,
1479                 [kernel has generic_file_llseek_size with 5 args])
1480 ],[
1481         AC_MSG_RESULT([no])
1482 ])
1483 ])
1484
1485 #
1486 # 3.6 switch i_dentry/d_alias from list to hlist
1487 #
1488 AC_DEFUN([LC_HAVE_DENTRY_D_ALIAS_HLIST],
1489 [AC_MSG_CHECKING([if i_dentry/d_alias uses hlist])
1490 tmp_flags="$EXTRA_KCFLAGS"
1491 EXTRA_KCFLAGS="-Werror"
1492 LB_LINUX_TRY_COMPILE([
1493         #include <linux/fs.h>
1494         #include <linux/list.h>
1495 ],[
1496         struct inode inode;
1497         struct dentry dentry;
1498         struct hlist_head head;
1499         struct hlist_node node;
1500         inode.i_dentry = head;
1501         dentry.d_alias = node;
1502 ],[
1503         AC_DEFINE(HAVE_DENTRY_D_ALIAS_HLIST, 1,
1504                   [have i_dentry/d_alias uses hlist])
1505         AC_MSG_RESULT([yes])
1506 ],[
1507         AC_MSG_RESULT([no])
1508 ])
1509 EXTRA_KCFLAGS="$tmp_flags"
1510 ])
1511
1512 #
1513 # 3.6 dentry_open uses struct path as first argument
1514 # see kernel commit 765927b2
1515 #
1516 AC_DEFUN([LC_DENTRY_OPEN_USE_PATH],
1517 [AC_MSG_CHECKING([if dentry_open uses struct path as first argument])
1518 tmp_flags="$EXTRA_KCFLAGS"
1519 EXTRA_KCFLAGS="-Werror"
1520 LB_LINUX_TRY_COMPILE([
1521         #include <linux/fs.h>
1522         #include <linux/path.h>
1523 ],[
1524         struct path path;
1525         dentry_open(&path, 0, NULL);
1526 ],[
1527         AC_DEFINE(HAVE_DENTRY_OPEN_USE_PATH, 1,
1528                   [dentry_open uses struct path as first argument])
1529         AC_MSG_RESULT([yes])
1530 ],[
1531         AC_MSG_RESULT([no])
1532 ])
1533 EXTRA_KCFLAGS="$tmp_flags"
1534 ])
1535
1536 #
1537 # 3.6 vfs adds iop->atomic_open
1538 #
1539 AC_DEFUN([LC_HAVE_IOP_ATOMIC_OPEN],
1540 [AC_MSG_CHECKING([if iop has atomic_open])
1541 LB_LINUX_TRY_COMPILE([
1542         #include <linux/fs.h>
1543 ],[
1544         struct inode_operations iop;
1545         iop.atomic_open = NULL;
1546 ],[
1547         AC_DEFINE(HAVE_IOP_ATOMIC_OPEN, 1,
1548                   [have iop atomic_open])
1549         AC_MSG_RESULT([yes])
1550 ],[
1551         AC_MSG_RESULT([no])
1552 ])
1553 ])
1554
1555 #
1556 # 3.7 posix_acl_{to,from}_xattr take struct user_namespace
1557 #
1558 AC_DEFUN([LC_HAVE_POSIXACL_USER_NS],
1559 [AC_MSG_CHECKING([if posix_acl_to_xattr takes struct user_namespace])
1560 LB_LINUX_TRY_COMPILE([
1561         #include <linux/fs.h>
1562         #include <linux/posix_acl_xattr.h>
1563 ],[
1564         posix_acl_to_xattr((struct user_namespace *)NULL, NULL, NULL, 0);
1565 ],[
1566         AC_DEFINE(HAVE_POSIXACL_USER_NS, 1,
1567                   [posix_acl_to_xattr takes struct user_namespace])
1568         AC_MSG_RESULT([yes])
1569 ],[
1570         AC_MSG_RESULT([no])
1571 ])
1572 ])
1573
1574 #
1575 # 3.9 uses hlist_for_each_entry with 3 args
1576 # b67bfe0d42cac56c512dd5da4b1b347a23f4b70a
1577 #
1578 AC_DEFUN([LC_HAVE_HLIST_FOR_EACH_3ARG],
1579 [AC_MSG_CHECKING([if hlist_for_each_entry has 3 args])
1580 LB_LINUX_TRY_COMPILE([
1581         #include <linux/list.h>
1582         #include <linux/fs.h>
1583 ],[
1584         struct inode *inode;
1585         struct dentry *dentry;
1586         hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) {
1587                 continue;
1588         }
1589 ],[
1590         AC_DEFINE(HAVE_HLIST_FOR_EACH_3ARG, 1, [3 args])
1591         AC_MSG_RESULT([yes])
1592 ],[
1593         AC_MSG_RESULT([no])
1594 ])
1595 ])
1596
1597 #
1598 # LC_PROG_LINUX
1599 #
1600 # Lustre linux kernel checks
1601 #
1602 AC_DEFUN([LC_PROG_LINUX],
1603          [
1604          LC_CONFIG_PINGER
1605          LC_CONFIG_CHECKSUM
1606          LC_CONFIG_LIBLUSTRE_RECOVERY
1607          LC_CONFIG_HEALTH_CHECK_WRITE
1608          LC_CONFIG_LRU_RESIZE
1609          LC_LLITE_LLOOP_MODULE
1610
1611          # RHEL4 patches
1612          LC_EXPORT_TRUNCATE_COMPLETE
1613
1614          LC_BIT_SPINLOCK_H
1615
1616          LC_CAPA_CRYPTO
1617          LC_CONFIG_RMTCLIENT
1618          LC_CONFIG_GSS
1619
1620          # 2.6.12
1621          LC_RW_TREE_LOCK
1622
1623          #2.6.18 + RHEL5 (fc6)
1624          LC_LINUX_FIEMAP_H
1625
1626          # 2.6.19
1627          LC_FILE_WRITEV
1628          LC_FILE_READV
1629
1630          # raid5-zerocopy patch
1631          LC_PAGE_CONSTANT
1632
1633          # 2.6.22
1634          LC_INVALIDATE_BDEV_2ARG
1635          LC_FS_RENAME_DOES_D_MOVE
1636
1637          # 2.6.23
1638          LC_UNREGISTER_BLKDEV_RETURN_INT
1639          LC_PROCFS_USERS
1640
1641          # 2.6.24
1642          LC_BIO_ENDIO_2ARG
1643          LC_PROCFS_DELETED
1644
1645          # 2.6.26
1646          LC_FS_STRUCT_USE_PATH
1647
1648          # 2.6.27
1649          LC_SECURITY_PLUG  # for SLES10 SP2
1650          LC_INODE_PERMISION_2ARGS
1651          LC_QUOTA_ON_5ARGS
1652          LC_QUOTA_OFF_3ARGS
1653          LC_LOCK_MAP_ACQUIRE
1654
1655          # 2.6.27.15-2 sles11
1656          LC_BI_HW_SEGMENTS
1657          LC_HAVE_QUOTAIO_H
1658
1659          # 2.6.32
1660          LC_BLK_QUEUE_MAX_SEGMENTS
1661          LC_SET_CPUS_ALLOWED
1662
1663          # 2.6.34
1664          LC_HAVE_DQUOT_FS_DISK_QUOTA
1665          LC_HAVE_DQUOT_SUSPEND
1666
1667          # 2.6.35, 3.0.0
1668          LC_FILE_FSYNC
1669          LC_EXPORT_SIMPLE_SETATTR
1670
1671          # 2.6.36
1672          LC_FS_STRUCT_RWLOCK
1673          LC_SBOPS_EVICT_INODE
1674
1675          # 2.6.37
1676          LC_KERNEL_LOCKED
1677
1678          # 2.6.38
1679          LC_BLKDEV_GET_BY_DEV
1680          LC_GENERIC_PERMISSION
1681          LC_QUOTA_ON_USE_PATH
1682          LC_DCACHE_LOCK
1683          LC_INODE_I_RCU
1684          LC_D_COMPARE_7ARGS
1685          LC_D_DELETE_CONST
1686
1687          # 2.6.39
1688          LC_REQUEST_QUEUE_UNPLUG_FN
1689          LC_HAVE_FSTYPE_MOUNT
1690
1691          # 3.0
1692          LC_DIRTY_INODE_WITH_FLAG
1693
1694          # 3.1
1695          LC_LM_XXX_LOCK_MANAGER_OPS
1696          LC_INODE_DIO_WAIT
1697          LC_IOP_GET_ACL
1698          LC_FILE_LLSEEK_SIZE
1699
1700          # 3.1.1
1701          LC_BLOCKS_FOR_TRUNCATE
1702
1703          # 3.2
1704          LC_HAVE_VOID_MAKE_REQUEST_FN
1705          LC_HAVE_PROTECT_I_NLINK
1706
1707          # 3.3
1708          LC_HAVE_MIGRATE_HEADER
1709          LC_MIGRATEPAGE_4ARGS
1710          LC_SUPEROPS_USE_DENTRY
1711          LC_INODEOPS_USE_UMODE_T
1712
1713          # 3.4
1714          LC_TOUCH_ATIME_1ARG
1715          LC_HAVE_D_MAKE_ROOT
1716          LC_KMAP_ATOMIC_HAS_1ARG
1717
1718          # 3.5
1719          LC_HAVE_CLEAR_INODE
1720          LC_HAVE_ENCODE_FH_PARENT
1721          LC_FILE_LLSEEK_SIZE_5ARG
1722
1723          # 3.6
1724          LC_HAVE_DENTRY_D_ALIAS_HLIST
1725          LC_DENTRY_OPEN_USE_PATH
1726          LC_HAVE_IOP_ATOMIC_OPEN
1727
1728          # 3.7
1729          LC_HAVE_POSIXACL_USER_NS
1730
1731          # 3.9
1732          LC_HAVE_HLIST_FOR_EACH_3ARG
1733
1734          #
1735          if test x$enable_server = xyes ; then
1736                 AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
1737                 LC_FUNC_DEV_SET_RDONLY
1738                 LC_STACK_SIZE
1739                 LC_QUOTA64
1740                 LC_QUOTA_CONFIG
1741          fi
1742 ])
1743
1744 #
1745 # LC_CONFIG_CLIENT_SERVER
1746 #
1747 # Build client/server sides of Lustre
1748 #
1749 AC_DEFUN([LC_CONFIG_CLIENT_SERVER],
1750 [AC_MSG_CHECKING([whether to build Lustre server support])
1751 AC_ARG_ENABLE([server],
1752         AC_HELP_STRING([--disable-server],
1753                         [disable Lustre server support]),
1754         [],[enable_server='yes'])
1755 AC_MSG_RESULT([$enable_server])
1756
1757 AC_MSG_CHECKING([whether to build Lustre client support])
1758 AC_ARG_ENABLE([client],
1759         AC_HELP_STRING([--disable-client],
1760                         [disable Lustre client support]),
1761         [],[enable_client='yes'])
1762 AC_MSG_RESULT([$enable_client])])
1763
1764 #
1765 # LC_CONFIG_LIBLUSTRE
1766 #
1767 # whether to build liblustre
1768 #
1769 AC_DEFUN([LC_CONFIG_LIBLUSTRE],
1770 [AC_MSG_CHECKING([whether to build Lustre library])
1771 AC_ARG_ENABLE([liblustre],
1772         AC_HELP_STRING([--disable-liblustre],
1773                         [disable building of Lustre library]),
1774         [],[enable_liblustre=$with_sysio])
1775 AC_MSG_RESULT([$enable_liblustre])
1776 # only build sysio if liblustre is built
1777 with_sysio="$enable_liblustre"
1778
1779 AC_MSG_CHECKING([whether to build liblustre tests])
1780 AC_ARG_ENABLE([liblustre-tests],
1781         AC_HELP_STRING([--enable-liblustre-tests],
1782                         [enable liblustre tests, if --disable-tests is used]),
1783         [],[enable_liblustre_tests=$enable_tests])
1784 if test x$enable_liblustre != xyes ; then
1785    enable_liblustre_tests='no'
1786 fi
1787 AC_MSG_RESULT([$enable_liblustre_tests])
1788
1789 AC_MSG_CHECKING([whether to enable liblustre acl])
1790 AC_ARG_ENABLE([liblustre-acl],
1791         AC_HELP_STRING([--disable-liblustre-acl],
1792                         [disable ACL support for liblustre]),
1793         [],[enable_liblustre_acl=yes])
1794 AC_MSG_RESULT([$enable_liblustre_acl])
1795 if test x$enable_liblustre_acl = xyes ; then
1796   AC_DEFINE(LIBLUSTRE_POSIX_ACL, 1, Liblustre Support ACL-enabled MDS)
1797 fi
1798
1799 # 2.6.29 blkdev_put has 2 arguments
1800 AC_DEFUN([LC_BLKDEV_PUT_2ARGS],
1801 [AC_MSG_CHECKING([blkdev_put needs 2 parameters])
1802 LB_LINUX_TRY_COMPILE([
1803         #include <linux/fs.h>
1804 ],[
1805         blkdev_put(NULL, 0);
1806 ],[
1807         AC_DEFINE(HAVE_BLKDEV_PUT_2ARGS, 1,
1808                 [blkdev_put needs 2 paramters])
1809         AC_MSG_RESULT([yes])
1810 ],[
1811         AC_MSG_RESULT([no])
1812 ])
1813 ])
1814
1815 #
1816 # --enable-mpitest
1817 #
1818 AC_ARG_ENABLE(mpitests,
1819         AC_HELP_STRING([--enable-mpitests=yes|no|mpicc wrapper],
1820                            [include mpi tests]),
1821         [
1822          enable_mpitests=yes
1823          case $enableval in
1824          yes)
1825                 MPICC_WRAPPER=mpicc
1826                 ;;
1827          no)
1828                 enable_mpitests=no
1829                 ;;
1830          *)
1831                 MPICC_WRAPPER=$enableval
1832                  ;;
1833          esac
1834         ],
1835         [
1836         MPICC_WRAPPER=mpicc
1837         enable_mpitests=yes
1838         ]
1839 )
1840
1841 if test x$enable_mpitests != xno; then
1842         AC_MSG_CHECKING([whether mpitests can be built])
1843         oldcc=$CC
1844         CC=$MPICC_WRAPPER
1845         AC_LINK_IFELSE(
1846             [AC_LANG_PROGRAM([[
1847                     #include <mpi.h>
1848                 ]],[[
1849                     int flag;
1850                     MPI_Initialized(&flag);
1851                 ]])],
1852             [
1853                     AC_MSG_RESULT([yes])
1854             ],[
1855                     AC_MSG_RESULT([no])
1856                     enable_mpitests=no
1857         ])
1858         CC=$oldcc
1859 fi
1860 AC_SUBST(MPICC_WRAPPER)
1861
1862 AC_MSG_NOTICE([Enabling Lustre configure options for libsysio])
1863 ac_configure_args="$ac_configure_args --with-lustre-hack --with-sockets"
1864
1865 LC_CONFIG_PINGER
1866 LC_CONFIG_LIBLUSTRE_RECOVERY
1867 ])
1868
1869 #
1870 # LC_CONFIG_QUOTA
1871 #
1872 # whether to enable quota support global control
1873 #
1874 AC_DEFUN([LC_CONFIG_QUOTA],
1875 [AC_ARG_ENABLE([quota],
1876         AC_HELP_STRING([--enable-quota],
1877                         [enable quota support]),
1878         [],[enable_quota='yes'])
1879 ])
1880
1881 AC_DEFUN([LC_QUOTA],
1882 [#check global
1883 LC_CONFIG_QUOTA
1884 #check for utils
1885 AC_CHECK_HEADER(sys/quota.h,
1886                 [AC_DEFINE(HAVE_SYS_QUOTA_H, 1, [Define to 1 if you have <sys/quota.h>.])],
1887                 [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
1888 ])
1889
1890 #
1891 # LC_CONFIG_SPLIT
1892 #
1893 # whether to enable split support
1894 #
1895 AC_DEFUN([LC_CONFIG_SPLIT],
1896 [AC_MSG_CHECKING([whether to enable split support])
1897 AC_ARG_ENABLE([split],
1898         AC_HELP_STRING([--enable-split],
1899                         [enable split support]),
1900         [],[enable_split='no'])
1901 AC_MSG_RESULT([$enable_split])
1902 if test x$enable_split != xno; then
1903    AC_DEFINE(HAVE_SPLIT_SUPPORT, 1, [enable split support])
1904 fi
1905 ])
1906
1907 #
1908 # LC_LLITE_LLOOP_MODULE
1909 # lloop_llite.ko does not currently work with page sizes
1910 # of 64k or larger.
1911 #
1912 AC_DEFUN([LC_LLITE_LLOOP_MODULE],
1913 [AC_MSG_CHECKING([whether to enable llite_lloop module])
1914 LB_LINUX_TRY_COMPILE([
1915         #include <asm/page.h>
1916 ],[
1917         #if PAGE_SIZE >= 65536
1918         #error "PAGE_SIZE >= 65536"
1919         #endif
1920 ],[
1921         enable_llite_lloop_module='yes'
1922         AC_MSG_RESULT([yes])
1923 ],[
1924         enable_llite_lloop_module='no'
1925         AC_MSG_RESULT([no])
1926 ])
1927 ])
1928
1929 #
1930 # LC_OSD_ADDON
1931 #
1932 # configure support for optional OSD implementation
1933 #
1934 AC_DEFUN([LC_OSD_ADDON],
1935 [AC_MSG_CHECKING([for osd])
1936 AC_ARG_WITH([osd],
1937         AC_HELP_STRING([--with-osd=path],
1938                        [set path to optional osd]),
1939         [
1940                 case $with_osd in
1941                         no)     ENABLEOSDADDON=0
1942                                 ;;
1943                         *)      OSDADDON="${with_osd}"
1944                                 ENABLEOSDADDON=1
1945                                 ;;
1946                 esac
1947         ], [
1948                 ENABLEOSDADDON=0
1949         ])
1950 if test $ENABLEOSDADDON -eq 0; then
1951         AC_MSG_RESULT([no])
1952         OSDADDON=
1953 else
1954         OSDMODNAME=`basename $OSDADDON`
1955         if test -e $LUSTRE/$OSDMODNAME; then
1956                 AC_MSG_RESULT([can't link])
1957                 OSDADDON=
1958         elif ln -s $OSDADDON $LUSTRE/$OSDMODNAME; then
1959                 AC_MSG_RESULT([$OSDMODNAME])
1960                 OSDADDON="subdir-m += $OSDMODNAME"
1961         else
1962                 AC_MSG_RESULT([can't link])
1963                 OSDADDON=
1964         fi
1965 fi
1966 AC_SUBST(OSDADDON)
1967 ])
1968
1969 #
1970 # LC_CONFIGURE
1971 #
1972 # other configure checks
1973 #
1974 AC_DEFUN([LC_CONFIGURE],
1975 [LC_CONFIG_OBD_BUFFER_SIZE
1976
1977 if test $target_cpu == "i686" -o $target_cpu == "x86_64"; then
1978         CFLAGS="$CFLAGS -Werror"
1979 fi
1980
1981 # maximum MDS thread count
1982 LC_MDS_MAX_THREADS
1983
1984 # include/liblustre.h
1985 AC_CHECK_HEADERS([sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
1986
1987 # liblustre/llite_lib.h
1988 AC_CHECK_HEADERS([xtio.h file.h])
1989
1990 # liblustre/dir.c
1991 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
1992
1993 # liblustre/lutil.c
1994 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h catamount/data.h])
1995 AC_CHECK_FUNCS([inet_ntoa])
1996
1997 # libsysio/src/readlink.c
1998 LC_READLINK_SSIZE_T
1999
2000 # lvfs/prng.c - depends on linux/types.h from liblustre/dir.c
2001 AC_CHECK_HEADERS([linux/random.h], [], [],
2002                  [#ifdef HAVE_LINUX_TYPES_H
2003                   # include <linux/types.h>
2004                   #endif
2005                  ])
2006
2007 # utils/llverfs.c
2008 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
2009
2010 # check for -lz support
2011 ZLIB=""
2012 AC_CHECK_LIB([z],
2013              [adler32],
2014              [AC_CHECK_HEADERS([zlib.h],
2015                                [ZLIB="-lz"
2016                                 AC_DEFINE([HAVE_ADLER], 1,
2017                                           [support alder32 checksum type])],
2018                                [AC_MSG_WARN([No zlib-devel package found,
2019                                              unable to use adler32 checksum])])],
2020              [AC_MSG_WARN([No zlib package found, unable to use adler32 checksum])]
2021 )
2022 AC_SUBST(ZLIB)
2023
2024 SELINUX=""
2025 AC_CHECK_LIB([selinux],
2026                 [is_selinux_enabled],
2027                 [AC_CHECK_HEADERS([selinux.h],
2028                                 [SELINUX="-lselinux"
2029                                 AC_DEFINE([HAVE_SELINUX], 1,
2030                                                 [support for selinux ])],
2031                                 [AC_MSG_WARN([No selinux-devel package found,
2032                                                 unable to build selinux enabled
2033                                                 tools])])],
2034                 [AC_MSG_WARN([No selinux package found, unable to build selinux
2035                                 enabled tools])]
2036 )
2037 AC_SUBST(SELINUX)
2038
2039 # Super safe df
2040 AC_ARG_ENABLE([mindf],
2041       AC_HELP_STRING([--enable-mindf],
2042                       [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
2043       [],[])
2044 if test "$enable_mindf" = "yes" ;  then
2045       AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])
2046 fi
2047
2048 AC_ARG_ENABLE([fail_alloc],
2049         AC_HELP_STRING([--disable-fail-alloc],
2050                 [disable randomly alloc failure]),
2051         [],[enable_fail_alloc=yes])
2052 AC_MSG_CHECKING([whether to randomly failing memory alloc])
2053 AC_MSG_RESULT([$enable_fail_alloc])
2054 if test x$enable_fail_alloc != xno ; then
2055         AC_DEFINE([RANDOM_FAIL_ALLOC], 1, [enable randomly alloc failure])
2056 fi
2057
2058 AC_ARG_ENABLE([invariants],
2059         AC_HELP_STRING([--enable-invariants],
2060                 [enable invariant checking (cpu intensive)]),
2061         [],[])
2062 AC_MSG_CHECKING([whether to check invariants (expensive cpu-wise)])
2063 AC_MSG_RESULT([$enable_invariants])
2064 if test x$enable_invariants = xyes ; then
2065         AC_DEFINE([CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK], 1, [enable invariant checking])
2066 fi
2067
2068 AC_ARG_ENABLE([lu_ref],
2069         AC_HELP_STRING([--enable-lu_ref],
2070                 [enable lu_ref reference tracking code]),
2071         [],[])
2072 AC_MSG_CHECKING([whether to track references with lu_ref])
2073 AC_MSG_RESULT([$enable_lu_ref])
2074 if test x$enable_lu_ref = xyes ; then
2075         AC_DEFINE([USE_LU_REF], 1, [enable lu_ref reference tracking code])
2076 fi
2077
2078 AC_ARG_ENABLE([pgstate-track],
2079               AC_HELP_STRING([--enable-pgstate-track],
2080                              [enable page state tracking]),
2081               [enable_pgstat_track='yes'],[])
2082 AC_MSG_CHECKING([whether to enable page state tracking])
2083 AC_MSG_RESULT([$enable_pgstat_track])
2084 if test x$enable_pgstat_track = xyes ; then
2085         AC_DEFINE([CONFIG_DEBUG_PAGESTATE_TRACKING], 1,
2086                   [enable page state tracking code])
2087 fi
2088
2089          #2.6.29
2090          LC_BLKDEV_PUT_2ARGS
2091
2092 ])
2093
2094 #
2095 # LC_CONDITIONALS
2096 #
2097 # AM_CONDITIONALS for lustre
2098 #
2099 AC_DEFUN([LC_CONDITIONALS],
2100 [AM_CONDITIONAL(LIBLUSTRE, test x$enable_liblustre = xyes)
2101 AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
2102 AM_CONDITIONAL(LIBLUSTRE_TESTS, test x$enable_liblustre_tests = xyes)
2103 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
2104 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
2105 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
2106 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
2107 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
2108 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
2109 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
2110 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
2111 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
2112 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
2113 AM_CONDITIONAL(LLITE_LLOOP, test x$enable_llite_lloop_module = xyes)
2114 ])
2115
2116 #
2117 # LC_CONFIG_FILES
2118 #
2119 # files that should be generated with AC_OUTPUT
2120 #
2121 AC_DEFUN([LC_CONFIG_FILES],
2122 [AC_CONFIG_FILES([
2123 lustre/Makefile
2124 lustre/autoMakefile
2125 lustre/autoconf/Makefile
2126 lustre/conf/Makefile
2127 lustre/contrib/Makefile
2128 lustre/doc/Makefile
2129 lustre/include/Makefile
2130 lustre/include/lustre_ver.h
2131 lustre/include/linux/Makefile
2132 lustre/include/darwin/Makefile
2133 lustre/include/lustre/Makefile
2134 lustre/kernel_patches/targets/2.6-rhel6.target
2135 lustre/kernel_patches/targets/2.6-rhel5.target
2136 lustre/kernel_patches/targets/2.6-sles11.target
2137 lustre/kernel_patches/targets/3.0-sles11.target
2138 lustre/kernel_patches/targets/2.6-fc11.target
2139 lustre/kernel_patches/targets/2.6-fc12.target
2140 lustre/kernel_patches/targets/2.6-fc15.target
2141 lustre/kernel_patches/targets/3.x-fc18.target
2142 lustre/ldlm/Makefile
2143 lustre/fid/Makefile
2144 lustre/fid/autoMakefile
2145 lustre/liblustre/Makefile
2146 lustre/liblustre/tests/Makefile
2147 lustre/liblustre/tests/mpi/Makefile
2148 lustre/llite/Makefile
2149 lustre/llite/autoMakefile
2150 lustre/lclient/Makefile
2151 lustre/lov/Makefile
2152 lustre/lov/autoMakefile
2153 lustre/lvfs/Makefile
2154 lustre/lvfs/autoMakefile
2155 lustre/mdc/Makefile
2156 lustre/mdc/autoMakefile
2157 lustre/lmv/Makefile
2158 lustre/lmv/autoMakefile
2159 lustre/lfsck/Makefile
2160 lustre/lfsck/autoMakefile
2161 lustre/mdt/Makefile
2162 lustre/mdt/autoMakefile
2163 lustre/mdd/Makefile
2164 lustre/mdd/autoMakefile
2165 lustre/fld/Makefile
2166 lustre/fld/autoMakefile
2167 lustre/obdclass/Makefile
2168 lustre/obdclass/autoMakefile
2169 lustre/obdclass/linux/Makefile
2170 lustre/obdecho/Makefile
2171 lustre/obdecho/autoMakefile
2172 lustre/ofd/Makefile
2173 lustre/ofd/autoMakefile
2174 lustre/osc/Makefile
2175 lustre/osc/autoMakefile
2176 lustre/ost/Makefile
2177 lustre/ost/autoMakefile
2178 lustre/osd-ldiskfs/Makefile
2179 lustre/osd-ldiskfs/autoMakefile
2180 lustre/osd-zfs/Makefile
2181 lustre/osd-zfs/autoMakefile
2182 lustre/mgc/Makefile
2183 lustre/mgc/autoMakefile
2184 lustre/mgs/Makefile
2185 lustre/mgs/autoMakefile
2186 lustre/target/Makefile
2187 lustre/ptlrpc/Makefile
2188 lustre/ptlrpc/autoMakefile
2189 lustre/ptlrpc/gss/Makefile
2190 lustre/ptlrpc/gss/autoMakefile
2191 lustre/quota/Makefile
2192 lustre/quota/autoMakefile
2193 lustre/scripts/Makefile
2194 lustre/tests/Makefile
2195 lustre/tests/mpi/Makefile
2196 lustre/utils/Makefile
2197 lustre/utils/gss/Makefile
2198 lustre/osp/Makefile
2199 lustre/osp/autoMakefile
2200 lustre/lod/Makefile
2201 lustre/lod/autoMakefile
2202 lustre/obdclass/darwin/Makefile
2203 ])
2204 ])