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