Whamcloud - gitweb
f056134c76f06c5d0a5c9adb094e781e1276dc62
[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='/sbin'
24 AC_SUBST(rootsbindir)
25
26 demodir='$(docdir)/demo'
27 AC_SUBST(demodir)
28
29 pkgexampledir='${pkgdatadir}/examples'
30 AC_SUBST(pkgexampledir)
31 ]) # LC_PATH_DEFAULTS
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*)
41 $1
42                 ;;
43         *)
44 $2
45                 ;;
46 esac
47 ]) # LC_TARGET_SUPPORTED
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([for 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         [OBD_BUFFER_SIZE=$with_obd_buffer_size],
60         [OBD_BUFFER_SIZE=8192])
61 AC_MSG_RESULT([$OBD_BUFFER_SIZE bytes])
62 AC_DEFINE_UNQUOTED(CONFIG_LUSTRE_OBD_MAX_IOCTL_BUFFER, $OBD_BUFFER_SIZE,
63         [IOCTL Buffer Size])
64 ]) # LC_CONFIG_OBD_BUFFER_SIZE
65
66 #
67 # LC_GLIBC_SUPPORT_FHANDLES
68 #
69 AC_DEFUN([LC_GLIBC_SUPPORT_FHANDLES], [
70 AC_CHECK_FUNCS([name_to_handle_at],
71         [AC_DEFINE(HAVE_FHANDLE_GLIBC_SUPPORT, 1,
72                 [file handle and related syscalls are supported])],
73         [AC_MSG_WARN([file handle and related syscalls are not supported])])
74 ]) # LC_GLIBC_SUPPORT_FHANDLES
75
76 #
77 # LC_FUNC_DEV_SET_RDONLY
78 #
79 # check whether dev_set_rdonly is exported.  This is needed until we
80 # have another mechanism to fence IO from the underlying device.
81 #
82 AC_DEFUN([LC_FUNC_DEV_SET_RDONLY], [
83 LB_CHECK_EXPORT([dev_set_rdonly], [block/ll_rw_block.c block/blk-core.c],
84         [AC_DEFINE(HAVE_DEV_SET_RDONLY, 1,
85                 [kernel exports dev_set_rdonly])],
86         [AC_MSG_WARN([kernel missing dev_set_rdonly patch for testing])])
87 ]) # LC_FUNC_DEV_SET_RDONLY
88
89 #
90 # LC_STACK_SIZE
91 #
92 # Ensure the stack size is at least 8k in Lustre server (all kernels)
93 #
94 AC_DEFUN([LC_STACK_SIZE], [
95 LB_CHECK_COMPILE([if stack size is at least 8k],
96 stack_size_8k, [
97         #include <linux/thread_info.h>
98 ], [
99         #if THREAD_SIZE < 8192
100         #error "stack size < 8192"
101         #endif
102 ], [], [AC_MSG_ERROR([
103
104 Lustre requires that Linux is configured with at least a 8KB stack.
105 ])])
106 ]) # LC_STACK_SIZE
107
108 #
109 # LC_MDS_MAX_THREADS
110 #
111 # Allow the user to set the MDS thread upper limit
112 #
113 AC_DEFUN([LC_MDS_MAX_THREADS], [
114 AC_MSG_CHECKING([for maximum number of MDS threads])
115 AC_ARG_WITH([mds_max_threads],
116         AC_HELP_STRING([--with-mds-max-threads=count],
117                 [maximum threads available on the MDS: (default=512)]),
118         [AC_DEFINE_UNQUOTED(MDS_MAX_THREADS, $with_mds_max_threads,
119                 [maximum number of MDS threads])])
120 AC_MSG_RESULT([$with_mds_max_threads])
121 ]) # LC_MDS_MAX_THREADS
122
123 #
124 # LC_CONFIG_PINGER
125 #
126 # the pinger is temporary, until we have the recovery node in place
127 #
128 AC_DEFUN([LC_CONFIG_PINGER], [
129 AC_MSG_CHECKING([whether to enable Lustre pinger support])
130 AC_ARG_ENABLE([pinger],
131         AC_HELP_STRING([--disable-pinger],
132                 [disable recovery pinger support]),
133         [], [enable_pinger="yes"])
134 AC_MSG_RESULT([$enable_pinger])
135 AS_IF([test "x$enable_pinger" != xno],
136         [AC_DEFINE(ENABLE_PINGER, 1,[Use the Pinger])])
137 ]) # LC_CONFIG_PINGER
138
139 #
140 # LC_CONFIG_CHECKSUM
141 #
142 # do checksum of bulk data between client and OST
143 #
144 AC_DEFUN([LC_CONFIG_CHECKSUM], [
145 AC_MSG_CHECKING([whether to enable data checksum support])
146 AC_ARG_ENABLE([checksum],
147         AC_HELP_STRING([--disable-checksum],
148                 [disable data checksum support]),
149         [], [enable_checksum="yes"])
150 AC_MSG_RESULT([$enable_checksum])
151 AS_IF([test "x$enable_checksum" != xno],
152         [AC_DEFINE(ENABLE_CHECKSUM, 1, [do data checksums])])
153 ]) # LC_CONFIG_CHECKSUM
154
155 #
156 # LC_CONFIG_HEALTH_CHECK_WRITE
157 #
158 # Turn off the actual write to the disk
159 #
160 AC_DEFUN([LC_CONFIG_HEALTH_CHECK_WRITE], [
161 AC_MSG_CHECKING([whether to enable a write with the health check])
162 AC_ARG_ENABLE([health_write],
163         AC_HELP_STRING([--enable-health_write],
164                 [enable disk writes when doing health check]),
165         [], [enable_health_write="no"])
166 AC_MSG_RESULT([$enable_health_write])
167 AS_IF([test "x$enable_health_write" != xno],
168         [AC_DEFINE(USE_HEALTH_CHECK_WRITE, 1, [Write when Checking Health])])
169 ]) # LC_CONFIG_HEALTH_CHECK_WRITE
170
171 #
172 # LC_CONFIG_LRU_RESIZE
173 #
174 AC_DEFUN([LC_CONFIG_LRU_RESIZE], [
175 AC_MSG_CHECKING([whether to enable lru self-adjusting])
176 AC_ARG_ENABLE([lru_resize],
177         AC_HELP_STRING([--enable-lru-resize],
178                 [enable lru resize support]),
179         [], [enable_lru_resize="yes"])
180 AC_MSG_RESULT([$enable_lru_resize])
181 AS_IF([test "x$enable_lru_resize" != xno],
182         [AC_DEFINE(HAVE_LRU_RESIZE_SUPPORT, 1, [Enable lru resize support])])
183 ]) # LC_CONFIG_LRU_RESIZE
184
185 #
186 # LC_QUOTA_CONFIG
187 #
188 # Quota support. The kernel must support CONFIG_QUOTA.
189 #
190 AC_DEFUN([LC_QUOTA_CONFIG], [
191 LB_CHECK_CONFIG_IM([QUOTA], [],
192         [AC_MSG_ERROR([
193
194 Lustre quota requires that CONFIG_QUOTA is enabled in your kernel.
195 ])])
196 ]) # LC_QUOTA_CONFIG
197
198 #
199 # LC_EXPORT_TRUNCATE_COMPLETE_PAGE
200 #
201 # truncate_complete_page() has never been exported from an upstream kernel
202 # remove_from_page_cache() was exported between 2.6.35 and 2.6.38
203 # delete_from_page_cache() is exported from 2.6.39
204 #
205 AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE_PAGE], [
206 LB_CHECK_EXPORT([truncate_complete_page], [mm/truncate.c],
207         [AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
208                 [kernel export truncate_complete_page])])
209 LB_CHECK_EXPORT([remove_from_page_cache], [mm/filemap.c],
210         [AC_DEFINE(HAVE_REMOVE_FROM_PAGE_CACHE, 1,
211                 [kernel export remove_from_page_cache])])
212 LB_CHECK_EXPORT([delete_from_page_cache], [mm/filemap.c],
213         [AC_DEFINE(HAVE_DELETE_FROM_PAGE_CACHE, 1,
214                 [kernel export delete_from_page_cache])])
215 ]) # LC_EXPORT_TRUNCATE_COMPLETE_PAGE
216
217 #
218 # LC_CONFIG_RMTCLIENT
219 #
220 dnl FIXME
221 dnl the AES symbol usually tied with arch, e.g. CRYPTO_AES_586
222 dnl FIXME
223 AC_DEFUN([LC_CONFIG_RMTCLIENT], [
224 LB_CHECK_CONFIG_IM([CRYPTO_AES], [],
225         [AC_MSG_WARN([
226
227 Lustre remote client require that CONFIG_CRYPTO_AES is enabled in your kernel.
228 ])])
229 ]) # LC_CONFIG_RMTCLIENT
230
231 #
232 # LC_CONFIG_GSS_KEYRING
233 #
234 # default 'auto', tests for dependencies, if found, enables;
235 # only called if gss is enabled
236 #
237 AC_DEFUN([LC_CONFIG_GSS_KEYRING], [
238 AC_MSG_CHECKING([whether to enable gss keyring backend])
239 AC_ARG_ENABLE([gss_keyring],
240         [AC_HELP_STRING([--disable-gss-keyring],
241                 [disable gss keyring backend])],
242         [], [enable_gss_keyring="auto"])
243 AC_MSG_RESULT([$enable_gss_keyring])
244 AS_IF([test "x$enable_gss_keyring" != xno], [
245         LB_CHECK_CONFIG_IM([KEYS], [], [
246                 gss_keyring_conf_test="fail"
247                 AC_MSG_WARN([GSS keyring backend requires that CONFIG_KEYS be enabled in your kernel.])])
248
249         AC_CHECK_LIB([keyutils], [keyctl_search], [], [
250                 gss_keyring_conf_test="fail"
251                 AC_MSG_WARN([GSS keyring backend requires libkeyutils])])
252
253         AS_IF([test "x$gss_keyring_conf_test" != xfail], [
254                 AC_DEFINE([HAVE_GSS_KEYRING], [1],
255                         [Define this if you enable gss keyring backend])
256                 enable_gss_keyring="yes"
257         ], [
258                 AS_IF([test "x$enable_gss_keyring" = xyes], [
259                         AC_MSG_ERROR([Cannot enable gss_keyring. See above for details.])
260                 ])
261         ])
262 ])
263 ]) # LC_CONFIG_GSS_KEYRING
264
265 #
266 # LC_HAVE_CRED_TGCRED
267 #
268 # rhel7 struct cred has no member tgcred
269 #
270 AC_DEFUN([LC_HAVE_CRED_TGCRED], [
271 LB_CHECK_COMPILE([if 'struct cred' has member 'tgcred'],
272 cred_tgcred, [
273         #include <linux/cred.h>
274 ],[
275         ((struct cred *)0)->tgcred = NULL;
276 ],[
277         AC_DEFINE(HAVE_CRED_TGCRED, 1,
278                 [struct cred has member tgcred])
279 ])
280 ]) # LC_HAVE_CRED_TGCRED
281
282 #
283 # LC_KEY_TYPE_INSTANTIATE_2ARGS
284 #
285 # rhel7 key_type->instantiate takes 2 args (struct key, struct key_preparsed_payload)
286 #
287 AC_DEFUN([LC_KEY_TYPE_INSTANTIATE_2ARGS], [
288 LB_CHECK_COMPILE([if 'key_type->instantiate' has two args],
289 key_type_instantiate_2args, [
290         #include <linux/key-type.h>
291 ],[
292         ((struct key_type *)0)->instantiate(0, NULL);
293 ],[
294         AC_DEFINE(HAVE_KEY_TYPE_INSTANTIATE_2ARGS, 1,
295                 [key_type->instantiate has two args])
296 ])
297 ]) # LC_KEY_TYPE_INSTANTIATE_2ARGS
298
299 #
300 # LC_CONFIG_SUNRPC
301 #
302 AC_DEFUN([LC_CONFIG_SUNRPC], [
303 LB_CHECK_CONFIG_IM([SUNRPC], [], [
304         AS_IF([test "x$sunrpc_required" = xyes], [
305                 AC_MSG_ERROR([
306
307 kernel SUNRPC support is required by using GSS.
308 ])
309         ])])
310 ]) # LC_CONFIG_SUNRPC
311
312 #
313 # LC_CONFIG_GSS (default 'auto' (tests for dependencies, if found, enables))
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 support])
320 AC_ARG_ENABLE([gss],
321         [AC_HELP_STRING([--enable-gss], [enable gss support])],
322         [], [enable_gss="auto"])
323 AC_MSG_RESULT([$enable_gss])
324
325 AS_IF([test "x$enable_gss" != xno], [
326         LC_CONFIG_GSS_KEYRING
327         LC_HAVE_CRED_TGCRED
328         LC_KEY_TYPE_INSTANTIATE_2ARGS
329         sunrpc_required=$enable_gss
330         LC_CONFIG_SUNRPC
331         sunrpc_required="no"
332
333         LB_CHECK_CONFIG_IM([CRYPTO_MD5], [],
334                 [AC_MSG_WARN([kernel MD5 support is recommended by using GSS.])])
335         LB_CHECK_CONFIG_IM([CRYPTO_SHA1], [],
336                 [AC_MSG_WARN([kernel SHA1 support is recommended by using GSS.])])
337         LB_CHECK_CONFIG_IM([CRYPTO_SHA256], [],
338                 [AC_MSG_WARN([kernel SHA256 support is recommended by using GSS.])])
339         LB_CHECK_CONFIG_IM([CRYPTO_SHA512], [],
340                 [AC_MSG_WARN([kernel SHA512 support is recommended by using GSS.])])
341
342         require_krb5=$enable_gss
343         AC_KERBEROS_V5
344         require_krb5="no"
345
346         AS_IF([test -n "$KRBDIR"], [
347                 gss_conf_test="success"
348         ], [
349                 gss_conf_test="failure"
350         ])
351
352         AS_IF([test "x$gss_conf_test" = xsuccess], [
353                 AC_DEFINE([HAVE_GSS], [1], [Define this is if you enable gss])
354                 enable_gss="yes"
355         ], [
356                 enable_gss="no"
357         ])
358 ])
359 ]) # LC_CONFIG_GSS
360
361 # LC_HAVE_VOID_OPENSSL_HMAC_FUNCS
362 #
363 # OpenSSL 1.0+ return int for HMAC functions but previous versions do not
364 AC_DEFUN([LC_HAVE_VOID_OPENSSL_HMAC_FUNCS], [
365 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
366         #include <openssl/hmac.h>
367         #include <openssl/evp.h>
368
369         int main(void) {
370                 int rc;
371                 HMAC_CTX ctx;
372                 HMAC_CTX_init(&ctx);
373                 rc = HMAC_Init_ex(&ctx, "test", 4, EVP_md_null(), NULL);
374         }
375 ])],[],[AC_DEFINE(HAVE_VOID_OPENSSL_HMAC_FUNCS, 1,
376                 [OpenSSL HMAC functions return void instead of int])
377 ])
378 ]) # LC_HAVE_VOID_OPENSSL_HMAC_FUNCS
379
380 # LC_INODE_PERMISION_2ARGS
381 #
382 # up to v2.6.27 had a 3 arg version (inode, mask, nameidata)
383 # v2.6.27->v2.6.37 had a 2 arg version (inode, mask)
384 # v2.6.37->v3.0 had a 3 arg version (inode, mask, nameidata)
385 # v3.1 onward have a 2 arg version (inode, mask)
386 #
387 AC_DEFUN([LC_INODE_PERMISION_2ARGS], [
388 LB_CHECK_COMPILE([if 'inode_operations->permission' has two args],
389 inode_ops_permission_2args, [
390         #include <linux/fs.h>
391 ],[
392         struct inode *inode __attribute__ ((unused));
393
394         inode = NULL;
395         inode->i_op->permission(NULL, 0);
396 ],[
397         AC_DEFINE(HAVE_INODE_PERMISION_2ARGS, 1,
398                 [inode_operations->permission has two args])
399 ])
400 ]) # LC_INODE_PERMISION_2ARGS
401
402 #
403 # LC_BLK_QUEUE_MAX_SEGMENTS
404 #
405 # 2.6.32 replaces 2 functions blk_queue_max_phys_segments and blk_queue_max_hw_segments by blk_queue_max_segments
406 #
407 AC_DEFUN([LC_BLK_QUEUE_MAX_SEGMENTS], [
408 LB_CHECK_COMPILE([if 'blk_queue_max_segments' is defined],
409 blk_queue_max_segments, [
410         #include <linux/blkdev.h>
411 ],[
412         blk_queue_max_segments(NULL, 0);
413 ],[
414         AC_DEFINE(HAVE_BLK_QUEUE_MAX_SEGMENTS, 1,
415                 [blk_queue_max_segments is defined])
416 ])
417 ]) # LC_BLK_QUEUE_MAX_SEGMENTS
418
419 #
420 # LC_HAVE_DQUOT_FS_DISK_QUOTA
421 #
422 # 2.6.34 has quotactl_ops->[sg]et_dqblk that take struct fs_disk_quota
423 #
424 AC_DEFUN([LC_HAVE_DQUOT_FS_DISK_QUOTA], [
425 tmp_flags="$EXTRA_KCFLAGS"
426 EXTRA_KCFLAGS="-Werror"
427 LB_CHECK_COMPILE([if 'quotactl_ops.set_dqblk' takes struct fs_disk_quota],
428 fs_disk_quota, [
429         #include <linux/fs.h>
430         #include <linux/quota.h>
431 ],[
432         ((struct quotactl_ops *)0)->set_dqblk(NULL, 0, 0, (struct fs_disk_quota*)0);
433 ],[
434         AC_DEFINE(HAVE_DQUOT_FS_DISK_QUOTA, 1,
435                 [quotactl_ops.set_dqblk takes struct fs_disk_quota])
436 ],[
437         LB_CHECK_COMPILE([if 'quotactl_ops.set_dqblk' takes struct kqid & fs_disk_quota],
438         kqid_fs_disk_quota, [
439                 #include <linux/fs.h>
440                 #include <linux/quota.h>
441         ],[
442                 ((struct quotactl_ops *)0)->set_dqblk((struct super_block*)0, *((struct kqid*)0), (struct fs_disk_quota*)0);
443         ],[
444                 AC_DEFINE(HAVE_DQUOT_FS_DISK_QUOTA, 1,
445                         [quotactl_ops.set_dqblk takes struct fs_disk_quota])
446                 AC_DEFINE(HAVE_DQUOT_KQID, 1,
447                         [quotactl_ops.set_dqblk takes struct kqid])
448         ])
449 ])
450 EXTRA_KCFLAGS="$tmp_flags"
451 ]) # LC_HAVE_DQUOT_FS_DISK_QUOTA
452
453 #
454 # LC_HAVE_DQUOT_SUSPEND
455 #
456 # 2.6.34 has renamed dquot options to dquot_*, check for dquot_suspend
457 #
458 AC_DEFUN([LC_HAVE_DQUOT_SUSPEND], [
459 LB_CHECK_COMPILE([if 'dquot_suspend' is defined],
460 dquot_suspend, [
461         #include <linux/quotaops.h>
462 ],[
463         dquot_suspend(NULL, -1);
464 ],[
465         AC_DEFINE(HAVE_DQUOT_SUSPEND, 1, [dquot_suspend is defined])
466 ])
467 ]) # LC_HAVE_DQUOT_SUSPEND
468
469 #
470 # LC_QUOTA64
471 #
472 # Check if kernel has been patched for 64-bit quota limits support.
473 # The upstream version of this patch in RHEL6 2.6.32 kernels introduces
474 # the constant QFMT_VFS_V1 in include/linux/quota.h, so we can check for
475 # that in the absence of quotaio_v1.h in the kernel headers.
476 #
477 AC_DEFUN([LC_QUOTA64], [
478 tmp_flags="$EXTRA_KCFLAGS"
479 EXTRA_KCFLAGS="-I$LINUX/fs"
480 LB_CHECK_COMPILE([if kernel has 64-bit quota limits support],
481 quota64, [
482         #include <linux/kernel.h>
483         #include <linux/fs.h>
484         #if defined(HAVE_FS_QUOTA_QUOTAIO_H)
485         #include <quota/quotaio_v2.h>
486         struct v2r1_disk_dqblk dqblk_r1;
487         #else
488         #include <linux/quota.h>
489         int ver = QFMT_VFS_V1;
490         #endif
491 ], [], [
492         AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
493 ],[
494         LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],
495                 [AC_MSG_ERROR([You have got no 64-bit kernel quota support.])])
496 ])
497 EXTRA_KCFLAGS=$tmp_flags
498 ]) # LC_QUOTA64
499
500 #
501 # LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE
502 #
503 # 2.6.34 adds __add_wait_queue_exclusive
504 #
505 AC_DEFUN([LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE], [
506 LB_CHECK_COMPILE([if '__add_wait_queue_exclusive' exists],
507 __add_wait_queue_exclusive, [
508         #include <linux/wait.h>
509 ],[
510         wait_queue_head_t queue;
511         wait_queue_t      wait;
512         __add_wait_queue_exclusive(&queue, &wait);
513 ],[
514         AC_DEFINE(HAVE___ADD_WAIT_QUEUE_EXCLUSIVE, 1,
515                   [__add_wait_queue_exclusive exists])
516 ])
517 ]) # LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE
518
519 #
520 # LC_FS_STRUCT_RWLOCK
521 #
522 # 2.6.36 fs_struct.lock use spinlock instead of rwlock.
523 #
524 AC_DEFUN([LC_FS_STRUCT_RWLOCK], [
525 LB_CHECK_COMPILE([if 'fs_struct.lock' use rwlock],
526 fs_struct_rwlock, [
527         #include <asm/atomic.h>
528         #include <linux/spinlock.h>
529         #include <linux/fs_struct.h>
530 ],[
531         ((struct fs_struct *)0)->lock = (rwlock_t){ 0 };
532 ],[
533         AC_DEFINE(HAVE_FS_STRUCT_RWLOCK, 1, [fs_struct.lock use rwlock])
534 ])
535 ]) # LC_FS_STRUCT_RWLOCK
536
537 #
538 # LC_SBOPS_EVICT_INODE
539 #
540 # 2.6.36 super_operations add evict_inode method. it hybird of
541 # delete_inode & clear_inode.
542 #
543 AC_DEFUN([LC_SBOPS_EVICT_INODE], [
544 LB_CHECK_COMPILE([if 'super_operations.evict_inode' exist],
545 super_ops_evict_inode, [
546         #include <linux/fs.h>
547 ],[
548         ((struct super_operations *)0)->evict_inode(NULL);
549 ],[
550         AC_DEFINE(HAVE_SBOPS_EVICT_INODE, 1,
551                 [super_operations.evict_inode() is exist in kernel])
552 ])
553 ]) # LC_SBOPS_EVICT_INODE
554
555 #
556 # LC_FILE_FSYNC
557 #
558 # 2.6.35 file_operations.fsync taken 2 arguments.
559 # 3.0.0 file_operations.fsync takes 4 arguments.
560 #
561 AC_DEFUN([LC_FILE_FSYNC], [
562 LB_CHECK_COMPILE([if 'file_operations.fsync' takes 4 arguments],
563 file_ops_fsync_4args, [
564         #include <linux/fs.h>
565 ],[
566         ((struct file_operations *)0)->fsync(NULL, 0, 0, 0);
567 ],[
568         AC_DEFINE(HAVE_FILE_FSYNC_4ARGS, 1,
569                 [file_operations.fsync takes 4 arguments])
570 ],[
571         LB_CHECK_COMPILE([if 'file_operations.fsync' takes 2 arguments],
572         file_ops_fsync_2args, [
573                 #include <linux/fs.h>
574         ],[
575                 ((struct file_operations *)0)->fsync(NULL, 0);
576         ],[
577                 AC_DEFINE(HAVE_FILE_FSYNC_2ARGS, 1,
578                         [file_operations.fsync takes 2 arguments])
579         ])
580 ])
581 ]) # LC_FILE_FSYNC
582
583 #
584 # LC_KERNEL_LOCKED
585 #
586 # 2.6.37 remove kernel_locked
587 #
588 AC_DEFUN([LC_KERNEL_LOCKED], [
589 LB_CHECK_COMPILE([if 'kernel_locked' is defined],
590 kernel_locked, [
591         #include <linux/smp_lock.h>
592 ],[
593         kernel_locked();
594 ],[
595         AC_DEFINE(HAVE_KERNEL_LOCKED, 1, [kernel_locked is defined])
596 ])
597 ]) # LC_KERNEL_LOCKED
598
599 #
600 # LC_D_COMPARE_7ARGS
601 #
602 # 2.6.38 dentry_operations.d_compare() taken 7 arguments.
603 #
604 AC_DEFUN([LC_D_COMPARE_7ARGS], [
605 LB_CHECK_COMPILE([if 'dentry_operations.d_compare()' taken 7 arguments],
606 dentry_ops_d_compare_7arg, [
607         #include <linux/dcache.h>
608 ],[
609         ((struct dentry_operations*)0)->d_compare(NULL,NULL,NULL,NULL,0,NULL,NULL);
610 ],[
611         AC_DEFINE(HAVE_D_COMPARE_7ARGS, 1, [d_compare need 7 arguments])
612 ])
613 ]) # LC_D_COMPARE_7ARGS
614
615 #
616 # LC_D_DELETE_CONST
617 #
618 # 2.6.38 dentry_operations.d_delete() defined 'const' for 1st parameter.
619 #
620 AC_DEFUN([LC_D_DELETE_CONST], [
621 tmp_flags="$EXTRA_KCFLAGS"
622 EXTRA_KCFLAGS="-Werror"
623 LB_CHECK_COMPILE([if 'dentry_operations.d_delete()' has const declare on first parameter],
624 dentry_ops_d_delete_1st_const, [
625         #include <linux/dcache.h>
626 ],[
627         const struct dentry *d = NULL;
628         ((struct dentry_operations*)0)->d_delete(d);
629 ],[
630         AC_DEFINE(HAVE_D_DELETE_CONST, const,
631                 [d_delete first parameter declared const])
632 ],[
633         AC_DEFINE(HAVE_D_DELETE_CONST, [],
634                 [d_delete first parameter declared is not const])
635 ])
636 EXTRA_KCFLAGS="$tmp_flags"
637 ]) # LC_D_DELETE_CONST
638
639 #
640 # LC_DCACHE_LOCK
641 #
642 # 2.6.38 dcache_lock removed. rcu-walk committed.
643 #
644 AC_DEFUN([LC_DCACHE_LOCK], [
645 LB_CHECK_COMPILE([if 'dcache_lock' is exist],
646 dcache_lock, [
647         #include <linux/dcache.h>
648 ],[
649         spin_lock(&dcache_lock);
650 ],[
651         AC_DEFINE(HAVE_DCACHE_LOCK, 1,
652                 [dcache_lock is exist])
653 ])
654 ]) # LC_DCACHE_LOCK
655
656 #
657 # LC_INODE_I_RCU
658 #
659 # 2.6.38 inode.i_rcu added.
660 #
661 AC_DEFUN([LC_INODE_I_RCU], [
662 LB_CHECK_COMPILE([if 'inode.i_rcu' exists],
663 inode_i_rcu, [
664         #include <linux/fs.h>
665 ],[
666         struct inode ino;
667         struct rcu_head rcu = {};
668         ino.i_rcu = rcu;
669 ],[
670         AC_DEFINE(HAVE_INODE_I_RCU, 1,
671                 [inode.i_rcu exists])
672 ])
673 ]) # LC_INODE_I_RCU
674
675 #
676 # LC_BLKDEV_GET_BY_DEV
677 #
678 # 2.6.38 export blkdev_get_by_dev
679 #
680 AC_DEFUN([LC_BLKDEV_GET_BY_DEV], [
681 LB_CHECK_EXPORT([blkdev_get_by_dev], [fs/block_dev.c],
682         [AC_DEFINE(HAVE_BLKDEV_GET_BY_DEV, 1,
683                 [blkdev_get_by_dev is exported by the kernel])])
684 ]) # LC_BLKDEV_GET_BY_DEV
685
686 #
687 # LC_EXPORT_SIMPLE_SETATTR
688 #
689 # 2.6.38 export simple_setattr
690 #
691 AC_DEFUN([LC_EXPORT_SIMPLE_SETATTR], [
692 LB_CHECK_EXPORT([simple_setattr], [fs/libfs.c],
693         [AC_DEFINE(HAVE_SIMPLE_SETATTR, 1,
694                 [simple_setattr is exported by the kernel])])
695 ]) # LC_EXPORT_SIMPLE_SETATTR
696
697 #
698 # LC_IOP_TRUNCATE
699 #
700 # truncate callback removed since 2.6.39
701 #
702 AC_DEFUN([LC_IOP_TRUNCATE], [
703 LB_CHECK_COMPILE([if 'inode_operations' has '.truncate' member function],
704 inode_ops_truncate, [
705         #include <linux/fs.h>
706 ],[
707         ((struct inode_operations *)0)->truncate(NULL);
708 ],[
709         AC_DEFINE(HAVE_INODEOPS_TRUNCATE, 1,
710                 [inode_operations has .truncate member function])
711 ])
712 ]) # LC_IOP_TRUNCATE
713
714 #
715 # LC_REQUEST_QUEUE_UNPLUG_FN
716 #
717 # 2.6.39 remove unplug_fn from request_queue.
718 #
719 AC_DEFUN([LC_REQUEST_QUEUE_UNPLUG_FN], [
720 LB_CHECK_COMPILE([if 'request_queue' has 'unplug_fn' field],
721 request_queue_unplug_fn, [
722         #include <linux/blkdev.h>
723 ],[
724         do {} while(sizeof(((struct request_queue *)0)->unplug_fn));
725 ],[
726         AC_DEFINE(HAVE_REQUEST_QUEUE_UNPLUG_FN, 1,
727                 [request_queue has unplug_fn field])
728 ])
729 ]) # LC_REQUEST_QUEUE_UNPLUG_FN
730
731 #
732 # LC_HAVE_FSTYPE_MOUNT
733 #
734 # 2.6.39 replace get_sb with mount in struct file_system_type
735 #
736 AC_DEFUN([LC_HAVE_FSTYPE_MOUNT], [
737 LB_CHECK_COMPILE([if 'file_system_type' has 'mount' field],
738 file_system_type_mount, [
739         #include <linux/fs.h>
740 ],[
741         struct file_system_type fst;
742         void *i = (void *) fst.mount;
743 ],[
744         AC_DEFINE(HAVE_FSTYPE_MOUNT, 1,
745                 [struct file_system_type has mount field])
746 ])
747 ]) # LC_HAVE_FSTYPE_MOUNT
748
749 #
750 # LC_HAVE_FHANDLE_SYSCALLS
751 #
752 # 2.6.39 The open_by_handle_at() and name_to_handle_at() system calls were
753 # added to Linux kernel 2.6.39.
754 # Check if client supports these functions
755 #
756 AC_DEFUN([LC_HAVE_FHANDLE_SYSCALLS], [
757 LB_CHECK_CONFIG_IM([FHANDLE],[
758         AC_DEFINE(HAVE_FHANDLE_SYSCALLS, 1,
759                 [kernel supports fhandles and related syscalls])
760         ])
761 ]) # LC_HAVE_FHANDLE_SYSCALLS
762
763 #
764 # LC_HAVE_INODE_OWNER_OR_CAPABLE
765 #
766 # 2.6.39 renames is_owner_or_cap to inode_owner_or_capable
767 #
768 AC_DEFUN([LC_HAVE_INODE_OWNER_OR_CAPABLE], [
769 LB_CHECK_COMPILE([if 'inode_owner_or_capable' exist],
770 inode_owner_or_capable, [
771         #include <linux/fs.h>
772 ],[
773         inode_owner_or_capable(NULL);
774 ],[
775         AC_DEFINE(HAVE_INODE_OWNER_OR_CAPABLE, 1,
776                 [inode_owner_or_capable exist])
777 ])
778 ]) # LC_HAVE_INODE_OWNER_OR_CAPABLE
779
780 #
781 # LC_DIRTY_INODE_WITH_FLAG
782 #
783 # 3.0 dirty_inode() has a flag parameter
784 # see kernel commit aa38572954ade525817fe88c54faebf85e5a61c0
785 #
786 AC_DEFUN([LC_DIRTY_INODE_WITH_FLAG], [
787 LB_CHECK_COMPILE([if 'dirty_inode' super_operation takes flag],
788 dirty_inode_super_operation_flag, [
789         #include <linux/fs.h>
790 ],[
791         struct inode *inode;
792         inode->i_sb->s_op->dirty_inode(NULL, 0);
793 ],[
794         AC_DEFINE(HAVE_DIRTY_INODE_HAS_FLAG, 1,
795                 [dirty_inode super_operation takes flag])
796 ])
797 ]) # LC_DIRTY_INODE_WITH_FLAG
798
799 #
800 # LC_GENERIC_PERMISSION
801 #
802 # 2.6.38 generic_permission taken 4 parameters.
803 # in fact, it means rcu-walk aware permission bring.
804 #
805 # 3.1 generic_permission taken 2 parameters.
806 # see kernel commit 2830ba7f34ebb27c4e5b8b6ef408cd6d74860890
807 #
808 AC_DEFUN([LC_GENERIC_PERMISSION], [
809 LB_CHECK_COMPILE([if 'generic_permission' take 2 arguments],
810 generic_permission_2args, [
811         #include <linux/fs.h>
812 ],[
813         generic_permission(NULL, 0);
814 ],[
815         AC_DEFINE(HAVE_GENERIC_PERMISSION_2ARGS, 1,
816                 [generic_permission taken 2 arguments])
817 ],[
818         LB_CHECK_COMPILE([if 'generic_permission' take 4 arguments],
819         generic_permission_4args, [
820                 #include <linux/fs.h>
821         ],[
822                 generic_permission(NULL, 0, 0, NULL);
823         ],[
824                 AC_DEFINE(HAVE_GENERIC_PERMISSION_4ARGS, 1,
825                         [generic_permission taken 4 arguments])
826         ])
827 ])
828 ]) # LC_GENERIC_PERMISSION
829
830 #
831 # LC_LM_XXX_LOCK_MANAGER_OPS
832 #
833 # 3.1 renames lock-manager ops(lock_manager_operations) from fl_xxx to lm_xxx
834 # see kernel commit 8fb47a4fbf858a164e973b8ea8ef5e83e61f2e50
835 #
836 AC_DEFUN([LC_LM_XXX_LOCK_MANAGER_OPS], [
837 LB_CHECK_COMPILE([if 'lock-manager' ops renamed to 'lm_xxx'],
838 lock_manager_ops_lm_xxx, [
839         #include <linux/fs.h>
840 ],[
841         struct lock_manager_operations lm_ops;
842         lm_ops.lm_compare_owner = NULL;
843 ],[
844         AC_DEFINE(HAVE_LM_XXX_LOCK_MANAGER_OPS, 1,
845                 [lock-manager ops renamed to lm_xxx])
846 ])
847 ]) # LC_LM_XXX_LOCK_MANAGER_OPS
848
849 #
850 # LC_INODE_DIO_WAIT
851 #
852 # 3.1 kills inode->i_alloc_sem, use i_dio_count and inode_dio_wait
853 #     instead.
854 # see kernel commit bd5fe6c5eb9c548d7f07fe8f89a150bb6705e8e3
855 #
856 AC_DEFUN([LC_INODE_DIO_WAIT], [
857 LB_CHECK_COMPILE([if 'inode->i_alloc_sem' is killed and use inode_dio_wait],
858 inode_dio_wait, [
859         #include <linux/fs.h>
860 ],[
861         inode_dio_wait((struct inode *)0);
862 ],[
863         AC_DEFINE(HAVE_INODE_DIO_WAIT, 1,
864                 [inode->i_alloc_sem is killed and use inode_dio_wait])
865 ])
866 ]) # LC_INODE_DIO_WAIT
867
868 #
869 # LC_IOP_GET_ACL
870 #
871 # 3.1 adds get_acl method to inode_operations to read ACL from disk.
872 # see kernel commit 4e34e719e457f2e031297175410fc0bd4016a085
873 #
874 AC_DEFUN([LC_IOP_GET_ACL], [
875 LB_CHECK_COMPILE([if 'inode_operations' has '.get_acl' member function],
876 inode_ops_get_acl, [
877         #include <linux/fs.h>
878 ],[
879         struct inode_operations iop;
880         iop.get_acl = NULL;
881 ],[
882         AC_DEFINE(HAVE_IOP_GET_ACL, 1,
883                 [inode_operations has .get_acl member function])
884 ])
885 ]) # LC_IOP_GET_ACL
886
887 #
888 # LC_FILE_LLSEEK_SIZE
889 #
890 # 3.1 introduced generic_file_llseek_size()
891 #
892 AC_DEFUN([LC_FILE_LLSEEK_SIZE], [
893 LB_CHECK_EXPORT([generic_file_llseek_size], [fs/read_write.c],
894         [AC_DEFINE(HAVE_FILE_LLSEEK_SIZE, 1,
895                 [generic_file_llseek_size is exported by the kernel])])
896 ]) # LC_FILE_LLSEEK_SIZE
897
898 #
899 # LC_RADIX_EXCEPTION_ENTRY
900 # 3.1 adds radix_tree_exception_entry.
901 #
902 AC_DEFUN([LC_RADIX_EXCEPTION_ENTRY], [
903 LB_CHECK_COMPILE([radix_tree_exceptional_entry exist],
904 radix_tree_exceptional_entry, [
905         #include <linux/radix-tree.h>
906 ],[
907         radix_tree_exceptional_entry(NULL);
908 ],[
909         AC_DEFINE(HAVE_RADIX_EXCEPTION_ENTRY, 1,
910                 [radix_tree_exceptional_entry exist])
911 ])
912 ]) # LC_RADIX_EXCEPTION_ENTRY
913
914 #
915 # LC_HAVE_VOID_MAKE_REQUEST_FN
916 #
917 # 3.2 request_queue.make_request_fn defined as function returns with void
918 # see kernel commit 5a7bbad27a410350e64a2d7f5ec18fc73836c14f
919 #
920 AC_DEFUN([LC_HAVE_VOID_MAKE_REQUEST_FN], [
921 LB_CHECK_COMPILE([if 'request_queue.make_request_fn' returns void but not int],
922 make_request_fn_void, [
923         #include <linux/blkdev.h>
924 ],[
925         int ret;
926         make_request_fn *mrf;
927         ret = mrf(NULL, NULL);
928 ],[],[
929         AC_DEFINE(HAVE_VOID_MAKE_REQUEST_FN, 1,
930                 [request_queue.make_request_fn returns void but not int])
931 ])
932 ]) # LC_HAVE_VOID_MAKE_REQUEST_FN
933
934 #
935 # LC_HAVE_PROTECT_I_NLINK
936 #
937 # 3.2 protects inode->i_nlink from direct modification
938 # see kernel commit a78ef704a8dd430225955f0709b22d4a6ba21deb
939 # at the same time adds set_nlink(), so checks set_nlink() for it.
940 #
941 AC_DEFUN([LC_HAVE_PROTECT_I_NLINK], [
942 LB_CHECK_COMPILE([if 'inode->i_nlink' is protected from direct modification],
943 inode_i_nlink_protected, [
944         #include <linux/fs.h>
945 ],[
946         struct inode i;
947         set_nlink(&i, 1);
948 ],[
949         AC_DEFINE(HAVE_PROTECT_I_NLINK, 1,
950                 [inode->i_nlink is protected from direct modification])
951 ])
952 ]) # LC_HAVE_PROTECT_I_NLINK
953
954 #
955 # 2.6.39 security_inode_init_security takes a 'struct qstr' parameter
956 #
957 # 3.2 security_inode_init_security takes a callback to set xattrs
958 #
959 AC_DEFUN([LC_HAVE_SECURITY_IINITSEC], [
960 LB_CHECK_COMPILE([if security_inode_init_security takes a callback],
961 security_inode_init_security_callback, [
962         #include <linux/security.h>
963 ],[
964         security_inode_init_security(NULL, NULL, NULL, (const initxattrs)NULL, NULL);
965 ],[
966         AC_DEFINE(HAVE_SECURITY_IINITSEC_CALLBACK, 1,
967                   [security_inode_init_security takes a callback to set xattrs])
968 ],[
969         LB_CHECK_COMPILE([if security_inode_init_security takes a 'struct qstr' parameter],
970         security_inode_init_security_qstr, [
971                 #include <linux/security.h>
972         ],[
973                 security_inode_init_security(NULL, NULL, (struct qstr *)NULL, NULL, NULL, NULL);
974         ],[
975                 AC_DEFINE(HAVE_SECURITY_IINITSEC_QSTR, 1,
976                           [security_inode_init_security takes a 'struct qstr' parameter])
977         ])
978 ])
979 ]) # LC_HAVE_SECURITY_IINITSEC
980
981 #
982 # LC_HAVE_MIGRATE_HEADER
983 #
984 # 3.3 introduces migrate_mode.h and migratepage has 4 args
985 #
986 AC_DEFUN([LC_HAVE_MIGRATE_HEADER], [
987 LB_CHECK_FILE([$LINUX/include/linux/migrate.h], [
988         AC_DEFINE(HAVE_MIGRATE_H, 1,
989                 [kernel has include/linux/migrate.h])
990 ],[
991         LB_CHECK_FILE([$LINUX/include/linux/migrate_mode.h], [
992                 AC_DEFINE(HAVE_MIGRATE_MODE_H, 1,
993                         [kernel has include/linux/migrate_mode.h])
994         ])
995 ])
996 ]) # LC_HAVE_MIGRATE_HEADER
997
998 #
999 # LC_MIGRATEPAGE_4ARGS
1000 #
1001 AC_DEFUN([LC_MIGRATEPAGE_4ARGS], [
1002 LB_CHECK_COMPILE([if 'address_space_operations.migratepage' has 4 args],
1003 address_space_ops_migratepage_4args, [
1004         #include <linux/fs.h>
1005 #ifdef HAVE_MIGRATE_H
1006         #include <linux/migrate.h>
1007 #elif defined(HAVE_MIGRATE_MODE_H)
1008         #include <linux/migrate_mode.h>
1009 #endif
1010 ],[
1011         struct address_space_operations aops;
1012         aops.migratepage(NULL, NULL, NULL, MIGRATE_ASYNC);
1013 ],[
1014         AC_DEFINE(HAVE_MIGRATEPAGE_4ARGS, 1,
1015                 [address_space_operations.migratepage has 4 args])
1016 ])
1017 ]) # LC_MIGRATEPAGE_4ARGS
1018
1019 #
1020 # LC_SUPEROPS_USE_DENTRY
1021 #
1022 # 3.3 switchs super_operations to use dentry as parameter (but not vfsmount)
1023 # see kernel commit 34c80b1d93e6e20ca9dea0baf583a5b5510d92d4
1024 #
1025 AC_DEFUN([LC_SUPEROPS_USE_DENTRY], [
1026 tmp_flags="$EXTRA_KCFLAGS"
1027 EXTRA_KCFLAGS="-Werror"
1028 LB_CHECK_COMPILE([if 'super_operations' use 'dentry' as parameter],
1029 super_ops_dentry, [
1030         #include <linux/fs.h>
1031         int show_options(struct seq_file *seq, struct dentry *root) {
1032                 return 0;
1033         }
1034 ],[
1035         struct super_operations ops;
1036         ops.show_options = show_options;
1037 ],[
1038         AC_DEFINE(HAVE_SUPEROPS_USE_DENTRY, 1,
1039                 [super_operations use dentry as parameter])
1040 ])
1041 EXTRA_KCFLAGS="$tmp_flags"
1042 ]) # LC_SUPEROPS_USE_DENTRY
1043
1044 #
1045 # LC_INODEOPS_USE_UMODE_T
1046 #
1047 # 3.3 switchs inode_operations to use umode_t as parameter (but not int)
1048 # see kernel commit 1a67aafb5f72a436ca044293309fa7e6351d6a35
1049 #
1050 AC_DEFUN([LC_INODEOPS_USE_UMODE_T], [
1051 tmp_flags="$EXTRA_KCFLAGS"
1052 EXTRA_KCFLAGS="-Werror"
1053 LB_CHECK_COMPILE([if 'inode_operations' use 'umode_t' as parameter],
1054 inode_ops_umode_t, [
1055         #include <linux/fs.h>
1056         #include <linux/types.h>
1057         int my_mknod(struct inode *dir, struct dentry *dchild,
1058                      umode_t mode, dev_t dev)
1059         {
1060                 return 0;
1061         }
1062 ],[
1063         struct inode_operations ops;
1064         ops.mknod = my_mknod;
1065 ],[
1066         AC_DEFINE(HAVE_INODEOPS_USE_UMODE_T, 1,
1067                 [inode_operations use umode_t as parameter])
1068 ])
1069 EXTRA_KCFLAGS="$tmp_flags"
1070 ]) # LC_INODEOPS_USE_UMODE_T
1071
1072 #
1073 # LC_KMAP_ATOMIC_HAS_1ARG
1074 #
1075 # 3.4 kmap_atomic removes second argument
1076 # see kernel commit 1ec9c5ddc17aa398f05646abfcbaf315b544e62f
1077 #
1078 AC_DEFUN([LC_KMAP_ATOMIC_HAS_1ARG], [
1079 LB_CHECK_COMPILE([if 'kmap_atomic' has only 1 argument],
1080 kmap_atomic_1arg, [
1081         #include <linux/highmem.h>
1082 ],[
1083         kmap_atomic(NULL);
1084 ],[
1085         AC_DEFINE(HAVE_KMAP_ATOMIC_HAS_1ARG, 1,
1086                 [have kmap_atomic has only 1 argument])
1087 ])
1088 ]) # LC_KMAP_ATOMIC_HAS_1ARG
1089
1090 #
1091 # LC_HAVE_D_MAKE_ROOT
1092 #
1093 # 3.4 converts d_alloc_root to d_make_root
1094 # see kernel commit 32991ab305ace7017c62f8eecbe5eb36dc32e13b
1095 #
1096 AC_DEFUN([LC_HAVE_D_MAKE_ROOT], [
1097 LB_CHECK_COMPILE([if have 'd_make_root'],
1098 d_make_root, [
1099         #include <linux/fs.h>
1100 ],[
1101         d_make_root((struct inode *)NULL);
1102 ],[
1103         AC_DEFINE(HAVE_D_MAKE_ROOT, 1,
1104                 [have d_make_root])
1105 ])
1106 ]) # LC_HAVE_D_MAKE_ROOT
1107
1108 #
1109 # LC_HAVE_CACHE_REGISTER
1110 #
1111 # 3.4 cache_register/cache_unregister are removed
1112 # see kernel commit 2c5f846747526e2b83c5f1b8e69016be0e2e87c0
1113 # Note, since 2.6.37 cache_register_net/cache_unregister_net
1114 # are defined, but not exported.
1115 # 3.3 cache_register_net/cache_unregister_net are
1116 # exported and replacing cache_register/cache_unregister in 3.4
1117 #
1118 AC_DEFUN([LC_HAVE_CACHE_REGISTER], [
1119 LB_CHECK_COMPILE([if have 'cache_register'],
1120 cache_register, [
1121         #include <linux/sunrpc/cache.h>
1122 ],[
1123         cache_register(NULL);
1124 ],[
1125         AC_DEFINE(HAVE_CACHE_REGISTER, 1,
1126                 [have cache_register])
1127 ])
1128 ]) # LC_HAVE_CACHE_REGISTER
1129
1130 #
1131 # LC_HAVE_CLEAR_INODE
1132 #
1133 # 3.5 renames end_writeback() back to clear_inode()...
1134 # see kernel commit dbd5768f87ff6fb0a4fe09c4d7b6c4a24de99430
1135 #
1136 AC_DEFUN([LC_HAVE_CLEAR_INODE], [
1137 LB_CHECK_COMPILE([if have 'clear_inode'],
1138 clear_inode, [
1139         #include <linux/fs.h>
1140 ],[
1141         clear_inode((struct inode *)NULL);
1142 ],[
1143         AC_DEFINE(HAVE_CLEAR_INODE, 1,
1144                 [have clear_inode])
1145 ])
1146 ]) # LC_HAVE_CLEAR_INODE
1147
1148 #
1149 # LC_HAVE_ENCODE_FH_PARENT
1150 #
1151 # 3.5 encode_fh has parent inode passed in directly
1152 # see kernel commit b0b0382b
1153 #
1154 AC_DEFUN([LC_HAVE_ENCODE_FH_PARENT], [
1155 tmp_flags="$EXTRA_KCFLAGS"
1156 EXTRA_KCFLAGS="-Werror"
1157 LB_CHECK_COMPILE([if 'encode_fh' have parent inode as parameter],
1158 encode_fh_parent_inode, [
1159         #include <linux/exportfs.h>
1160         #include <linux/fs.h>
1161         #include <linux/types.h>
1162         int ll_encode_fh(struct inode *i, __u32 *a, int *b, struct inode *p)
1163         {
1164                 return 0;
1165         }
1166 ],[
1167         struct export_operations exp_op;
1168         exp_op.encode_fh = ll_encode_fh;
1169 ],[
1170         AC_DEFINE(HAVE_ENCODE_FH_PARENT, 1,
1171                 [have parent inode as parameter])
1172 ])
1173 EXTRA_KCFLAGS="$tmp_flags"
1174 ]) # LC_HAVE_ENCODE_FH_PARENT
1175
1176 #
1177 # LC_FILE_LLSEEK_SIZE_5ARG
1178 #
1179 # 3.5 has generic_file_llseek_size with 5 args
1180 #
1181 AC_DEFUN([LC_FILE_LLSEEK_SIZE_5ARG], [
1182 LB_CHECK_COMPILE([if Linux kernel has 'generic_file_llseek_size' with 5 args],
1183 generic_file_llseek_size_5args, [
1184         #include <linux/fs.h>
1185 ],[
1186         generic_file_llseek_size(NULL, 0, 0, 0, 0);
1187 ], [
1188         AC_DEFINE(HAVE_FILE_LLSEEK_SIZE_5ARGS, 1,
1189                 [kernel has generic_file_llseek_size with 5 args])
1190 ])
1191 ]) # LC_FILE_LLSEEK_SIZE_5ARG
1192
1193 #
1194 # LC_LLITE_DATA_IS_LIST
1195 #
1196 # 3.6 switch i_dentry/d_alias from list to hlist
1197 #
1198 # In the upstream kernels d_alias first changes
1199 # to a hlist and then in later version, 3.11, gets
1200 # moved to the union d_u. Due to some distros having
1201 # d_alias in the d_u union as a struct list, which
1202 # has never existed upstream stream, we can't test
1203 # if d_alias is a list or hlist directly. If ever
1204 # i_dentry and d_alias even up different combos then
1205 # the build will fail. In that case then we will need
1206 # to separate out the i_dentry and d_alias test below.
1207 #
1208 AC_DEFUN([LC_DATA_FOR_LLITE_IS_LIST], [
1209 tmp_flags="$EXTRA_KCFLAGS"
1210 EXTRA_KCFLAGS="-Werror"
1211 LB_CHECK_COMPILE([if 'i_dentry/d_alias' uses 'list'],
1212 i_dentry_d_alias_list, [
1213         #include <linux/fs.h>
1214 ],[
1215         struct inode inode;
1216         INIT_LIST_HEAD(&inode.i_dentry);
1217 ],[
1218         AC_DEFINE(DATA_FOR_LLITE_IS_LIST, 1,
1219                 [both i_dentry/d_alias uses list])
1220 ])
1221 EXTRA_KCFLAGS="$tmp_flags"
1222 ]) # LC_DATA_FOR_LLITE_IS_LIST
1223
1224 #
1225 # LC_DENTRY_OPEN_USE_PATH
1226 #
1227 # 3.6 dentry_open uses struct path as first argument
1228 # see kernel commit 765927b2
1229 #
1230 AC_DEFUN([LC_DENTRY_OPEN_USE_PATH], [
1231 tmp_flags="$EXTRA_KCFLAGS"
1232 EXTRA_KCFLAGS="-Werror"
1233 LB_CHECK_COMPILE([if 'dentry_open' uses 'struct path' as first argument],
1234 dentry_open_path, [
1235         #include <linux/fs.h>
1236         #include <linux/path.h>
1237 ],[
1238         struct path path;
1239         dentry_open(&path, 0, NULL);
1240 ],[
1241         AC_DEFINE(HAVE_DENTRY_OPEN_USE_PATH, 1,
1242                 [dentry_open uses struct path as first argument])
1243 ])
1244 EXTRA_KCFLAGS="$tmp_flags"
1245 ]) # LC_DENTRY_OPEN_USE_PATH
1246
1247 #
1248 # LC_HAVE_IOP_ATOMIC_OPEN
1249 #
1250 # 3.6 vfs adds iop->atomic_open
1251 #
1252 AC_DEFUN([LC_HAVE_IOP_ATOMIC_OPEN], [
1253 LB_CHECK_COMPILE([if 'iop' has 'atomic_open'],
1254 inode_ops_atomic_open, [
1255         #include <linux/fs.h>
1256 ],[
1257         struct inode_operations iop;
1258         iop.atomic_open = NULL;
1259 ],[
1260         AC_DEFINE(HAVE_IOP_ATOMIC_OPEN, 1,
1261                 [have iop atomic_open])
1262 ])
1263 ]) # LC_HAVE_IOP_ATOMIC_OPEN
1264
1265 #
1266 # LC_HAVE_SB_START_WRITE
1267 #
1268 # RHEL6 2.6.32, 3.6 or newer support wrapped FS freeze functions
1269 #
1270 AC_DEFUN([LC_HAVE_SB_START_WRITE], [
1271 LB_CHECK_COMPILE([if kernel supports wrapped FS freeze functions],
1272 sb_start_write, [
1273         #include <linux/fs.h>
1274 ],[
1275         sb_start_write(NULL);
1276 ],[
1277         AC_DEFINE(HAVE_SB_START_WRITE, 1,
1278                 [kernel supports wrapped FS freeze functions])
1279 ])
1280 ]) # LC_HAVE_SB_START_WRITE
1281
1282 #
1283 # LC_HAVE_POSIXACL_USER_NS
1284 #
1285 # 3.7 posix_acl_{to,from}_xattr take struct user_namespace
1286 #
1287 AC_DEFUN([LC_HAVE_POSIXACL_USER_NS], [
1288 LB_CHECK_COMPILE([if 'posix_acl_to_xattr' takes 'struct user_namespace'],
1289 posix_acl_to_xattr_user_namespace, [
1290         #include <linux/fs.h>
1291         #include <linux/posix_acl_xattr.h>
1292 ],[
1293         posix_acl_to_xattr((struct user_namespace *)NULL, NULL, NULL, 0);
1294 ],[
1295         AC_DEFINE(HAVE_POSIXACL_USER_NS, 1,
1296                 [posix_acl_to_xattr takes struct user_namespace])
1297 ])
1298 ]) # LC_HAVE_POSIXACL_USER_NS
1299
1300 #
1301 # LC_HAVE_FILE_F_INODE
1302 #
1303 # 3.8 struct file has new member f_inode
1304 #
1305 AC_DEFUN([LC_HAVE_FILE_F_INODE], [
1306 LB_CHECK_COMPILE([if 'struct file' has member 'f_inode'],
1307 file_f_inode, [
1308         #include <linux/fs.h>
1309 ],[
1310         ((struct file *)0)->f_inode = NULL;
1311 ],[
1312         AC_DEFINE(HAVE_FILE_F_INODE, 1,
1313                 [struct file has member f_inode])
1314 ])
1315 ]) # LC_HAVE_FILE_F_INODE
1316
1317 #
1318 # LC_HAVE_FILE_INODE
1319 #
1320 # 3.8 has introduced inline function file_inode
1321 #
1322 AC_DEFUN([LC_HAVE_FILE_INODE], [
1323 LB_CHECK_COMPILE([if file_inode() exists],
1324 file_inode, [
1325         #include <linux/fs.h>
1326 ],[
1327         file_inode(NULL);
1328 ],[
1329         AC_DEFINE(HAVE_FILE_INODE, 1,
1330                 [file_inode() has been defined])
1331 ])
1332 ]) # LC_HAVE_FILE_INODE
1333
1334 #
1335 # LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS
1336 #
1337 AC_DEFUN([LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS], [
1338 LB_CHECK_COMPILE([if 'sunrpc_cache_pipe_upcall' takes 3 args],
1339 sunrpc_cache_pipe_upcall_3args, [
1340         #include <linux/sunrpc/cache.h>
1341 ],[
1342         sunrpc_cache_pipe_upcall(NULL, NULL, NULL);
1343 ],[
1344         AC_DEFINE(HAVE_SUNRPC_UPCALL_HAS_3ARGS, 1,
1345                 [sunrpc_cache_pipe_upcall takes 3 args])
1346 ])
1347 ]) # LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS
1348
1349 #
1350 # LC_HAVE_HLIST_FOR_EACH_3ARG
1351 #
1352 # 3.9 uses hlist_for_each_entry with 3 args
1353 # b67bfe0d42cac56c512dd5da4b1b347a23f4b70a
1354 #
1355 AC_DEFUN([LC_HAVE_HLIST_FOR_EACH_3ARG], [
1356 LB_CHECK_COMPILE([if 'hlist_for_each_entry' has 3 args],
1357 hlist_for_each_entry_3args, [
1358         #include <linux/list.h>
1359         #include <linux/fs.h>
1360 ],[
1361         struct hlist_head *head = NULL;
1362         struct inode *inode;
1363
1364         hlist_for_each_entry(inode, head, i_hash) {
1365                 continue;
1366         }
1367 ],[
1368         AC_DEFINE(HAVE_HLIST_FOR_EACH_3ARG, 1,
1369                 [hlist_for_each_entry has 3 args])
1370 ])
1371 ]) # LC_HAVE_HLIST_FOR_EACH_3ARG
1372
1373 #
1374 # LC_HAVE_BIO_END_SECTOR
1375 #
1376 # 3.9 introduces bio_end_sector macro
1377 # f73a1c7d117d07a96d89475066188a2b79e53c48
1378 #
1379 AC_DEFUN([LC_HAVE_BIO_END_SECTOR], [
1380 LB_CHECK_COMPILE([if 'bio_end_sector' is defined],
1381 bio_end_sector, [
1382         #include <linux/bio.h>
1383 ],[
1384         struct bio bio;
1385
1386         bio_end_sector(&bio);
1387 ],[
1388         AC_DEFINE(HAVE_BIO_END_SECTOR, 1,
1389                   [bio_end_sector is defined])
1390 ])
1391 ]) # LC_HAVE_BIO_END_SECTOR
1392
1393 #
1394 # LC_HAVE_REMOVE_PROC_SUBTREE
1395 #
1396 # 3.10 introduced remove_proc_subtree
1397 #
1398 AC_DEFUN([LC_HAVE_REMOVE_PROC_SUBTREE], [
1399 LB_CHECK_COMPILE([if 'remove_proc_subtree' is defined],
1400 remove_proc_subtree, [
1401         #include <linux/proc_fs.h>
1402 ],[
1403         remove_proc_subtree(NULL, NULL);
1404 ], [
1405         AC_DEFINE(HAVE_REMOVE_PROC_SUBTREE, 1,
1406                   [remove_proc_subtree is defined])
1407 ])
1408 ]) # LC_HAVE_REMOVE_PROC_SUBTREE
1409
1410 #
1411 # LC_HAVE_PROC_REMOVE
1412 #
1413 # 3.10 introduced proc_remove
1414 #
1415 AC_DEFUN([LC_HAVE_PROC_REMOVE], [
1416 LB_CHECK_COMPILE([if 'proc_remove' is defined],
1417 proc_remove, [
1418         #include <linux/proc_fs.h>
1419 ],[
1420         proc_remove(NULL);
1421 ], [
1422         AC_DEFINE(HAVE_PROC_REMOVE, 1,
1423                   [proc_remove is defined])
1424 ])
1425 ]) # LC_HAVE_PROC_REMOVE
1426
1427 #
1428 # LC_BLKDEV_RELEASE_RETURN_INT
1429 #
1430 # 3.10 release for block device doesn't return int
1431 #
1432 AC_DEFUN([LC_BLKDEV_RELEASE_RETURN_INT], [
1433 LB_CHECK_COMPILE([if 'block_device_operations' release returns 'int'],
1434 block_device_ops_release_return_int, [
1435         #include <linux/blkdev.h>
1436 ],[
1437         struct block_device_operations fops;
1438         int i __attribute__ ((unused));
1439
1440         i = fops.release(NULL, 0);
1441 ],[
1442         AC_DEFINE(HAVE_BLKDEV_RELEASE_RETURN_INT, 1,
1443                 [block device release returns int])
1444 ])
1445 ]) # LC_BLKDEV_RELEASE_RETURN_INT
1446
1447 #
1448 # LC_INVALIDATE_RANGE
1449 #
1450 # 3.11 invalidatepage requires the length of the range to invalidate
1451 #
1452 AC_DEFUN([LC_INVALIDATE_RANGE], [
1453 LB_CHECK_COMPILE([if 'address_space_operations.invalidatepage' requires 3 arguments],
1454 address_space_ops_invalidatepage_3args, [
1455         #include <linux/fs.h>
1456 ],[
1457         struct address_space_operations a_ops;
1458         a_ops.invalidatepage(NULL, 0, 0);
1459 ],[
1460         AC_DEFINE(HAVE_INVALIDATE_RANGE, 1,
1461                 [address_space_operations.invalidatepage needs 3 arguments])
1462 ])
1463 ]) # LC_INVALIDATE_RANGE
1464
1465 #
1466 # LC_HAVE_DIR_CONTEXT
1467 #
1468 # 3.11 readdir now takes the new struct dir_context
1469 #
1470 AC_DEFUN([LC_HAVE_DIR_CONTEXT], [
1471 LB_CHECK_COMPILE([if 'dir_context' exist],
1472 dir_context, [
1473         #include <linux/fs.h>
1474 ],[
1475         struct dir_context ctx;
1476         ctx.pos = 0;
1477 ],[
1478         AC_DEFINE(HAVE_DIR_CONTEXT, 1,
1479                 [dir_context exist])
1480 ])
1481 ]) # LC_HAVE_DIR_CONTEXT
1482
1483 #
1484 # LC_D_COMPARE_5ARGS
1485 #
1486 # 3.11 dentry_operations.d_compare() taken 5 arguments.
1487 #
1488 AC_DEFUN([LC_D_COMPARE_5ARGS], [
1489 LB_CHECK_COMPILE([if 'd_compare' taken 5 arguments],
1490 d_compare_5args, [
1491         #include <linux/dcache.h>
1492 ],[
1493         ((struct dentry_operations*)0)->d_compare(NULL,NULL,0,NULL,NULL);
1494 ],[
1495         AC_DEFINE(HAVE_D_COMPARE_5ARGS, 1,
1496                 [d_compare need 5 arguments])
1497 ])
1498 ]) # LC_D_COMPARE_5ARGS
1499
1500 #
1501 # LC_HAVE_DCOUNT
1502 #
1503 # 3.11 need to access d_count to get dentry reference count
1504 #
1505 AC_DEFUN([LC_HAVE_DCOUNT], [
1506 LB_CHECK_COMPILE([if 'd_count' exist],
1507 d_count, [
1508         #include <linux/dcache.h>
1509 ],[
1510         struct dentry de;
1511         d_count(&de);
1512 ],[
1513         AC_DEFINE(HAVE_D_COUNT, 1,
1514                 [d_count exist])
1515 ])
1516 ]) # LC_HAVE_DCOUNT
1517
1518 #
1519 # LC_OLDSIZE_TRUNCATE_PAGECACHE
1520 #
1521 # 3.12 truncate_pagecache without oldsize parameter
1522 #
1523 AC_DEFUN([LC_OLDSIZE_TRUNCATE_PAGECACHE], [
1524 LB_CHECK_COMPILE([if 'truncate_pagecache' with 'old_size' parameter],
1525 truncate_pagecache_old_size, [
1526         #include <linux/mm.h>
1527 ],[
1528         truncate_pagecache(NULL, 0, 0);
1529 ],[
1530         AC_DEFINE(HAVE_OLDSIZE_TRUNCATE_PAGECACHE, 1,
1531                 [with oldsize])
1532 ])
1533 ]) # LC_OLDSIZE_TRUNCATE_PAGECACHE
1534
1535 #
1536 # LC_HAVE_DENTRY_D_U_D_ALIAS
1537 #
1538 # 3.11 kernel moved d_alias to the union d_u in struct dentry
1539 #
1540 # Some distros move d_alias to d_u but it is still a struct list
1541 #
1542 AC_DEFUN([LC_HAVE_DENTRY_D_U_D_ALIAS], [
1543 AS_IF([test "x$lb_cv_compile_i_dentry_d_alias_list" = xyes], [
1544         LB_CHECK_COMPILE([if list 'dentry.d_u.d_alias' exist],
1545         d_alias, [
1546                 #include <linux/list.h>
1547                 #include <linux/dcache.h>
1548         ],[
1549                 struct dentry de;
1550                 INIT_LIST_HEAD(&de.d_u.d_alias);
1551         ],[
1552                 AC_DEFINE(HAVE_DENTRY_D_U_D_ALIAS, 1,
1553                         [list dentry.d_u.d_alias exist])
1554         ])
1555 ],[
1556         LB_CHECK_COMPILE([if hlist 'dentry.d_u.d_alias' exist],
1557         d_alias, [
1558                 #include <linux/list.h>
1559                 #include <linux/dcache.h>
1560         ],[
1561                 struct dentry de;
1562                 INIT_HLIST_NODE(&de.d_u.d_alias);
1563         ],[
1564                 AC_DEFINE(HAVE_DENTRY_D_U_D_ALIAS, 1,
1565                         [hlist dentry.d_u.d_alias exist])
1566         ])
1567 ])
1568 ]) # LC_HAVE_DENTRY_D_U_D_ALIAS
1569
1570 #
1571 # LC_HAVE_DENTRY_D_CHILD
1572 #
1573 # 3.11 kernel d_child has been moved out of the union d_u
1574 # in struct dentry
1575 #
1576 AC_DEFUN([LC_HAVE_DENTRY_D_CHILD], [
1577 LB_CHECK_COMPILE([if 'dentry.d_child' exist],
1578 d_child, [
1579         #include <linux/list.h>
1580         #include <linux/dcache.h>
1581 ],[
1582         struct dentry de;
1583         INIT_LIST_HEAD(&de.d_child);
1584 ],[
1585         AC_DEFINE(HAVE_DENTRY_D_CHILD, 1,
1586                 [dentry.d_child exist])
1587 ])
1588 ]) # LC_HAVE_DENTRY_D_CHILD
1589
1590 #
1591 # LC_KIOCB_KI_LEFT
1592 #
1593 # 3.12 ki_left removed from struct kiocb
1594 #
1595 AC_DEFUN([LC_KIOCB_KI_LEFT], [
1596 LB_CHECK_COMPILE([if 'struct kiocb' with 'ki_left' member],
1597 kiocb_ki_left, [
1598         #include <linux/aio.h>
1599 ],[
1600         ((struct kiocb*)0)->ki_left = 0;
1601 ],[
1602         AC_DEFINE(HAVE_KIOCB_KI_LEFT, 1,
1603                 [ki_left exist])
1604 ])
1605 ]) # LC_KIOCB_KI_LEFT
1606
1607 #
1608 # LC_VFS_RENAME_5ARGS
1609 #
1610 # 3.13 has vfs_rename with 5 args
1611 #
1612 AC_DEFUN([LC_VFS_RENAME_5ARGS], [
1613 LB_CHECK_COMPILE([if Linux kernel has 'vfs_rename' with 5 args],
1614 vfs_rename_5args, [
1615         #include <linux/fs.h>
1616 ],[
1617         vfs_rename(NULL, NULL, NULL, NULL, NULL);
1618 ], [
1619         AC_DEFINE(HAVE_VFS_RENAME_5ARGS, 1,
1620                 [kernel has vfs_rename with 5 args])
1621 ])
1622 ]) # LC_VFS_RENAME_5ARGS
1623
1624 #
1625 # LC_VFS_UNLINK_3ARGS
1626 #
1627 # 3.13 has vfs_unlink with 3 args
1628 #
1629 AC_DEFUN([LC_VFS_UNLINK_3ARGS], [
1630 LB_CHECK_COMPILE([if Linux kernel has 'vfs_unlink' with 3 args],
1631 vfs_unlink_3args, [
1632         #include <linux/fs.h>
1633 ],[
1634         vfs_unlink(NULL, NULL, NULL);
1635 ], [
1636         AC_DEFINE(HAVE_VFS_UNLINK_3ARGS, 1,
1637                 [kernel has vfs_unlink with 3 args])
1638 ])
1639 ]) # LC_VFS_UNLINK_3ARGS
1640
1641 #
1642 # LC_HAVE_BVEC_ITER
1643 #
1644 # 3.14 move some of its data in struct bio into the new
1645 # struct bvec_iter
1646 #
1647 AC_DEFUN([LC_HAVE_BVEC_ITER], [
1648 LB_CHECK_COMPILE([if Linux kernel has struct bvec_iter],
1649 have_bvec_iter, [
1650         #include <linux/bio.h>
1651 ],[
1652         struct bvec_iter iter;
1653         iter.bi_bvec_done = 0;
1654 ], [
1655         AC_DEFINE(HAVE_BVEC_ITER, 1,
1656                 [kernel has struct bvec_iter])
1657 ])
1658 ]) # LC_HAVE_BVEC_ITER
1659
1660 #
1661 # LC_HAVE_TRUNCATE_IPAGE_FINAL
1662 #
1663 # 3.14 bring truncate_inode_pages_final for evict_inode
1664 #
1665 AC_DEFUN([LC_HAVE_TRUNCATE_IPAGES_FINAL], [
1666 LB_CHECK_COMPILE([if Linux kernel has truncate_inode_pages_final],
1667 truncate_ipages_final, [
1668         #include <linux/mm.h>
1669 ],[
1670         truncate_inode_pages_final(NULL);
1671 ], [
1672         AC_DEFINE(HAVE_TRUNCATE_INODE_PAGES_FINAL, 1,
1673                 [kernel has truncate_inode_pages_final])
1674 ])
1675 ]) # LC_HAVE_TRUNCATE_IPAGES_FINAL
1676
1677 #
1678 # LC_VFS_RENAME_6ARGS
1679 #
1680 # 3.15 has vfs_rename with 6 args
1681 #
1682 AC_DEFUN([LC_VFS_RENAME_6ARGS], [
1683 LB_CHECK_COMPILE([if Linux kernel has 'vfs_rename' with 6 args],
1684 vfs_rename_6args, [
1685         #include <linux/fs.h>
1686 ],[
1687         vfs_rename(NULL, NULL, NULL, NULL, NULL, NULL);
1688 ], [
1689         AC_DEFINE(HAVE_VFS_RENAME_6ARGS, 1,
1690                 [kernel has vfs_rename with 6 args])
1691 ])
1692 ]) # LC_VFS_RENAME_6ARGS
1693
1694 #
1695 # LC_DIRECTIO_USE_ITER
1696 #
1697 # 3.16 kernel changes direct IO to use iov_iter
1698 #
1699 AC_DEFUN([LC_DIRECTIO_USE_ITER], [
1700 LB_CHECK_COMPILE([if direct IO uses iov_iter],
1701 direct_io_iter, [
1702         #include <linux/fs.h>
1703 ],[
1704         struct address_space_operations ops;
1705         struct iov_iter *iter = NULL;
1706         loff_t offset = 0;
1707
1708         ops.direct_IO(0, NULL, iter, offset);
1709 ],[
1710         AC_DEFINE(HAVE_DIRECTIO_ITER, 1,
1711                 [direct IO uses iov_iter])
1712 ])
1713 ]) # LC_DIRECTIO_USE_ITER
1714
1715 #
1716 # LC_HAVE_IOV_ITER_INIT_DIRECTION
1717 #
1718 #
1719 # 3.16 linux commit 71d8e532b1549a478e6a6a8a44f309d050294d00
1720 #      changed iov_iter_init api to start accepting a tag
1721 #      that defines if its a read or write operation
1722 #
1723 AC_DEFUN([LC_HAVE_IOV_ITER_INIT_DIRECTION], [
1724 tmp_flags="$EXTRA_KCFLAGS"
1725 EXTRA_KCFLAGS="-Werror"
1726 LB_CHECK_COMPILE([if 'iov_iter_init' takes a tag],
1727 iter_init, [
1728         #include <linux/uio.h>
1729         #include <linux/fs.h>
1730 ],[
1731         const struct iovec *iov = NULL;
1732
1733         iov_iter_init(NULL, READ, iov, 1, 0);
1734 ],[
1735         AC_DEFINE(HAVE_IOV_ITER_INIT_DIRECTION, 1,
1736                 [iov_iter_init handles directional tag])
1737 ])
1738 EXTRA_KCFLAGS="$tmp_flags"
1739 ]) # LC_HAVE_IOV_ITER_INIT_DIRECTION
1740
1741 #
1742 # LC_HAVE_IOV_ITER_TRUNCATE
1743 #
1744 #
1745 # 3.16 introduces a new API iov_iter_truncate()
1746 #
1747 AC_DEFUN([LC_HAVE_IOV_ITER_TRUNCATE], [
1748 tmp_flags="$EXTRA_KCFLAGS"
1749 EXTRA_KCFLAGS="-Werror"
1750 LB_CHECK_COMPILE([if 'iov_iter_truncate' exists ],
1751 iter_truncate, [
1752         #include <linux/uio.h>
1753         #include <linux/fs.h>
1754 ],[
1755         struct iov_iter *i = NULL;
1756
1757         iov_iter_truncate(i, 0);
1758 ],[
1759         AC_DEFINE(HAVE_IOV_ITER_TRUNCATE, 1, [iov_iter_truncate exists])
1760 ])
1761 EXTRA_KCFLAGS="$tmp_flags"
1762 ]) # LC_HAVE_IOV_ITER_TRUNCATE
1763
1764 #
1765 # LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
1766 #
1767 # 3.16 introduces [read|write]_iter to struct file_operations
1768 #
1769 AC_DEFUN([LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER], [
1770 LB_CHECK_COMPILE([if 'file_operations.[read|write]_iter' exist],
1771 file_function_iter, [
1772         #include <linux/fs.h>
1773 ],[
1774         ((struct file_operations *)NULL)->read_iter(NULL, NULL);
1775         ((struct file_operations *)NULL)->write_iter(NULL, NULL);
1776 ],[
1777         AC_DEFINE(HAVE_FILE_OPERATIONS_READ_WRITE_ITER, 1,
1778                 [file_operations.[read|write]_iter functions exist])
1779 ])
1780 ]) # LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
1781
1782 #
1783 # LC_KEY_MATCH_DATA
1784 #
1785 # 3.17  replaces key_type::match with match_preparse
1786 #       and has new struct key_match_data
1787 #
1788 AC_DEFUN([LC_KEY_MATCH_DATA], [
1789 LB_CHECK_COMPILE([if struct key_match field exist],
1790 key_match, [
1791         #include <linux/key-type.h>
1792 ],[
1793         struct key_match_data data;
1794 ],[
1795         AC_DEFINE(HAVE_KEY_MATCH_DATA, 1,
1796                 [struct key_match_data exist])
1797 ])
1798 ]) # LC_KEY_MATCH_DATA
1799
1800 #
1801 # LC_NFS_FILLDIR_USE_CTX
1802 #
1803 # 3.18 kernel moved from void cookie to struct dir_context
1804 #
1805 AC_DEFUN([LC_NFS_FILLDIR_USE_CTX], [
1806 tmp_flags="$EXTRA_KCFLAGS"
1807 EXTRA_KCFLAGS="-Werror"
1808 LB_CHECK_COMPILE([if filldir_t uses struct dir_context],
1809 filldir_ctx, [
1810         #include <linux/fs.h>
1811 ],[
1812         int filldir(struct dir_context *ctx, const char* name,
1813                     int i, loff_t off, u64 tmp, unsigned temp)
1814         {
1815                 return 0;
1816         }
1817
1818         struct dir_context ctx = {
1819                 .actor = filldir,
1820         };
1821
1822         ctx.actor(NULL, "test", 0, (loff_t) 0, 0, 0);
1823 ],[
1824         AC_DEFINE(HAVE_FILLDIR_USE_CTX, 1,
1825                 [filldir_t needs struct dir_context as argument])
1826 ])
1827 EXTRA_KCFLAGS="$tmp_flags"
1828 ]) # LC_NFS_FILLDIR_USE_CTX
1829
1830 #
1831 # LC_PERCPU_COUNTER_INIT
1832 #
1833 # 3.18  For kernels 3.18 and after percpu_counter_init starts
1834 #       to pass a GFP_* memory allocation flag for internal
1835 #       memory allocation purposes.
1836 #
1837 AC_DEFUN([LC_PERCPU_COUNTER_INIT], [
1838 LB_CHECK_COMPILE([if percpu_counter_init uses GFP_* flag as argument],
1839 percpu_counter_init, [
1840         #include <linux/percpu_counter.h>
1841 ],[
1842         percpu_counter_init(NULL, 0, GFP_KERNEL);
1843 ],[
1844         AC_DEFINE(HAVE_PERCPU_COUNTER_INIT_GFP_FLAG, 1,
1845                 [percpu_counter_init uses GFP_* flag])
1846 ])
1847 ]) # LC_PERCPU_COUNTER_INIT
1848
1849 #
1850 # LC_KIOCB_HAS_NBYTES
1851 #
1852 # 3.19 kernel removed ki_nbytes from struct kiocb
1853 #
1854 AC_DEFUN([LC_KIOCB_HAS_NBYTES], [
1855 LB_CHECK_COMPILE([if struct kiocb has ki_nbytes field],
1856 ki_nbytes, [
1857         #include <linux/fs.h>
1858 ],[
1859         struct kiocb iocb;
1860
1861         iocb.ki_nbytes = 0;
1862 ],[
1863         AC_DEFINE(HAVE_KI_NBYTES, 1, [ki_nbytes field exist])
1864 ])
1865 ]) # LC_KIOCB_HAS_NBYTES
1866
1867 #
1868 # LC_BACKING_DEV_INFO_REMOVAL
1869 #
1870 # 3.20 kernel removed backing_dev_info from address_space
1871 #
1872 AC_DEFUN([LC_BACKING_DEV_INFO_REMOVAL], [
1873 LB_CHECK_COMPILE([if struct address_space has backing_dev_info],
1874 backing_dev_info, [
1875         #include <linux/fs.h>
1876 ],[
1877         struct address_space mapping;
1878
1879         mapping.backing_dev_info = NULL;
1880 ],[
1881         AC_DEFINE(HAVE_BACKING_DEV_INFO, 1, [backing_dev_info exist])
1882 ])
1883 ]) # LC_BACKING_DEV_INFO_REMOVAL
1884
1885 #
1886 # LC_HAVE_BDI_CAP_MAP_COPY
1887 #
1888 # 3.20  removed mmap handling for backing devices since
1889 #       it breaks on non-MMU systems. See kernel commit
1890 #       b4caecd48005fbed3949dde6c1cb233142fd69e9
1891 #
1892 AC_DEFUN([LC_HAVE_BDI_CAP_MAP_COPY], [
1893 LB_CHECK_COMPILE([if have 'BDI_CAP_MAP_COPY'],
1894 bdi_cap_map_copy, [
1895         #include <linux/backing-dev.h>
1896 ],[
1897         struct backing_dev_info info;
1898
1899         info.capabilities = BDI_CAP_MAP_COPY;
1900 ],[
1901         AC_DEFINE(HAVE_BDI_CAP_MAP_COPY, 1,
1902                 [BDI_CAP_MAP_COPY exist])
1903 ])
1904 ]) # LC_HAVE_BDI_CAP_MAP_COPY
1905
1906 #
1907 # LC_CANCEL_DIRTY_PAGE
1908 #
1909 # 4.0.0 kernel removed cancel_dirty_page
1910 #
1911 AC_DEFUN([LC_CANCEL_DIRTY_PAGE], [
1912 LB_CHECK_COMPILE([if cancel_dirty_page still exist],
1913 cancel_dirty_page, [
1914         #include <linux/mm.h>
1915 ],[
1916         cancel_dirty_page(NULL, PAGE_SIZE);
1917 ],[
1918         AC_DEFINE(HAVE_CANCEL_DIRTY_PAGE, 1,
1919                 [cancel_dirty_page is still available])
1920 ])
1921 ]) # LC_CANCEL_DIRTY_PAGE
1922
1923 #
1924 # LC_IOV_ITER_RW
1925 #
1926 # 4.1 kernel has iov_iter_rw
1927 #
1928 AC_DEFUN([LC_IOV_ITER_RW], [
1929 LB_CHECK_COMPILE([if iov_iter_rw exist],
1930 iov_iter_rw, [
1931         #include <linux/fs.h>
1932         #include <linux/uio.h>
1933 ],[
1934         struct iov_iter *iter = NULL;
1935
1936         iov_iter_rw(iter);
1937 ],[
1938         AC_DEFINE(HAVE_IOV_ITER_RW, 1,
1939                 [iov_iter_rw exist])
1940 ])
1941 ]) # LC_IOV_ITER_RW
1942
1943 #
1944 # LC_HAVE_SYNC_READ_WRITE
1945 #
1946 # 4.1 new_sync_[read|write] no longer exported
1947 #
1948 AC_DEFUN([LC_HAVE_SYNC_READ_WRITE], [
1949 LB_CHECK_EXPORT([new_sync_read], [fs/read_write.c],
1950         [AC_DEFINE(HAVE_SYNC_READ_WRITE, 1,
1951                         [new_sync_[read|write] is exported by the kernel])])
1952 ]) # LC_HAVE_SYNC_READ_WRITE
1953
1954 #
1955 # LC_NEW_CANCEL_DIRTY_PAGE
1956 #
1957 # 4.2 kernel has new cancel_dirty_page
1958 #
1959 AC_DEFUN([LC_NEW_CANCEL_DIRTY_PAGE], [
1960 LB_CHECK_COMPILE([if cancel_dirty_page with one argument exist],
1961 new_cancel_dirty_page, [
1962         #include <linux/mm.h>
1963 ],[
1964         cancel_dirty_page(NULL);
1965 ],[
1966         AC_DEFINE(HAVE_NEW_CANCEL_DIRTY_PAGE, 1,
1967                 [cancel_dirty_page with one arguement is available])
1968 ])
1969 ]) # LC_NEW_CANCEL_DIRTY_PAGE
1970
1971 #
1972 # LC_SYMLINK_OPS_USE_NAMEIDATA
1973 #
1974 # For the 4.2+ kernels the file system internal symlink api no
1975 # longer uses struct nameidata as a argument
1976 #
1977 AC_DEFUN([LC_SYMLINK_OPS_USE_NAMEIDATA], [
1978 LB_CHECK_COMPILE([if symlink inode operations have struct nameidata argument],
1979 symlink_use_nameidata, [
1980         #include <linux/namei.h>
1981         #include <linux/fs.h>
1982 ],[
1983         struct nameidata *nd = NULL;
1984
1985         ((struct inode_operations *)0)->follow_link(NULL, nd);
1986         ((struct inode_operations *)0)->put_link(NULL, nd, NULL);
1987 ],[
1988         AC_DEFINE(HAVE_SYMLINK_OPS_USE_NAMEIDATA, 1,
1989                 [symlink inode operations need struct nameidata argument])
1990 ])
1991 ]) # LC_SYMLINK_OPS_USE_NAMEIDATA
1992
1993 #
1994 # LC_BIO_ENDIO_USES_ONE_ARG
1995 #
1996 # 4.2 kernel bio_endio now only takes one argument
1997 #
1998 AC_DEFUN([LC_BIO_ENDIO_USES_ONE_ARG], [
1999 LB_CHECK_COMPILE([if 'bio_endio' with one argument exist],
2000 bio_endio, [
2001         #include <linux/bio.h>
2002 ],[
2003         bio_endio(NULL);
2004 ],[
2005         AC_DEFINE(HAVE_BIO_ENDIO_USES_ONE_ARG, 1,
2006                 [bio_endio takes only one argument])
2007 ])
2008 ]) # LC_BIO_ENDIO_USES_ONE_ARG
2009
2010 #
2011 # LC_HAVE_LOOP_CTL_GET_FREE
2012 #
2013 # 4.x kernel have moved userspace APIs to
2014 # the separate directory and all of them
2015 # support LOOP_CTL_GET_FREE
2016 #
2017 AC_DEFUN([LC_HAVE_LOOP_CTL_GET_FREE], [
2018 LB_CHECK_FILE([$LINUX/include/linux/loop.h], [
2019         LB_CHECK_COMPILE([if have 'HAVE_LOOP_CTL_GET_FREE'],
2020         LOOP_CTL_GET_FREE, [
2021                 #include <linux/loop.h>
2022         ],[
2023                 int i;
2024
2025                 i = LOOP_CTL_GET_FREE;
2026         ],[
2027                 AC_DEFINE(HAVE_LOOP_CTL_GET_FREE, 1,
2028                         [LOOP_CTL_GET_FREE exist])
2029         ])
2030 ],[
2031         AC_DEFINE(HAVE_LOOP_CTL_GET_FREE, 1,
2032                 [kernel has LOOP_CTL_GET_FREE])
2033 ])
2034 ]) # LC_HAVE_LOOP_CTL_GET_FREE
2035
2036 #
2037 # LC_HAVE_CACHE_HEAD_HLIST
2038 #
2039 # 4.3 kernel swiched to hlist for cache_head
2040 #
2041 AC_DEFUN([LC_HAVE_CACHE_HEAD_HLIST], [
2042 LB_CHECK_COMPILE([if 'struct cache_head' has 'cache_list' field],
2043 cache_head_has_hlist, [
2044         #include <linux/sunrpc/cache.h>
2045 ],[
2046         do {} while(sizeof(((struct cache_head *)0)->cache_list));
2047 ],[
2048         AC_DEFINE(HAVE_CACHE_HEAD_HLIST, 1,
2049                 [cache_head has hlist cache_list])
2050 ])
2051 ]) # LC_HAVE_CACHE_HEAD_HLIST
2052
2053 #
2054 # LC_HAVE_LOCKS_LOCK_FILE_WAIT
2055 #
2056 # 4.4 kernel have moved locks API users to
2057 # locks_lock_inode_wait()
2058 #
2059 AC_DEFUN([LC_HAVE_LOCKS_LOCK_FILE_WAIT], [
2060 LB_CHECK_COMPILE([if 'locks_lock_file_wait' exists],
2061 locks_lock_file_wait, [
2062         #include <linux/fs.h>
2063 ],[
2064         locks_lock_file_wait(NULL, NULL);
2065 ],[
2066         AC_DEFINE(HAVE_LOCKS_LOCK_FILE_WAIT, 1,
2067                 [kernel has locks_lock_file_wait])
2068 ])
2069 ]) # LC_HAVE_LOCKS_LOCK_FILE_WAIT
2070
2071 #
2072 # LC_HAVE_QC_MAKE_REQUEST_FN
2073 #
2074 # 4.4 request_queue.make_request_fn defined as function returns with blk_qc_t
2075 # see kernel commit dece16353ef47d8d33f5302bc158072a9d65e26f
2076 #
2077 AC_DEFUN([LC_HAVE_QC_MAKE_REQUEST_FN], [
2078 LB_CHECK_COMPILE([if 'request_queue.make_request_fn' returns blk_qc_t],
2079 make_request_fn_blk_qc_t, [
2080         #include <linux/blkdev.h>
2081 ],[
2082         blk_qc_t ret;
2083         make_request_fn *mrf;
2084         ret = mrf(NULL, NULL);
2085 ],[
2086         AC_DEFINE(HAVE_QC_MAKE_REQUEST_FN, 1,
2087                 [request_queue.make_request_fn returns blk_qc_t])
2088 ])
2089 ]) # LC_HAVE_QC_MAKE_REQUEST_FN
2090
2091 #
2092 # LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
2093 #
2094 # 4.4 kernel merged type-specific data with the payload data for keys
2095 #
2096 AC_DEFUN([LC_HAVE_KEY_PAYLOAD_DATA_ARRAY], [
2097 LB_CHECK_COMPILE([if 'struct key' has 'payload.data' as an array],
2098 key_payload_data_array, [
2099         #include <linux/key.h>
2100 ],[
2101         ((struct key *)0)->payload.data[0] = NULL;
2102 ],[
2103         AC_DEFINE(HAVE_KEY_PAYLOAD_DATA_ARRAY, 1, [payload.data is an array])
2104 ])
2105 ]) #LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
2106
2107 #
2108 # LC_PROG_LINUX
2109 #
2110 # Lustre linux kernel checks
2111 #
2112 AC_DEFUN([LC_PROG_LINUX], [
2113         AC_MSG_NOTICE([Lustre kernel checks
2114 ==============================================================================])
2115
2116         LC_CONFIG_PINGER
2117         LC_CONFIG_CHECKSUM
2118         LC_CONFIG_HEALTH_CHECK_WRITE
2119         LC_CONFIG_LRU_RESIZE
2120         LC_LLITE_LLOOP_MODULE
2121
2122         LC_GLIBC_SUPPORT_FHANDLES
2123         LC_CONFIG_RMTCLIENT
2124         LC_CONFIG_GSS
2125         LC_HAVE_VOID_OPENSSL_HMAC_FUNCS
2126
2127         # 2.6.32
2128         LC_BLK_QUEUE_MAX_SEGMENTS
2129
2130         # 2.6.34
2131         LC_HAVE_DQUOT_FS_DISK_QUOTA
2132         LC_HAVE_DQUOT_SUSPEND
2133         LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE
2134
2135         # 2.6.35, 3.0.0
2136         LC_FILE_FSYNC
2137         LC_EXPORT_SIMPLE_SETATTR
2138         LC_EXPORT_TRUNCATE_COMPLETE_PAGE
2139
2140         # 2.6.36
2141         LC_FS_STRUCT_RWLOCK
2142         LC_SBOPS_EVICT_INODE
2143
2144         # 2.6.37
2145         LC_KERNEL_LOCKED
2146
2147         # 2.6.38
2148         LC_BLKDEV_GET_BY_DEV
2149         LC_GENERIC_PERMISSION
2150         LC_DCACHE_LOCK
2151         LC_INODE_I_RCU
2152         LC_D_COMPARE_7ARGS
2153         LC_D_DELETE_CONST
2154
2155         # 2.6.39
2156         LC_REQUEST_QUEUE_UNPLUG_FN
2157         LC_HAVE_FHANDLE_SYSCALLS
2158         LC_HAVE_FSTYPE_MOUNT
2159         LC_IOP_TRUNCATE
2160         LC_HAVE_INODE_OWNER_OR_CAPABLE
2161         LC_HAVE_SECURITY_IINITSEC
2162
2163         # 3.0
2164         LC_DIRTY_INODE_WITH_FLAG
2165
2166         # 3.1
2167         LC_LM_XXX_LOCK_MANAGER_OPS
2168         LC_INODE_DIO_WAIT
2169         LC_IOP_GET_ACL
2170         LC_FILE_LLSEEK_SIZE
2171         LC_INODE_PERMISION_2ARGS
2172         LC_RADIX_EXCEPTION_ENTRY
2173         LC_HAVE_LOOP_CTL_GET_FREE
2174
2175         # 3.2
2176         LC_HAVE_VOID_MAKE_REQUEST_FN
2177         LC_HAVE_PROTECT_I_NLINK
2178
2179         # 3.3
2180         LC_HAVE_MIGRATE_HEADER
2181         LC_MIGRATEPAGE_4ARGS
2182         LC_SUPEROPS_USE_DENTRY
2183         LC_INODEOPS_USE_UMODE_T
2184         LC_HAVE_CACHE_REGISTER
2185
2186         # 3.4
2187         LC_HAVE_D_MAKE_ROOT
2188         LC_KMAP_ATOMIC_HAS_1ARG
2189
2190         # 3.5
2191         LC_HAVE_CLEAR_INODE
2192         LC_HAVE_ENCODE_FH_PARENT
2193         LC_FILE_LLSEEK_SIZE_5ARG
2194
2195         # 3.6
2196         LC_DATA_FOR_LLITE_IS_LIST
2197         LC_DENTRY_OPEN_USE_PATH
2198         LC_HAVE_IOP_ATOMIC_OPEN
2199         LC_HAVE_SB_START_WRITE
2200
2201         # 3.7
2202         LC_HAVE_POSIXACL_USER_NS
2203
2204         # 3.8
2205         LC_HAVE_FILE_F_INODE
2206         LC_HAVE_FILE_INODE
2207         LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS
2208
2209         # 3.9
2210         LC_HAVE_HLIST_FOR_EACH_3ARG
2211         LC_HAVE_BIO_END_SECTOR
2212
2213         # 3.10
2214         LC_BLKDEV_RELEASE_RETURN_INT
2215         LC_HAVE_REMOVE_PROC_SUBTREE
2216         LC_HAVE_PROC_REMOVE
2217
2218         # 3.11
2219         LC_INVALIDATE_RANGE
2220         LC_HAVE_DIR_CONTEXT
2221         LC_D_COMPARE_5ARGS
2222         LC_HAVE_DCOUNT
2223         LC_HAVE_DENTRY_D_U_D_ALIAS
2224         LC_HAVE_DENTRY_D_CHILD
2225
2226         # 3.12
2227         LC_OLDSIZE_TRUNCATE_PAGECACHE
2228         LC_KIOCB_KI_LEFT
2229
2230         # 3.13
2231         LC_VFS_RENAME_5ARGS
2232         LC_VFS_UNLINK_3ARGS
2233
2234         # 3.14
2235         LC_HAVE_BVEC_ITER
2236         LC_HAVE_TRUNCATE_IPAGES_FINAL
2237
2238         # 3.15
2239         LC_VFS_RENAME_6ARGS
2240
2241         # 3.16
2242         LC_DIRECTIO_USE_ITER
2243         LC_HAVE_IOV_ITER_INIT_DIRECTION
2244         LC_HAVE_IOV_ITER_TRUNCATE
2245         LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
2246
2247         # 3.17
2248         LC_KEY_MATCH_DATA
2249
2250         # 3.18
2251         LC_PERCPU_COUNTER_INIT
2252         LC_NFS_FILLDIR_USE_CTX
2253
2254         # 3.19
2255         LC_KIOCB_HAS_NBYTES
2256
2257         # 3.20
2258         LC_BACKING_DEV_INFO_REMOVAL
2259         LC_HAVE_BDI_CAP_MAP_COPY
2260
2261         # 4.0.0
2262         LC_CANCEL_DIRTY_PAGE
2263
2264         # 4.1.0
2265         LC_IOV_ITER_RW
2266         LC_HAVE_SYNC_READ_WRITE
2267
2268         # 4.2
2269         LC_NEW_CANCEL_DIRTY_PAGE
2270         LC_BIO_ENDIO_USES_ONE_ARG
2271         LC_SYMLINK_OPS_USE_NAMEIDATA
2272
2273         # 4.3
2274         LC_HAVE_CACHE_HEAD_HLIST
2275
2276         # 4.4
2277         LC_HAVE_LOCKS_LOCK_FILE_WAIT
2278         LC_HAVE_QC_MAKE_REQUEST_FN
2279         LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
2280
2281         #
2282         AS_IF([test "x$enable_server" != xno], [
2283                 LC_FUNC_DEV_SET_RDONLY
2284                 LC_STACK_SIZE
2285                 LC_QUOTA64
2286                 LC_QUOTA_CONFIG
2287         ])
2288 ]) # LC_PROG_LINUX
2289
2290 #
2291 # LC_CONFIG_CLIENT
2292 #
2293 # Check whether to build the client side of Lustre
2294 #
2295 AC_DEFUN([LC_CONFIG_CLIENT], [
2296 AC_MSG_CHECKING([whether to build Lustre client support])
2297 AC_ARG_ENABLE([client],
2298         AC_HELP_STRING([--disable-client],
2299                 [disable Lustre client support]),
2300         [], [enable_client="yes"])
2301 AC_MSG_RESULT([$enable_client])
2302 ]) # LC_CONFIG_CLIENT
2303
2304 #
2305 # --enable-mpitests
2306 #
2307 AC_DEFUN([LB_CONFIG_MPITESTS], [
2308 AC_ARG_ENABLE([mpitests],
2309         AC_HELP_STRING([--enable-mpitests=<yes|no|mpicc wrapper>],
2310                        [include mpi tests]), [
2311                 enable_mpitests="yes"
2312                 case $enableval in
2313                 yes)
2314                         MPICC_WRAPPER="mpicc"
2315                         ;;
2316                 no)
2317                         enable_mpitests="no"
2318                         ;;
2319                 *)
2320                         MPICC_WRAPPER=$enableval
2321                         ;;
2322                 esac
2323         ], [
2324                 enable_mpitests="yes"
2325                 MPICC_WRAPPER="mpicc"
2326         ])
2327
2328         if test "x$enable_mpitests" != "xno"; then
2329                 oldcc=$CC
2330                 CC=$MPICC_WRAPPER
2331                 AC_CACHE_CHECK([whether mpitests can be built],
2332                 lb_cv_mpi_tests, [AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2333                         #include <mpi.h>
2334                         int main(void) {
2335                                 int flag;
2336                                 MPI_Initialized(&flag);
2337                                 return 0;
2338                         }
2339                 ])], [lb_cv_mpi_tests="yes"], [lb_cv_mpi_tests="no"])
2340                 ])
2341                 enable_mpitests=$lb_cv_mpi_tests
2342                 CC=$oldcc
2343         fi
2344         AC_SUBST(MPICC_WRAPPER)
2345 ]) # LB_CONFIG_MPITESTS
2346
2347 #
2348 # LC_CONFIG_QUOTA
2349 #
2350 # whether to enable quota support global control
2351 #
2352 AC_DEFUN([LC_CONFIG_QUOTA], [
2353 AC_MSG_CHECKING([whether to enable quota support global control])
2354 AC_ARG_ENABLE([quota],
2355         AC_HELP_STRING([--enable-quota],
2356                 [enable quota support]),
2357         [], [enable_quota="yes"])
2358 AS_IF([test "x$enable_quota" = xyes],
2359         [AC_MSG_RESULT([yes])],
2360         [AC_MSG_RESULT([no])])
2361 ]) # LC_CONFIG_QUOTA
2362
2363 #
2364 # LC_QUOTA
2365 #
2366 AC_DEFUN([LC_QUOTA], [
2367 #check global
2368 LC_CONFIG_QUOTA
2369 #check for utils
2370 AS_IF([test "x$enable_quota" != xno -a "x$enable_utils" != xno], [
2371         AC_CHECK_HEADER([sys/quota.h],
2372                 [AC_DEFINE(HAVE_SYS_QUOTA_H, 1,
2373                         [Define to 1 if you have <sys/quota.h>.])],
2374                 [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
2375 ])
2376 ]) # LC_QUOTA
2377
2378 #
2379 # LC_CONFIG_NODEMAP_PROC_DEBUG
2380 #
2381 # enable nodemap proc file debugging
2382 #
2383 AC_DEFUN([LC_NODEMAP_PROC_DEBUG], [
2384 AC_MSG_CHECKING([whether to enable nodemap proc debug])
2385 AC_ARG_ENABLE([nodemap_proc_debug],
2386         AC_HELP_STRING([--enable-nodemap-proc-debug],
2387                 [enable nodemap proc debug]),
2388         [], [enable_nodemap_proc_debug="no"])
2389 AC_MSG_RESULT([$enable_nodemap_proc_debug])
2390 AS_IF([test "x$enable_nodemap_proc_debug" != xno],
2391         [AC_DEFINE(NODEMAP_PROC_DEBUG, 1,
2392                 [enable nodemap proc debug support])])
2393 ]) # LC_NODEMAP_PROC_DEBUG
2394
2395 #
2396 # LC_LLITE_LLOOP_MODULE
2397 #
2398 # lloop_llite.ko does not currently work with page sizes
2399 # of 64k or larger.
2400 #
2401 AC_DEFUN([LC_LLITE_LLOOP_MODULE], [
2402 LB_CHECK_COMPILE([whether to enable 'llite_lloop' module],
2403 enable_llite_lloop_module, [
2404         #include <asm/page.h>
2405 ],[
2406         #if PAGE_SIZE >= 65536
2407         #error "PAGE_SIZE >= 65536"
2408         #endif
2409 ],
2410         [enable_llite_lloop_module="yes"],
2411         [enable_llite_lloop_module="no"])
2412 ]) # LC_LLITE_LLOOP_MODULE
2413
2414 #
2415 # LC_OSD_ADDON
2416 #
2417 # configure support for optional OSD implementation
2418 #
2419 AC_DEFUN([LC_OSD_ADDON], [
2420 AC_MSG_CHECKING([whether to use OSD addon])
2421 AC_ARG_WITH([osd],
2422         AC_HELP_STRING([--with-osd=path],
2423                 [set path to optional osd]),
2424         [
2425         case "$with_osd" in
2426         no)
2427                 ENABLEOSDADDON=0
2428                 ;;
2429         *)
2430                 OSDADDON="$with_osd"
2431                 ENABLEOSDADDON=1
2432                 ;;
2433         esac
2434         ], [
2435                 ENABLEOSDADDON=0
2436         ])
2437 AS_IF([test $ENABLEOSDADDON -eq 0], [
2438         AC_MSG_RESULT([no])
2439         OSDADDON=""
2440 ], [
2441         OSDMODNAME=$(basename $OSDADDON)
2442         AS_IF([test -e $LUSTRE/$OSDMODNAME], [
2443                 AC_MSG_RESULT([can't link])
2444                 OSDADDON=""
2445         ], [ln -s $OSDADDON $LUSTRE/$OSDMODNAME], [
2446                 AC_MSG_RESULT([$OSDMODNAME])
2447                 OSDADDON="subdir-m += $OSDMODNAME"
2448         ], [
2449                 AC_MSG_RESULT([can't link])
2450                 OSDADDON=""
2451         ])
2452 ])
2453 AC_SUBST(OSDADDON)
2454 ]) # LC_OSD_ADDON
2455
2456 #
2457 # LC_CONFIGURE
2458 #
2459 # other configure checks
2460 #
2461 AC_DEFUN([LC_CONFIGURE], [
2462 AC_MSG_NOTICE([Lustre core checks
2463 ==============================================================================])
2464
2465 LC_CONFIG_OBD_BUFFER_SIZE
2466
2467 AS_IF([test $target_cpu == "i686" -o $target_cpu == "x86_64"],
2468         [CFLAGS="$CFLAGS -Wall -Werror"])
2469
2470 # maximum MDS thread count
2471 LC_MDS_MAX_THREADS
2472
2473 # lustre/utils/gss/gss_util.c
2474 # lustre/utils/gss/gssd_proc.c
2475 # lustre/utils/gss/krb5_util.c
2476 # lustre/utils/llog_reader.c
2477 # lustre/utils/create_iam.c
2478 # lustre/utils/libiam.c
2479 AC_CHECK_HEADERS([netdb.h endian.h])
2480 AC_CHECK_FUNCS([gethostbyname])
2481
2482 # lustre/utils/llverdev.c
2483 AC_CHECK_HEADERS([blkid/blkid.h])
2484
2485 # lustre/utils/llverfs.c
2486 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
2487
2488 SELINUX=""
2489 AC_CHECK_LIB([selinux], [is_selinux_enabled],
2490         [AC_CHECK_HEADERS([selinux/selinux.h],
2491                         [SELINUX="-lselinux"
2492                         AC_DEFINE([HAVE_SELINUX], 1,
2493                                 [support for selinux ])],
2494                         [AC_MSG_WARN([
2495
2496 No libselinux-devel package found, unable to build selinux enabled tools
2497 ])
2498 ])],
2499         [AC_MSG_WARN([
2500
2501 No selinux package found, unable to build selinux enabled tools
2502 ])
2503 ])
2504 AC_SUBST(SELINUX)
2505
2506 # Super safe df
2507 AC_MSG_CHECKING([whether to report minimum OST free space])
2508 AC_ARG_ENABLE([mindf],
2509         AC_HELP_STRING([--enable-mindf],
2510                 [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
2511         [], [enable_mindf="no"])
2512 AC_MSG_RESULT([$enable_mindf])
2513 AS_IF([test "$enable_mindf" = "yes"],
2514         [AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])])
2515
2516 AC_MSG_CHECKING([whether to randomly failing memory alloc])
2517 AC_ARG_ENABLE([fail_alloc],
2518         AC_HELP_STRING([--disable-fail-alloc],
2519                 [disable randomly alloc failure]),
2520         [], [enable_fail_alloc="yes"])
2521 AC_MSG_RESULT([$enable_fail_alloc])
2522 AS_IF([test "x$enable_fail_alloc" != xno],
2523         [AC_DEFINE([RANDOM_FAIL_ALLOC], 1,
2524                 [enable randomly alloc failure])])
2525
2526 AC_MSG_CHECKING([whether to check invariants (expensive cpu-wise)])
2527 AC_ARG_ENABLE([invariants],
2528         AC_HELP_STRING([--enable-invariants],
2529                 [enable invariant checking (cpu intensive)]),
2530         [], [enable_invariants="no"])
2531 AC_MSG_RESULT([$enable_invariants])
2532 AS_IF([test "x$enable_invariants" = xyes],
2533         [AC_DEFINE([CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK], 1,
2534                 [enable invariant checking])])
2535
2536 AC_MSG_CHECKING([whether to track references with lu_ref])
2537 AC_ARG_ENABLE([lu_ref],
2538         AC_HELP_STRING([--enable-lu_ref],
2539                 [enable lu_ref reference tracking code]),
2540         [], [enable_lu_ref="no"])
2541 AC_MSG_RESULT([$enable_lu_ref])
2542 AS_IF([test "x$enable_lu_ref" = xyes],
2543         [AC_DEFINE([USE_LU_REF], 1,
2544                 [enable lu_ref reference tracking code])])
2545
2546 AC_MSG_CHECKING([whether to enable page state tracking])
2547 AC_ARG_ENABLE([pgstate-track],
2548         AC_HELP_STRING([--enable-pgstate-track],
2549                 [enable page state tracking]),
2550         [], [enable_pgstat_track="no"])
2551 AC_MSG_RESULT([$enable_pgstat_track])
2552 AS_IF([test "x$enable_pgstat_track" = xyes],
2553         [AC_DEFINE([CONFIG_DEBUG_PAGESTATE_TRACKING], 1,
2554                 [enable page state tracking code])])
2555 ]) # LC_CONFIGURE
2556
2557 #
2558 # LC_CONDITIONALS
2559 #
2560 # AM_CONDITIONALS for lustre
2561 #
2562 AC_DEFUN([LC_CONDITIONALS], [
2563 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
2564 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
2565 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
2566 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
2567 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
2568 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
2569 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
2570 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
2571 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
2572 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
2573 AM_CONDITIONAL(LLITE_LLOOP, test x$enable_llite_lloop_module = xyes)
2574 ]) # LC_CONDITIONALS
2575
2576 #
2577 # LC_CONFIG_FILES
2578 #
2579 # files that should be generated with AC_OUTPUT
2580 #
2581 AC_DEFUN([LC_CONFIG_FILES],
2582 [AC_CONFIG_FILES([
2583 lustre/Makefile
2584 lustre/autoMakefile
2585 lustre/autoconf/Makefile
2586 lustre/conf/Makefile
2587 lustre/contrib/Makefile
2588 lustre/doc/Makefile
2589 lustre/include/Makefile
2590 lustre/include/lustre/Makefile
2591 lustre/kernel_patches/targets/3.10-rhel7.target
2592 lustre/kernel_patches/targets/2.6-rhel6.8.target
2593 lustre/kernel_patches/targets/2.6-rhel6.7.target
2594 lustre/kernel_patches/targets/2.6-rhel6.6.target
2595 lustre/kernel_patches/targets/2.6-rhel6.target
2596 lustre/kernel_patches/targets/2.6-rhel5.target
2597 lustre/kernel_patches/targets/2.6-sles11.target
2598 lustre/kernel_patches/targets/3.0-sles11.target
2599 lustre/kernel_patches/targets/3.0-sles11sp3.target
2600 lustre/kernel_patches/targets/3.0-sles11sp4.target
2601 lustre/kernel_patches/targets/3.12-sles12.target
2602 lustre/kernel_patches/targets/2.6-fc11.target
2603 lustre/kernel_patches/targets/2.6-fc12.target
2604 lustre/kernel_patches/targets/2.6-fc15.target
2605 lustre/kernel_patches/targets/3.x-fc18.target
2606 lustre/ldlm/Makefile
2607 lustre/fid/Makefile
2608 lustre/fid/autoMakefile
2609 lustre/llite/Makefile
2610 lustre/llite/autoMakefile
2611 lustre/lov/Makefile
2612 lustre/lov/autoMakefile
2613 lustre/mdc/Makefile
2614 lustre/mdc/autoMakefile
2615 lustre/lmv/Makefile
2616 lustre/lmv/autoMakefile
2617 lustre/lfsck/Makefile
2618 lustre/lfsck/autoMakefile
2619 lustre/mdt/Makefile
2620 lustre/mdt/autoMakefile
2621 lustre/mdd/Makefile
2622 lustre/mdd/autoMakefile
2623 lustre/fld/Makefile
2624 lustre/fld/autoMakefile
2625 lustre/obdclass/Makefile
2626 lustre/obdclass/autoMakefile
2627 lustre/obdclass/linux/Makefile
2628 lustre/obdecho/Makefile
2629 lustre/obdecho/autoMakefile
2630 lustre/ofd/Makefile
2631 lustre/ofd/autoMakefile
2632 lustre/osc/Makefile
2633 lustre/osc/autoMakefile
2634 lustre/ost/Makefile
2635 lustre/ost/autoMakefile
2636 lustre/osd-ldiskfs/Makefile
2637 lustre/osd-ldiskfs/autoMakefile
2638 lustre/osd-zfs/Makefile
2639 lustre/osd-zfs/autoMakefile
2640 lustre/mgc/Makefile
2641 lustre/mgc/autoMakefile
2642 lustre/mgs/Makefile
2643 lustre/mgs/autoMakefile
2644 lustre/target/Makefile
2645 lustre/ptlrpc/Makefile
2646 lustre/ptlrpc/autoMakefile
2647 lustre/ptlrpc/gss/Makefile
2648 lustre/ptlrpc/gss/autoMakefile
2649 lustre/quota/Makefile
2650 lustre/quota/autoMakefile
2651 lustre/scripts/Makefile
2652 lustre/tests/Makefile
2653 lustre/tests/mpi/Makefile
2654 lustre/utils/Makefile
2655 lustre/utils/gss/Makefile
2656 lustre/osp/Makefile
2657 lustre/osp/autoMakefile
2658 lustre/lod/Makefile
2659 lustre/lod/autoMakefile
2660 ])
2661 ]) # LC_CONFIG_FILES