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