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