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