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