Whamcloud - gitweb
LU-9956 kernel: kernel upgrade [SLES12 SP3 4.4.82-6.3]
[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_GLIBC_SUPPORT_FHANDLES
51 #
52 AC_DEFUN([LC_GLIBC_SUPPORT_FHANDLES], [
53 AC_CHECK_FUNCS([name_to_handle_at],
54         [AC_DEFINE(HAVE_FHANDLE_GLIBC_SUPPORT, 1,
55                 [file handle and related syscalls are supported])],
56         [AC_MSG_WARN([file handle and related syscalls are not supported])])
57 ]) # LC_GLIBC_SUPPORT_FHANDLES
58
59 #
60 # LC_STACK_SIZE
61 #
62 # Ensure the stack size is at least 8k in Lustre server (all kernels)
63 #
64 AC_DEFUN([LC_STACK_SIZE], [
65 LB_CHECK_COMPILE([if stack size is at least 8k],
66 stack_size_8k, [
67         #include <linux/thread_info.h>
68 ], [
69         #if THREAD_SIZE < 8192
70         #error "stack size < 8192"
71         #endif
72 ], [], [AC_MSG_ERROR([
73
74 Lustre requires that Linux is configured with at least a 8KB stack.
75 ])])
76 ]) # LC_STACK_SIZE
77
78 #
79 # LC_MDS_MAX_THREADS
80 #
81 # Allow the user to set the MDS thread upper limit
82 #
83 AC_DEFUN([LC_MDS_MAX_THREADS], [
84 AC_MSG_CHECKING([for maximum number of MDS threads])
85 AC_ARG_WITH([mds_max_threads],
86         AC_HELP_STRING([--with-mds-max-threads=count],
87                 [maximum threads available on the MDS: (default=512)]),
88         [AC_DEFINE_UNQUOTED(MDS_MAX_THREADS, $with_mds_max_threads,
89                 [maximum number of MDS threads])])
90 AC_MSG_RESULT([$with_mds_max_threads])
91 ]) # LC_MDS_MAX_THREADS
92
93 #
94 # LC_CONFIG_PINGER
95 #
96 # the pinger is temporary, until we have the recovery node in place
97 #
98 AC_DEFUN([LC_CONFIG_PINGER], [
99 AC_MSG_CHECKING([whether to enable Lustre pinger support])
100 AC_ARG_ENABLE([pinger],
101         AC_HELP_STRING([--disable-pinger],
102                 [disable recovery pinger support]),
103         [], [enable_pinger="yes"])
104 AC_MSG_RESULT([$enable_pinger])
105 AS_IF([test "x$enable_pinger" != xno],
106         [AC_DEFINE(ENABLE_PINGER, 1,[Use the Pinger])])
107 ]) # LC_CONFIG_PINGER
108
109 #
110 # LC_CONFIG_CHECKSUM
111 #
112 # do checksum of bulk data between client and OST
113 #
114 AC_DEFUN([LC_CONFIG_CHECKSUM], [
115 AC_MSG_CHECKING([whether to enable data checksum support])
116 AC_ARG_ENABLE([checksum],
117         AC_HELP_STRING([--disable-checksum],
118                 [disable data checksum support]),
119         [], [enable_checksum="yes"])
120 AC_MSG_RESULT([$enable_checksum])
121 AS_IF([test "x$enable_checksum" != xno],
122         [AC_DEFINE(ENABLE_CHECKSUM, 1, [do data checksums])])
123 ]) # LC_CONFIG_CHECKSUM
124
125 #
126 # LC_CONFIG_HEALTH_CHECK_WRITE
127 #
128 # Turn off the actual write to the disk
129 #
130 AC_DEFUN([LC_CONFIG_HEALTH_CHECK_WRITE], [
131 AC_MSG_CHECKING([whether to enable a write with the health check])
132 AC_ARG_ENABLE([health_write],
133         AC_HELP_STRING([--enable-health_write],
134                 [enable disk writes when doing health check]),
135         [], [enable_health_write="no"])
136 AC_MSG_RESULT([$enable_health_write])
137 AS_IF([test "x$enable_health_write" != xno],
138         [AC_DEFINE(USE_HEALTH_CHECK_WRITE, 1, [Write when Checking Health])])
139 ]) # LC_CONFIG_HEALTH_CHECK_WRITE
140
141 #
142 # LC_CONFIG_LRU_RESIZE
143 #
144 AC_DEFUN([LC_CONFIG_LRU_RESIZE], [
145 AC_MSG_CHECKING([whether to enable lru self-adjusting])
146 AC_ARG_ENABLE([lru_resize],
147         AC_HELP_STRING([--enable-lru-resize],
148                 [enable lru resize support]),
149         [], [enable_lru_resize="yes"])
150 AC_MSG_RESULT([$enable_lru_resize])
151 AS_IF([test "x$enable_lru_resize" != xno],
152         [AC_DEFINE(HAVE_LRU_RESIZE_SUPPORT, 1, [Enable lru resize support])])
153 ]) # LC_CONFIG_LRU_RESIZE
154
155 #
156 # LC_QUOTA_CONFIG
157 #
158 # Quota support. The kernel must support CONFIG_QUOTA.
159 #
160 AC_DEFUN([LC_QUOTA_CONFIG], [
161 LB_CHECK_CONFIG_IM([QUOTA], [],
162         [AC_MSG_ERROR([
163
164 Lustre quota requires that CONFIG_QUOTA is enabled in your kernel.
165 ])])
166 ]) # LC_QUOTA_CONFIG
167
168 #
169 # LC_EXPORT_TRUNCATE_COMPLETE_PAGE
170 #
171 # truncate_complete_page() has never been exported from an upstream kernel
172 # remove_from_page_cache() was exported between 2.6.35 and 2.6.38
173 # delete_from_page_cache() is exported from 2.6.39
174 #
175 AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE_PAGE], [
176 LB_CHECK_EXPORT([truncate_complete_page], [mm/truncate.c],
177         [AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
178                 [kernel export truncate_complete_page])])
179 LB_CHECK_EXPORT([remove_from_page_cache], [mm/filemap.c],
180         [AC_DEFINE(HAVE_REMOVE_FROM_PAGE_CACHE, 1,
181                 [kernel export remove_from_page_cache])])
182 LB_CHECK_EXPORT([delete_from_page_cache], [mm/filemap.c],
183         [AC_DEFINE(HAVE_DELETE_FROM_PAGE_CACHE, 1,
184                 [kernel export delete_from_page_cache])])
185 ]) # LC_EXPORT_TRUNCATE_COMPLETE_PAGE
186
187 #
188 # LC_CONFIG_GSS_KEYRING
189 #
190 # default 'auto', tests for dependencies, if found, enables;
191 # only called if gss is enabled
192 #
193 AC_DEFUN([LC_CONFIG_GSS_KEYRING], [
194 AC_MSG_CHECKING([whether to enable gss keyring backend])
195 AC_ARG_ENABLE([gss_keyring],
196         [AC_HELP_STRING([--disable-gss-keyring],
197                 [disable gss keyring backend])],
198         [], [enable_gss_keyring="auto"])
199 AC_MSG_RESULT([$enable_gss_keyring])
200 AS_IF([test "x$enable_gss_keyring" != xno], [
201         LB_CHECK_CONFIG_IM([KEYS], [], [
202                 gss_keyring_conf_test="fail"
203                 AC_MSG_WARN([GSS keyring backend requires that CONFIG_KEYS be enabled in your kernel.])])
204
205         AC_CHECK_LIB([keyutils], [keyctl_search], [], [
206                 gss_keyring_conf_test="fail"
207                 AC_MSG_WARN([GSS keyring backend requires libkeyutils])])
208
209         AS_IF([test "x$gss_keyring_conf_test" != xfail], [
210                 AC_DEFINE([HAVE_GSS_KEYRING], [1],
211                         [Define this if you enable gss keyring backend])
212                 enable_gss_keyring="yes"
213         ], [
214                 AS_IF([test "x$enable_gss_keyring" = xyes], [
215                         AC_MSG_ERROR([Cannot enable gss_keyring. See above for details.])
216                 ])
217         ])
218 ])
219 ]) # LC_CONFIG_GSS_KEYRING
220
221 #
222 # LC_HAVE_CRED_TGCRED
223 #
224 # rhel7 struct cred has no member tgcred
225 #
226 AC_DEFUN([LC_HAVE_CRED_TGCRED], [
227 LB_CHECK_COMPILE([if 'struct cred' has member 'tgcred'],
228 cred_tgcred, [
229         #include <linux/cred.h>
230 ],[
231         ((struct cred *)0)->tgcred = NULL;
232 ],[
233         AC_DEFINE(HAVE_CRED_TGCRED, 1,
234                 [struct cred has member tgcred])
235 ])
236 ]) # LC_HAVE_CRED_TGCRED
237
238 #
239 # LC_KEY_TYPE_INSTANTIATE_2ARGS
240 #
241 # rhel7 key_type->instantiate takes 2 args (struct key, struct key_preparsed_payload)
242 #
243 AC_DEFUN([LC_KEY_TYPE_INSTANTIATE_2ARGS], [
244 LB_CHECK_COMPILE([if 'key_type->instantiate' has two args],
245 key_type_instantiate_2args, [
246         #include <linux/key-type.h>
247 ],[
248         ((struct key_type *)0)->instantiate(0, NULL);
249 ],[
250         AC_DEFINE(HAVE_KEY_TYPE_INSTANTIATE_2ARGS, 1,
251                 [key_type->instantiate has two args])
252 ])
253 ]) # LC_KEY_TYPE_INSTANTIATE_2ARGS
254
255 #
256 # LC_CONFIG_SUNRPC
257 #
258 AC_DEFUN([LC_CONFIG_SUNRPC], [
259 LB_CHECK_CONFIG_IM([SUNRPC], [], [
260         AS_IF([test "x$sunrpc_required" = xyes], [
261                 AC_MSG_ERROR([
262
263 kernel SUNRPC support is required by using GSS.
264 ])
265         ])])
266 ]) # LC_CONFIG_SUNRPC
267
268 #
269 # LC_HAVE_CRYPTO_HASH
270 #
271 # 4.6 kernel commit 896545098777564212b9e91af4c973f094649aa7
272 # removed crypto_hash support. Since GSS only works with
273 # crypto_hash it has to be disabled for newer distros.
274 #
275 AC_DEFUN([LC_HAVE_CRYPTO_HASH], [
276 LB_CHECK_COMPILE([if crypto_hash API is supported],
277 crypto_hash, [
278         #include <linux/crypto.h>
279 ],[
280         crypto_hash_digestsize(NULL);
281 ], [], [enable_gss="no"])
282 ])
283 ]) # LC_HAVE_CRYPTO_HASH
284
285 #
286 # LC_CONFIG_GSS (default 'auto' (tests for dependencies, if found, enables))
287 #
288 # Build gss and related tools of Lustre. Currently both kernel and user space
289 # parts are depend on linux platform.
290 #
291 AC_DEFUN([LC_CONFIG_GSS], [
292 AC_MSG_CHECKING([whether to enable gss support])
293 AC_ARG_ENABLE([gss],
294         [AC_HELP_STRING([--enable-gss], [enable gss support])],
295         [], [enable_gss="auto"])
296 AC_MSG_RESULT([$enable_gss])
297
298 AS_IF([test "x$enable_gss" != xno], [
299         LC_CONFIG_GSS_KEYRING
300         LC_HAVE_CRYPTO_HASH
301         LC_HAVE_CRED_TGCRED
302         LC_KEY_TYPE_INSTANTIATE_2ARGS
303         sunrpc_required=$enable_gss
304         LC_CONFIG_SUNRPC
305         sunrpc_required="no"
306
307         LB_CHECK_CONFIG_IM([CRYPTO_MD5], [],
308                 [AC_MSG_WARN([kernel MD5 support is recommended by using GSS.])])
309         LB_CHECK_CONFIG_IM([CRYPTO_SHA1], [],
310                 [AC_MSG_WARN([kernel SHA1 support is recommended by using GSS.])])
311         LB_CHECK_CONFIG_IM([CRYPTO_SHA256], [],
312                 [AC_MSG_WARN([kernel SHA256 support is recommended by using GSS.])])
313         LB_CHECK_CONFIG_IM([CRYPTO_SHA512], [],
314                 [AC_MSG_WARN([kernel SHA512 support is recommended by using GSS.])])
315
316         require_krb5=$enable_gss
317         AC_KERBEROS_V5
318         require_krb5="no"
319
320         AS_IF([test -n "$KRBDIR"], [
321                 gss_conf_test="success"
322         ], [
323                 gss_conf_test="failure"
324         ])
325
326         AS_IF([test "x$gss_conf_test" = xsuccess], [
327                 AC_DEFINE([HAVE_GSS], [1], [Define this is if you enable gss])
328                 enable_gss="yes"
329         ], [
330                 enable_gss="no"
331         ])
332
333         enable_ssk=$enable_gss
334 ])
335 ]) # LC_CONFIG_GSS
336
337 # LC_OPENSSL_SSK
338 #
339 # OpenSSL 1.0+ return int for HMAC functions but older SLES11 versions do not
340 AC_DEFUN([LC_OPENSSL_SSK], [
341 AC_MSG_CHECKING([whether OpenSSL has functions needed for SSK])
342 AS_IF([test "x$enable_ssk" != xno], [
343 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
344         #include <openssl/hmac.h>
345         #include <openssl/evp.h>
346
347         int main(void) {
348                 int rc;
349                 HMAC_CTX ctx;
350                 HMAC_CTX_init(&ctx);
351                 rc = HMAC_Init_ex(&ctx, "test", 4, EVP_md_null(), NULL);
352         }
353 ])],[AC_DEFINE(HAVE_OPENSSL_SSK, 1,
354                [OpenSSL HMAC functions needed for SSK])],
355         [enable_ssk="no"])
356 ])
357 AC_MSG_RESULT([$enable_ssk])
358 ]) # LC_OPENSSL_SSK
359
360 # LC_INODE_PERMISION_2ARGS
361 #
362 # up to v2.6.27 had a 3 arg version (inode, mask, nameidata)
363 # v2.6.27->v2.6.37 had a 2 arg version (inode, mask)
364 # v2.6.37->v3.0 had a 3 arg version (inode, mask, nameidata)
365 # v3.1 onward have a 2 arg version (inode, mask)
366 #
367 AC_DEFUN([LC_INODE_PERMISION_2ARGS], [
368 LB_CHECK_COMPILE([if 'inode_operations->permission' has two args],
369 inode_ops_permission_2args, [
370         #include <linux/fs.h>
371 ],[
372         struct inode *inode __attribute__ ((unused));
373
374         inode = NULL;
375         inode->i_op->permission(NULL, 0);
376 ],[
377         AC_DEFINE(HAVE_INODE_PERMISION_2ARGS, 1,
378                 [inode_operations->permission has two args])
379 ])
380 ]) # LC_INODE_PERMISION_2ARGS
381
382 #
383 # LC_BLK_QUEUE_MAX_SEGMENTS
384 #
385 # 2.6.32 replaces 2 functions blk_queue_max_phys_segments and blk_queue_max_hw_segments by blk_queue_max_segments
386 #
387 AC_DEFUN([LC_BLK_QUEUE_MAX_SEGMENTS], [
388 LB_CHECK_COMPILE([if 'blk_queue_max_segments' is defined],
389 blk_queue_max_segments, [
390         #include <linux/blkdev.h>
391 ],[
392         blk_queue_max_segments(NULL, 0);
393 ],[
394         AC_DEFINE(HAVE_BLK_QUEUE_MAX_SEGMENTS, 1,
395                 [blk_queue_max_segments is defined])
396 ])
397 ]) # LC_BLK_QUEUE_MAX_SEGMENTS
398
399 #
400 # LC_HAVE_XATTR_HANDLER_FLAGS
401 #
402 # 2.6.33 added a private flag to xattr_handler
403 #
404 AC_DEFUN([LC_HAVE_XATTR_HANDLER_FLAGS], [
405 LB_CHECK_COMPILE([if 'struct xattr_handler' has flags field],
406 xattr_handler_flags, [
407         #include <linux/xattr.h>
408 ],[
409         struct xattr_handler handler;
410
411         handler.flags = 0;
412 ],[
413         AC_DEFINE(HAVE_XATTR_HANDLER_FLAGS, 1, [flags field exist])
414 ])
415 ]) # LC_HAVE_XATTR_HANDLER_FLAGS
416
417 #
418 # LC_HAVE_DQUOT_FS_DISK_QUOTA
419 #
420 # 2.6.34 has quotactl_ops->[sg]et_dqblk that take struct fs_disk_quota
421 #
422 AC_DEFUN([LC_HAVE_DQUOT_FS_DISK_QUOTA], [
423 tmp_flags="$EXTRA_KCFLAGS"
424 EXTRA_KCFLAGS="-Werror"
425 LB_CHECK_COMPILE([if 'quotactl_ops.set_dqblk' takes struct fs_disk_quota],
426 fs_disk_quota, [
427         #include <linux/fs.h>
428         #include <linux/quota.h>
429 ],[
430         ((struct quotactl_ops *)0)->set_dqblk(NULL, 0, 0, (struct fs_disk_quota*)0);
431 ],[
432         AC_DEFINE(HAVE_DQUOT_FS_DISK_QUOTA, 1,
433                 [quotactl_ops.set_dqblk takes struct fs_disk_quota])
434 ],[
435         LB_CHECK_COMPILE([if 'quotactl_ops.set_dqblk' takes struct kqid & fs_disk_quota],
436         kqid_fs_disk_quota, [
437                 #include <linux/fs.h>
438                 #include <linux/quota.h>
439         ],[
440                 ((struct quotactl_ops *)0)->set_dqblk((struct super_block*)0, *((struct kqid*)0), (struct fs_disk_quota*)0);
441         ],[
442                 AC_DEFINE(HAVE_DQUOT_FS_DISK_QUOTA, 1,
443                         [quotactl_ops.set_dqblk takes struct fs_disk_quota])
444                 AC_DEFINE(HAVE_DQUOT_KQID, 1,
445                         [quotactl_ops.set_dqblk takes struct kqid])
446         ])
447 ])
448 EXTRA_KCFLAGS="$tmp_flags"
449 ]) # LC_HAVE_DQUOT_FS_DISK_QUOTA
450
451 #
452 # LC_HAVE_DQUOT_SUSPEND
453 #
454 # 2.6.34 has renamed dquot options to dquot_*, check for dquot_suspend
455 #
456 AC_DEFUN([LC_HAVE_DQUOT_SUSPEND], [
457 LB_CHECK_COMPILE([if 'dquot_suspend' is defined],
458 dquot_suspend, [
459         #include <linux/quotaops.h>
460 ],[
461         dquot_suspend(NULL, -1);
462 ],[
463         AC_DEFINE(HAVE_DQUOT_SUSPEND, 1, [dquot_suspend is defined])
464 ])
465 ]) # LC_HAVE_DQUOT_SUSPEND
466
467 #
468 # LC_QUOTA64
469 #
470 # Check if kernel has been patched for 64-bit quota limits support.
471 # The upstream version of this patch in RHEL6 2.6.32 kernels introduces
472 # the constant QFMT_VFS_V1 in include/linux/quota.h, so we can check for
473 # that in the absence of quotaio_v1.h in the kernel headers.
474 #
475 AC_DEFUN([LC_QUOTA64], [
476 tmp_flags="$EXTRA_KCFLAGS"
477 EXTRA_KCFLAGS="-I$LINUX/fs"
478 LB_CHECK_COMPILE([if kernel has 64-bit quota limits support],
479 quota64, [
480         #include <linux/kernel.h>
481         #include <linux/fs.h>
482         #if defined(HAVE_FS_QUOTA_QUOTAIO_H)
483         #include <quota/quotaio_v2.h>
484         struct v2r1_disk_dqblk dqblk_r1;
485         #else
486         #include <linux/quota.h>
487         int ver = QFMT_VFS_V1;
488         #endif
489 ], [], [
490         AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
491 ],[
492         LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],
493                 [AC_MSG_ERROR([You have got no 64-bit kernel quota support.])])
494 ])
495 EXTRA_KCFLAGS=$tmp_flags
496 ]) # LC_QUOTA64
497
498 #
499 # LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE
500 #
501 # 2.6.34 adds __add_wait_queue_exclusive
502 #
503 AC_DEFUN([LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE], [
504 LB_CHECK_COMPILE([if '__add_wait_queue_exclusive' exists],
505 __add_wait_queue_exclusive, [
506         #include <linux/wait.h>
507 ],[
508         wait_queue_head_t queue;
509         wait_queue_t      wait;
510         __add_wait_queue_exclusive(&queue, &wait);
511 ],[
512         AC_DEFINE(HAVE___ADD_WAIT_QUEUE_EXCLUSIVE, 1,
513                   [__add_wait_queue_exclusive exists])
514 ])
515 ]) # LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE
516
517 #
518 # LC_FS_STRUCT_RWLOCK
519 #
520 # 2.6.36 fs_struct.lock use spinlock instead of rwlock.
521 #
522 AC_DEFUN([LC_FS_STRUCT_RWLOCK], [
523 LB_CHECK_COMPILE([if 'fs_struct.lock' use rwlock],
524 fs_struct_rwlock, [
525         #include <asm/atomic.h>
526         #include <linux/spinlock.h>
527         #include <linux/fs_struct.h>
528 ],[
529         ((struct fs_struct *)0)->lock = (rwlock_t){ 0 };
530 ],[
531         AC_DEFINE(HAVE_FS_STRUCT_RWLOCK, 1, [fs_struct.lock use rwlock])
532 ])
533 ]) # LC_FS_STRUCT_RWLOCK
534
535 #
536 # LC_SBOPS_EVICT_INODE
537 #
538 # 2.6.36 super_operations add evict_inode method. it hybird of
539 # delete_inode & clear_inode.
540 #
541 AC_DEFUN([LC_SBOPS_EVICT_INODE], [
542 LB_CHECK_COMPILE([if 'super_operations.evict_inode' exist],
543 super_ops_evict_inode, [
544         #include <linux/fs.h>
545 ],[
546         ((struct super_operations *)0)->evict_inode(NULL);
547 ],[
548         AC_DEFINE(HAVE_SBOPS_EVICT_INODE, 1,
549                 [super_operations.evict_inode() is exist in kernel])
550 ])
551 ]) # LC_SBOPS_EVICT_INODE
552
553 #
554 # LC_FILE_FSYNC
555 #
556 # 2.6.35 file_operations.fsync taken 2 arguments.
557 # 3.0.0 file_operations.fsync takes 4 arguments.
558 #
559 AC_DEFUN([LC_FILE_FSYNC], [
560 LB_CHECK_COMPILE([if 'file_operations.fsync' takes 4 arguments],
561 file_ops_fsync_4args, [
562         #include <linux/fs.h>
563 ],[
564         ((struct file_operations *)0)->fsync(NULL, 0, 0, 0);
565 ],[
566         AC_DEFINE(HAVE_FILE_FSYNC_4ARGS, 1,
567                 [file_operations.fsync takes 4 arguments])
568 ],[
569         LB_CHECK_COMPILE([if 'file_operations.fsync' takes 2 arguments],
570         file_ops_fsync_2args, [
571                 #include <linux/fs.h>
572         ],[
573                 ((struct file_operations *)0)->fsync(NULL, 0);
574         ],[
575                 AC_DEFINE(HAVE_FILE_FSYNC_2ARGS, 1,
576                         [file_operations.fsync takes 2 arguments])
577         ])
578 ])
579 ]) # LC_FILE_FSYNC
580
581 #
582 # LC_KERNEL_LOCKED
583 #
584 # 2.6.37 remove kernel_locked
585 #
586 AC_DEFUN([LC_KERNEL_LOCKED], [
587 LB_CHECK_COMPILE([if 'kernel_locked' is defined],
588 kernel_locked, [
589         #include <linux/smp_lock.h>
590 ],[
591         kernel_locked();
592 ],[
593         AC_DEFINE(HAVE_KERNEL_LOCKED, 1, [kernel_locked is defined])
594 ])
595 ]) # LC_KERNEL_LOCKED
596
597 #
598 # LC_D_COMPARE_7ARGS
599 #
600 # 2.6.38 dentry_operations.d_compare() taken 7 arguments.
601 #
602 AC_DEFUN([LC_D_COMPARE_7ARGS], [
603 LB_CHECK_COMPILE([if 'dentry_operations.d_compare()' taken 7 arguments],
604 dentry_ops_d_compare_7arg, [
605         #include <linux/dcache.h>
606 ],[
607         ((struct dentry_operations*)0)->d_compare(NULL,NULL,NULL,NULL,0,NULL,NULL);
608 ],[
609         AC_DEFINE(HAVE_D_COMPARE_7ARGS, 1, [d_compare need 7 arguments])
610 ])
611 ]) # LC_D_COMPARE_7ARGS
612
613 #
614 # LC_D_DELETE_CONST
615 #
616 # 2.6.38 dentry_operations.d_delete() defined 'const' for 1st parameter.
617 #
618 AC_DEFUN([LC_D_DELETE_CONST], [
619 tmp_flags="$EXTRA_KCFLAGS"
620 EXTRA_KCFLAGS="-Werror"
621 LB_CHECK_COMPILE([if 'dentry_operations.d_delete()' has const declare on first parameter],
622 dentry_ops_d_delete_1st_const, [
623         #include <linux/dcache.h>
624 ],[
625         const struct dentry *d = NULL;
626         ((struct dentry_operations*)0)->d_delete(d);
627 ],[
628         AC_DEFINE(HAVE_D_DELETE_CONST, const,
629                 [d_delete first parameter declared const])
630 ],[
631         AC_DEFINE(HAVE_D_DELETE_CONST, [],
632                 [d_delete first parameter declared is not const])
633 ])
634 EXTRA_KCFLAGS="$tmp_flags"
635 ]) # LC_D_DELETE_CONST
636
637 #
638 # LC_DCACHE_LOCK
639 #
640 # 2.6.38 dcache_lock removed. rcu-walk committed.
641 #
642 AC_DEFUN([LC_DCACHE_LOCK], [
643 LB_CHECK_COMPILE([if 'dcache_lock' is exist],
644 dcache_lock, [
645         #include <linux/dcache.h>
646 ],[
647         spin_lock(&dcache_lock);
648 ],[
649         AC_DEFINE(HAVE_DCACHE_LOCK, 1,
650                 [dcache_lock is exist])
651 ])
652 ]) # LC_DCACHE_LOCK
653
654 #
655 # LC_INODE_I_RCU
656 #
657 # 2.6.38 inode.i_rcu added.
658 #
659 AC_DEFUN([LC_INODE_I_RCU], [
660 LB_CHECK_COMPILE([if 'inode.i_rcu' exists],
661 inode_i_rcu, [
662         #include <linux/fs.h>
663 ],[
664         struct inode ino;
665         struct rcu_head rcu = {};
666         ino.i_rcu = rcu;
667 ],[
668         AC_DEFINE(HAVE_INODE_I_RCU, 1,
669                 [inode.i_rcu exists])
670 ])
671 ]) # LC_INODE_I_RCU
672
673 #
674 # LC_BLKDEV_GET_BY_DEV
675 #
676 # 2.6.38 export blkdev_get_by_dev
677 #
678 AC_DEFUN([LC_BLKDEV_GET_BY_DEV], [
679 LB_CHECK_EXPORT([blkdev_get_by_dev], [fs/block_dev.c],
680         [AC_DEFINE(HAVE_BLKDEV_GET_BY_DEV, 1,
681                 [blkdev_get_by_dev is exported by the kernel])])
682 ]) # LC_BLKDEV_GET_BY_DEV
683
684 #
685 # LC_EXPORT_SIMPLE_SETATTR
686 #
687 # 2.6.38 export simple_setattr
688 #
689 AC_DEFUN([LC_EXPORT_SIMPLE_SETATTR], [
690 LB_CHECK_EXPORT([simple_setattr], [fs/libfs.c],
691         [AC_DEFINE(HAVE_SIMPLE_SETATTR, 1,
692                 [simple_setattr is exported by the kernel])])
693 ]) # LC_EXPORT_SIMPLE_SETATTR
694
695 #
696 # LC_HAVE_BLK_PLUG
697 #
698 # 2.6.38 add struct blk_plug
699 #
700 AC_DEFUN([LC_HAVE_BLK_PLUG], [
701 LB_CHECK_COMPILE([if 'struct blk_plug' exists],
702 blk_plug, [
703         #include <linux/blkdev.h>
704 ],[
705         struct blk_plug plug;
706
707         blk_start_plug(&plug);
708         blk_finish_plug(&plug);
709 ],[
710         AC_DEFINE(HAVE_BLK_PLUG, 1,
711                 [blk_plug struct exists])
712 ])
713 ]) # LC_HAVE_BLK_PLUG
714
715 #
716 # LC_IOP_TRUNCATE
717 #
718 # truncate callback removed since 2.6.39
719 #
720 AC_DEFUN([LC_IOP_TRUNCATE], [
721 LB_CHECK_COMPILE([if 'inode_operations' has '.truncate' member function],
722 inode_ops_truncate, [
723         #include <linux/fs.h>
724 ],[
725         ((struct inode_operations *)0)->truncate(NULL);
726 ],[
727         AC_DEFINE(HAVE_INODEOPS_TRUNCATE, 1,
728                 [inode_operations has .truncate member function])
729 ])
730 ]) # LC_IOP_TRUNCATE
731
732 #
733 # LC_HAVE_FSTYPE_MOUNT
734 #
735 # 2.6.39 replace get_sb with mount in struct file_system_type
736 #
737 AC_DEFUN([LC_HAVE_FSTYPE_MOUNT], [
738 LB_CHECK_COMPILE([if 'file_system_type' has 'mount' field],
739 file_system_type_mount, [
740         #include <linux/fs.h>
741 ],[
742         struct file_system_type fst;
743         void *i = (void *) fst.mount;
744 ],[
745         AC_DEFINE(HAVE_FSTYPE_MOUNT, 1,
746                 [struct file_system_type has mount field])
747 ])
748 ]) # LC_HAVE_FSTYPE_MOUNT
749
750 #
751 # LC_HAVE_FHANDLE_SYSCALLS
752 #
753 # 2.6.39 The open_by_handle_at() and name_to_handle_at() system calls were
754 # added to Linux kernel 2.6.39.
755 # Check if client supports these functions
756 #
757 AC_DEFUN([LC_HAVE_FHANDLE_SYSCALLS], [
758 LB_CHECK_CONFIG_IM([FHANDLE],[
759         AC_DEFINE(HAVE_FHANDLE_SYSCALLS, 1,
760                 [kernel supports fhandles and related syscalls])
761         ])
762 ]) # LC_HAVE_FHANDLE_SYSCALLS
763
764 #
765 # LC_HAVE_INODE_OWNER_OR_CAPABLE
766 #
767 # 2.6.39 renames is_owner_or_cap to inode_owner_or_capable
768 #
769 AC_DEFUN([LC_HAVE_INODE_OWNER_OR_CAPABLE], [
770 LB_CHECK_COMPILE([if 'inode_owner_or_capable' exist],
771 inode_owner_or_capable, [
772         #include <linux/fs.h>
773 ],[
774         inode_owner_or_capable(NULL);
775 ],[
776         AC_DEFINE(HAVE_INODE_OWNER_OR_CAPABLE, 1,
777                 [inode_owner_or_capable exist])
778 ])
779 ]) # LC_HAVE_INODE_OWNER_OR_CAPABLE
780
781 #
782 # LC_DIRTY_INODE_WITH_FLAG
783 #
784 # 3.0 dirty_inode() has a flag parameter
785 # see kernel commit aa38572954ade525817fe88c54faebf85e5a61c0
786 #
787 AC_DEFUN([LC_DIRTY_INODE_WITH_FLAG], [
788 LB_CHECK_COMPILE([if 'dirty_inode' super_operation takes flag],
789 dirty_inode_super_operation_flag, [
790         #include <linux/fs.h>
791 ],[
792         struct inode *inode;
793         inode->i_sb->s_op->dirty_inode(NULL, 0);
794 ],[
795         AC_DEFINE(HAVE_DIRTY_INODE_HAS_FLAG, 1,
796                 [dirty_inode super_operation takes flag])
797 ])
798 ]) # LC_DIRTY_INODE_WITH_FLAG
799
800 #
801 # LC_SETNS
802 #
803 # 3.0 introduced setns
804 #
805 AC_DEFUN([LC_SETNS], [
806 AC_CHECK_HEADERS([sched.h], [], [],
807                  [#define _GNU_SOURCE
808                  ])
809 AC_CHECK_FUNCS([setns])
810 ]) # LC_SETNS
811
812 #
813 # LC_GENERIC_PERMISSION
814 #
815 # 2.6.38 generic_permission taken 4 parameters.
816 # in fact, it means rcu-walk aware permission bring.
817 #
818 # 3.1 generic_permission taken 2 parameters.
819 # see kernel commit 2830ba7f34ebb27c4e5b8b6ef408cd6d74860890
820 #
821 AC_DEFUN([LC_GENERIC_PERMISSION], [
822 LB_CHECK_COMPILE([if 'generic_permission' take 2 arguments],
823 generic_permission_2args, [
824         #include <linux/fs.h>
825 ],[
826         generic_permission(NULL, 0);
827 ],[
828         AC_DEFINE(HAVE_GENERIC_PERMISSION_2ARGS, 1,
829                 [generic_permission taken 2 arguments])
830 ],[
831         LB_CHECK_COMPILE([if 'generic_permission' take 4 arguments],
832         generic_permission_4args, [
833                 #include <linux/fs.h>
834         ],[
835                 generic_permission(NULL, 0, 0, NULL);
836         ],[
837                 AC_DEFINE(HAVE_GENERIC_PERMISSION_4ARGS, 1,
838                         [generic_permission taken 4 arguments])
839         ])
840 ])
841 ]) # LC_GENERIC_PERMISSION
842
843 #
844 # LC_LM_XXX_LOCK_MANAGER_OPS
845 #
846 # 3.1 renames lock-manager ops(lock_manager_operations) from fl_xxx to lm_xxx
847 # see kernel commit 8fb47a4fbf858a164e973b8ea8ef5e83e61f2e50
848 #
849 AC_DEFUN([LC_LM_XXX_LOCK_MANAGER_OPS], [
850 LB_CHECK_COMPILE([if 'lock-manager' ops renamed to 'lm_xxx'],
851 lock_manager_ops_lm_xxx, [
852         #include <linux/fs.h>
853 ],[
854         struct lock_manager_operations lm_ops;
855         lm_ops.lm_compare_owner = NULL;
856 ],[
857         AC_DEFINE(HAVE_LM_XXX_LOCK_MANAGER_OPS, 1,
858                 [lock-manager ops renamed to lm_xxx])
859 ])
860 ]) # LC_LM_XXX_LOCK_MANAGER_OPS
861
862 #
863 # LC_INODE_DIO_WAIT
864 #
865 # 3.1 kills inode->i_alloc_sem, use i_dio_count and inode_dio_wait
866 #     instead.
867 # see kernel commit bd5fe6c5eb9c548d7f07fe8f89a150bb6705e8e3
868 #
869 AC_DEFUN([LC_INODE_DIO_WAIT], [
870 LB_CHECK_COMPILE([if 'inode->i_alloc_sem' is killed and use inode_dio_wait],
871 inode_dio_wait, [
872         #include <linux/fs.h>
873 ],[
874         inode_dio_wait((struct inode *)0);
875 ],[
876         AC_DEFINE(HAVE_INODE_DIO_WAIT, 1,
877                 [inode->i_alloc_sem is killed and use inode_dio_wait])
878 ])
879 ]) # LC_INODE_DIO_WAIT
880
881 #
882 # LC_IOP_GET_ACL
883 #
884 # 3.1 adds get_acl method to inode_operations to read ACL from disk.
885 # see kernel commit 4e34e719e457f2e031297175410fc0bd4016a085
886 #
887 AC_DEFUN([LC_IOP_GET_ACL], [
888 LB_CHECK_COMPILE([if 'inode_operations' has '.get_acl' member function],
889 inode_ops_get_acl, [
890         #include <linux/fs.h>
891 ],[
892         struct inode_operations iop;
893         iop.get_acl = NULL;
894 ],[
895         AC_DEFINE(HAVE_IOP_GET_ACL, 1,
896                 [inode_operations has .get_acl member function])
897 ])
898 ]) # LC_IOP_GET_ACL
899
900 #
901 # LC_FILE_LLSEEK_SIZE
902 #
903 # 3.1 introduced generic_file_llseek_size()
904 #
905 AC_DEFUN([LC_FILE_LLSEEK_SIZE], [
906 LB_CHECK_EXPORT([generic_file_llseek_size], [fs/read_write.c],
907         [AC_DEFINE(HAVE_FILE_LLSEEK_SIZE, 1,
908                 [generic_file_llseek_size is exported by the kernel])])
909 ]) # LC_FILE_LLSEEK_SIZE
910
911 #
912 # LC_RADIX_EXCEPTION_ENTRY
913 # 3.1 adds radix_tree_exception_entry.
914 #
915 AC_DEFUN([LC_RADIX_EXCEPTION_ENTRY], [
916 LB_CHECK_COMPILE([radix_tree_exceptional_entry exist],
917 radix_tree_exceptional_entry, [
918         #include <linux/radix-tree.h>
919 ],[
920         radix_tree_exceptional_entry(NULL);
921 ],[
922         AC_DEFINE(HAVE_RADIX_EXCEPTION_ENTRY, 1,
923                 [radix_tree_exceptional_entry exist])
924 ])
925 ]) # LC_RADIX_EXCEPTION_ENTRY
926
927 #
928 # LC_HAVE_PROTECT_I_NLINK
929 #
930 # 3.2 protects inode->i_nlink from direct modification
931 # see kernel commit a78ef704a8dd430225955f0709b22d4a6ba21deb
932 # at the same time adds set_nlink(), so checks set_nlink() for it.
933 #
934 AC_DEFUN([LC_HAVE_PROTECT_I_NLINK], [
935 LB_CHECK_COMPILE([if 'inode->i_nlink' is protected from direct modification],
936 inode_i_nlink_protected, [
937         #include <linux/fs.h>
938 ],[
939         struct inode i;
940         set_nlink(&i, 1);
941 ],[
942         AC_DEFINE(HAVE_PROTECT_I_NLINK, 1,
943                 [inode->i_nlink is protected from direct modification])
944 ])
945 ]) # LC_HAVE_PROTECT_I_NLINK
946
947 #
948 # 2.6.39 security_inode_init_security takes a 'struct qstr' parameter
949 #
950 # 3.2 security_inode_init_security takes a callback to set xattrs
951 #
952 AC_DEFUN([LC_HAVE_SECURITY_IINITSEC], [
953 LB_CHECK_COMPILE([if security_inode_init_security takes a callback],
954 security_inode_init_security_callback, [
955         #include <linux/security.h>
956 ],[
957         security_inode_init_security(NULL, NULL, NULL, (const initxattrs)NULL, NULL);
958 ],[
959         AC_DEFINE(HAVE_SECURITY_IINITSEC_CALLBACK, 1,
960                   [security_inode_init_security takes a callback to set xattrs])
961 ],[
962         LB_CHECK_COMPILE([if security_inode_init_security takes a 'struct qstr' parameter],
963         security_inode_init_security_qstr, [
964                 #include <linux/security.h>
965         ],[
966                 security_inode_init_security(NULL, NULL, (struct qstr *)NULL, NULL, NULL, NULL);
967         ],[
968                 AC_DEFINE(HAVE_SECURITY_IINITSEC_QSTR, 1,
969                           [security_inode_init_security takes a 'struct qstr' parameter])
970         ])
971 ])
972 ]) # LC_HAVE_SECURITY_IINITSEC
973
974 #
975 # LC_HAVE_MIGRATE_HEADER
976 #
977 # 3.3 introduces migrate_mode.h and migratepage has 4 args
978 #
979 AC_DEFUN([LC_HAVE_MIGRATE_HEADER], [
980 LB_CHECK_FILE([$LINUX/include/linux/migrate.h], [
981         AC_DEFINE(HAVE_MIGRATE_H, 1,
982                 [kernel has include/linux/migrate.h])
983 ],[
984         LB_CHECK_FILE([$LINUX/include/linux/migrate_mode.h], [
985                 AC_DEFINE(HAVE_MIGRATE_MODE_H, 1,
986                         [kernel has include/linux/migrate_mode.h])
987         ])
988 ])
989 ]) # LC_HAVE_MIGRATE_HEADER
990
991 #
992 # LC_MIGRATEPAGE_4ARGS
993 #
994 AC_DEFUN([LC_MIGRATEPAGE_4ARGS], [
995 LB_CHECK_COMPILE([if 'address_space_operations.migratepage' has 4 args],
996 address_space_ops_migratepage_4args, [
997         #include <linux/fs.h>
998 #ifdef HAVE_MIGRATE_H
999         #include <linux/migrate.h>
1000 #elif defined(HAVE_MIGRATE_MODE_H)
1001         #include <linux/migrate_mode.h>
1002 #endif
1003 ],[
1004         struct address_space_operations aops;
1005         aops.migratepage(NULL, NULL, NULL, MIGRATE_ASYNC);
1006 ],[
1007         AC_DEFINE(HAVE_MIGRATEPAGE_4ARGS, 1,
1008                 [address_space_operations.migratepage has 4 args])
1009 ])
1010 ]) # LC_MIGRATEPAGE_4ARGS
1011
1012 #
1013 # LC_SUPEROPS_USE_DENTRY
1014 #
1015 # 3.3 switchs super_operations to use dentry as parameter (but not vfsmount)
1016 # see kernel commit 34c80b1d93e6e20ca9dea0baf583a5b5510d92d4
1017 #
1018 AC_DEFUN([LC_SUPEROPS_USE_DENTRY], [
1019 tmp_flags="$EXTRA_KCFLAGS"
1020 EXTRA_KCFLAGS="-Werror"
1021 LB_CHECK_COMPILE([if 'super_operations' use 'dentry' as parameter],
1022 super_ops_dentry, [
1023         #include <linux/fs.h>
1024         int show_options(struct seq_file *seq, struct dentry *root) {
1025                 return 0;
1026         }
1027 ],[
1028         struct super_operations ops;
1029         ops.show_options = show_options;
1030 ],[
1031         AC_DEFINE(HAVE_SUPEROPS_USE_DENTRY, 1,
1032                 [super_operations use dentry as parameter])
1033 ])
1034 EXTRA_KCFLAGS="$tmp_flags"
1035 ]) # LC_SUPEROPS_USE_DENTRY
1036
1037 #
1038 # LC_INODEOPS_USE_UMODE_T
1039 #
1040 # 3.3 switchs inode_operations to use umode_t as parameter (but not int)
1041 # see kernel commit 1a67aafb5f72a436ca044293309fa7e6351d6a35
1042 #
1043 AC_DEFUN([LC_INODEOPS_USE_UMODE_T], [
1044 tmp_flags="$EXTRA_KCFLAGS"
1045 EXTRA_KCFLAGS="-Werror"
1046 LB_CHECK_COMPILE([if 'inode_operations' use 'umode_t' as parameter],
1047 inode_ops_umode_t, [
1048         #include <linux/fs.h>
1049         #include <linux/types.h>
1050         int my_mknod(struct inode *dir, struct dentry *dchild,
1051                      umode_t mode, dev_t dev)
1052         {
1053                 return 0;
1054         }
1055 ],[
1056         struct inode_operations ops;
1057         ops.mknod = my_mknod;
1058 ],[
1059         AC_DEFINE(HAVE_INODEOPS_USE_UMODE_T, 1,
1060                 [inode_operations use umode_t as parameter])
1061 ])
1062 EXTRA_KCFLAGS="$tmp_flags"
1063 ]) # LC_INODEOPS_USE_UMODE_T
1064
1065 #
1066 # LC_KMAP_ATOMIC_HAS_1ARG
1067 #
1068 # 3.4 kmap_atomic removes second argument
1069 # see kernel commit 1ec9c5ddc17aa398f05646abfcbaf315b544e62f
1070 #
1071 AC_DEFUN([LC_KMAP_ATOMIC_HAS_1ARG], [
1072 LB_CHECK_COMPILE([if 'kmap_atomic' has only 1 argument],
1073 kmap_atomic_1arg, [
1074         #include <linux/highmem.h>
1075 ],[
1076         kmap_atomic(NULL);
1077 ],[
1078         AC_DEFINE(HAVE_KMAP_ATOMIC_HAS_1ARG, 1,
1079                 [have kmap_atomic has only 1 argument])
1080 ])
1081 ]) # LC_KMAP_ATOMIC_HAS_1ARG
1082
1083 #
1084 # LC_HAVE_D_MAKE_ROOT
1085 #
1086 # 3.4 converts d_alloc_root to d_make_root
1087 # see kernel commit 32991ab305ace7017c62f8eecbe5eb36dc32e13b
1088 #
1089 AC_DEFUN([LC_HAVE_D_MAKE_ROOT], [
1090 LB_CHECK_COMPILE([if have 'd_make_root'],
1091 d_make_root, [
1092         #include <linux/fs.h>
1093 ],[
1094         d_make_root((struct inode *)NULL);
1095 ],[
1096         AC_DEFINE(HAVE_D_MAKE_ROOT, 1,
1097                 [have d_make_root])
1098 ])
1099 ]) # LC_HAVE_D_MAKE_ROOT
1100
1101 #
1102 # LC_HAVE_CACHE_REGISTER
1103 #
1104 # 3.4 cache_register/cache_unregister are removed
1105 # see kernel commit 2c5f846747526e2b83c5f1b8e69016be0e2e87c0
1106 # Note, since 2.6.37 cache_register_net/cache_unregister_net
1107 # are defined, but not exported.
1108 # 3.3 cache_register_net/cache_unregister_net are
1109 # exported and replacing cache_register/cache_unregister in 3.4
1110 #
1111 AC_DEFUN([LC_HAVE_CACHE_REGISTER], [
1112 LB_CHECK_COMPILE([if have 'cache_register'],
1113 cache_register, [
1114         #include <linux/sunrpc/cache.h>
1115 ],[
1116         cache_register(NULL);
1117 ],[
1118         AC_DEFINE(HAVE_CACHE_REGISTER, 1,
1119                 [have cache_register])
1120 ])
1121 ]) # LC_HAVE_CACHE_REGISTER
1122
1123 #
1124 # LC_HAVE_CLEAR_INODE
1125 #
1126 # 3.5 renames end_writeback() back to clear_inode()...
1127 # see kernel commit dbd5768f87ff6fb0a4fe09c4d7b6c4a24de99430
1128 #
1129 AC_DEFUN([LC_HAVE_CLEAR_INODE], [
1130 LB_CHECK_COMPILE([if have 'clear_inode'],
1131 clear_inode, [
1132         #include <linux/fs.h>
1133 ],[
1134         clear_inode((struct inode *)NULL);
1135 ],[
1136         AC_DEFINE(HAVE_CLEAR_INODE, 1,
1137                 [have clear_inode])
1138 ])
1139 ]) # LC_HAVE_CLEAR_INODE
1140
1141 #
1142 # LC_HAVE_ENCODE_FH_PARENT
1143 #
1144 # 3.5 encode_fh has parent inode passed in directly
1145 # see kernel commit b0b0382b
1146 #
1147 AC_DEFUN([LC_HAVE_ENCODE_FH_PARENT], [
1148 tmp_flags="$EXTRA_KCFLAGS"
1149 EXTRA_KCFLAGS="-Werror"
1150 LB_CHECK_COMPILE([if 'encode_fh' have parent inode as parameter],
1151 encode_fh_parent_inode, [
1152         #include <linux/exportfs.h>
1153         #include <linux/fs.h>
1154         #include <linux/types.h>
1155         int ll_encode_fh(struct inode *i, __u32 *a, int *b, struct inode *p)
1156         {
1157                 return 0;
1158         }
1159 ],[
1160         struct export_operations exp_op;
1161         exp_op.encode_fh = ll_encode_fh;
1162 ],[
1163         AC_DEFINE(HAVE_ENCODE_FH_PARENT, 1,
1164                 [have parent inode as parameter])
1165 ])
1166 EXTRA_KCFLAGS="$tmp_flags"
1167 ]) # LC_HAVE_ENCODE_FH_PARENT
1168
1169 #
1170 # LC_FILE_LLSEEK_SIZE_5ARG
1171 #
1172 # 3.5 has generic_file_llseek_size with 5 args
1173 #
1174 AC_DEFUN([LC_FILE_LLSEEK_SIZE_5ARG], [
1175 LB_CHECK_COMPILE([if Linux kernel has 'generic_file_llseek_size' with 5 args],
1176 generic_file_llseek_size_5args, [
1177         #include <linux/fs.h>
1178 ],[
1179         generic_file_llseek_size(NULL, 0, 0, 0, 0);
1180 ], [
1181         AC_DEFINE(HAVE_FILE_LLSEEK_SIZE_5ARGS, 1,
1182                 [kernel has generic_file_llseek_size with 5 args])
1183 ])
1184 ]) # LC_FILE_LLSEEK_SIZE_5ARG
1185
1186 #
1187 # LC_LLITE_DATA_IS_LIST
1188 #
1189 # 3.6 switch i_dentry/d_alias from list to hlist
1190 #
1191 # In the upstream kernels d_alias first changes
1192 # to a hlist and then in later version, 3.11, gets
1193 # moved to the union d_u. Due to some distros having
1194 # d_alias in the d_u union as a struct list, which
1195 # has never existed upstream stream, we can't test
1196 # if d_alias is a list or hlist directly. If ever
1197 # i_dentry and d_alias even up different combos then
1198 # the build will fail. In that case then we will need
1199 # to separate out the i_dentry and d_alias test below.
1200 #
1201 AC_DEFUN([LC_DATA_FOR_LLITE_IS_LIST], [
1202 tmp_flags="$EXTRA_KCFLAGS"
1203 EXTRA_KCFLAGS="-Werror"
1204 LB_CHECK_COMPILE([if 'i_dentry/d_alias' uses 'list'],
1205 i_dentry_d_alias_list, [
1206         #include <linux/fs.h>
1207 ],[
1208         struct inode inode;
1209         INIT_LIST_HEAD(&inode.i_dentry);
1210 ],[
1211         AC_DEFINE(DATA_FOR_LLITE_IS_LIST, 1,
1212                 [both i_dentry/d_alias uses list])
1213 ])
1214 EXTRA_KCFLAGS="$tmp_flags"
1215 ]) # LC_DATA_FOR_LLITE_IS_LIST
1216
1217 #
1218 # LC_DENTRY_OPEN_USE_PATH
1219 #
1220 # 3.6 dentry_open uses struct path as first argument
1221 # see kernel commit 765927b2
1222 #
1223 AC_DEFUN([LC_DENTRY_OPEN_USE_PATH], [
1224 tmp_flags="$EXTRA_KCFLAGS"
1225 EXTRA_KCFLAGS="-Werror"
1226 LB_CHECK_COMPILE([if 'dentry_open' uses 'struct path' as first argument],
1227 dentry_open_path, [
1228         #include <linux/fs.h>
1229         #include <linux/path.h>
1230 ],[
1231         struct path path;
1232         dentry_open(&path, 0, NULL);
1233 ],[
1234         AC_DEFINE(HAVE_DENTRY_OPEN_USE_PATH, 1,
1235                 [dentry_open uses struct path as first argument])
1236 ])
1237 EXTRA_KCFLAGS="$tmp_flags"
1238 ]) # LC_DENTRY_OPEN_USE_PATH
1239
1240 #
1241 # LC_HAVE_IOP_ATOMIC_OPEN
1242 #
1243 # 3.6 vfs adds iop->atomic_open
1244 #
1245 AC_DEFUN([LC_HAVE_IOP_ATOMIC_OPEN], [
1246 LB_CHECK_COMPILE([if 'iop' has 'atomic_open'],
1247 inode_ops_atomic_open, [
1248         #include <linux/fs.h>
1249 ],[
1250         struct inode_operations iop;
1251         iop.atomic_open = NULL;
1252 ],[
1253         AC_DEFINE(HAVE_IOP_ATOMIC_OPEN, 1,
1254                 [have iop atomic_open])
1255 ])
1256 ]) # LC_HAVE_IOP_ATOMIC_OPEN
1257
1258 #
1259 # LC_HAVE_SB_START_WRITE
1260 #
1261 # RHEL6 2.6.32, 3.6 or newer support wrapped FS freeze functions
1262 #
1263 AC_DEFUN([LC_HAVE_SB_START_WRITE], [
1264 LB_CHECK_COMPILE([if kernel supports wrapped FS freeze functions],
1265 sb_start_write, [
1266         #include <linux/fs.h>
1267 ],[
1268         sb_start_write(NULL);
1269 ],[
1270         AC_DEFINE(HAVE_SB_START_WRITE, 1,
1271                 [kernel supports wrapped FS freeze functions])
1272 ])
1273 ]) # LC_HAVE_SB_START_WRITE
1274
1275 #
1276 # LC_HAVE_POSIXACL_USER_NS
1277 #
1278 # 3.7 posix_acl_{to,from}_xattr take struct user_namespace
1279 #
1280 AC_DEFUN([LC_HAVE_POSIXACL_USER_NS], [
1281 LB_CHECK_COMPILE([if 'posix_acl_to_xattr' takes 'struct user_namespace'],
1282 posix_acl_to_xattr_user_namespace, [
1283         #include <linux/fs.h>
1284         #include <linux/posix_acl_xattr.h>
1285 ],[
1286         posix_acl_to_xattr((struct user_namespace *)NULL, NULL, NULL, 0);
1287 ],[
1288         AC_DEFINE(HAVE_POSIXACL_USER_NS, 1,
1289                 [posix_acl_to_xattr takes struct user_namespace])
1290 ])
1291 ]) # LC_HAVE_POSIXACL_USER_NS
1292
1293 #
1294 # LC_HAVE_FILE_F_INODE
1295 #
1296 # 3.8 struct file has new member f_inode
1297 #
1298 AC_DEFUN([LC_HAVE_FILE_F_INODE], [
1299 LB_CHECK_COMPILE([if 'struct file' has member 'f_inode'],
1300 file_f_inode, [
1301         #include <linux/fs.h>
1302 ],[
1303         ((struct file *)0)->f_inode = NULL;
1304 ],[
1305         AC_DEFINE(HAVE_FILE_F_INODE, 1,
1306                 [struct file has member f_inode])
1307 ])
1308 ]) # LC_HAVE_FILE_F_INODE
1309
1310 #
1311 # LC_HAVE_FILE_INODE
1312 #
1313 # 3.8 has introduced inline function file_inode
1314 #
1315 AC_DEFUN([LC_HAVE_FILE_INODE], [
1316 LB_CHECK_COMPILE([if file_inode() exists],
1317 file_inode, [
1318         #include <linux/fs.h>
1319 ],[
1320         file_inode(NULL);
1321 ],[
1322         AC_DEFINE(HAVE_FILE_INODE, 1,
1323                 [file_inode() has been defined])
1324 ])
1325 ]) # LC_HAVE_FILE_INODE
1326
1327 #
1328 # LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS
1329 #
1330 AC_DEFUN([LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS], [
1331 LB_CHECK_COMPILE([if 'sunrpc_cache_pipe_upcall' takes 3 args],
1332 sunrpc_cache_pipe_upcall_3args, [
1333         #include <linux/sunrpc/cache.h>
1334 ],[
1335         sunrpc_cache_pipe_upcall(NULL, NULL, NULL);
1336 ],[
1337         AC_DEFINE(HAVE_SUNRPC_UPCALL_HAS_3ARGS, 1,
1338                 [sunrpc_cache_pipe_upcall takes 3 args])
1339 ])
1340 ]) # LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS
1341
1342 #
1343 # LC_HAVE_HLIST_FOR_EACH_3ARG
1344 #
1345 # 3.9 uses hlist_for_each_entry with 3 args
1346 # b67bfe0d42cac56c512dd5da4b1b347a23f4b70a
1347 #
1348 AC_DEFUN([LC_HAVE_HLIST_FOR_EACH_3ARG], [
1349 LB_CHECK_COMPILE([if 'hlist_for_each_entry' has 3 args],
1350 hlist_for_each_entry_3args, [
1351         #include <linux/list.h>
1352         #include <linux/fs.h>
1353 ],[
1354         struct hlist_head *head = NULL;
1355         struct inode *inode;
1356
1357         hlist_for_each_entry(inode, head, i_hash) {
1358                 continue;
1359         }
1360 ],[
1361         AC_DEFINE(HAVE_HLIST_FOR_EACH_3ARG, 1,
1362                 [hlist_for_each_entry has 3 args])
1363 ])
1364 ]) # LC_HAVE_HLIST_FOR_EACH_3ARG
1365
1366 #
1367 # LC_HAVE_BIO_END_SECTOR
1368 #
1369 # 3.9 introduces bio_end_sector macro
1370 # f73a1c7d117d07a96d89475066188a2b79e53c48
1371 #
1372 AC_DEFUN([LC_HAVE_BIO_END_SECTOR], [
1373 LB_CHECK_COMPILE([if 'bio_end_sector' is defined],
1374 bio_end_sector, [
1375         #include <linux/bio.h>
1376 ],[
1377         struct bio bio;
1378
1379         bio_end_sector(&bio);
1380 ],[
1381         AC_DEFINE(HAVE_BIO_END_SECTOR, 1,
1382                   [bio_end_sector is defined])
1383 ])
1384 ]) # LC_HAVE_BIO_END_SECTOR
1385
1386 #
1387 # 3.9 created is_sxid
1388 #
1389 AC_DEFUN([LC_HAVE_IS_SXID], [
1390 LB_CHECK_COMPILE([if 'is_sxid' is defined],
1391 is_sxid, [
1392         #include <linux/fs.h>
1393 ],[
1394         struct inode inode;
1395
1396         is_sxid(inode.i_mode);
1397 ],[
1398         AC_DEFINE(HAVE_IS_SXID, 1, [is_sxid is defined])
1399 ])
1400 ]) # LC_HAVE_IS_SXID
1401
1402 #
1403 # LC_HAVE_REMOVE_PROC_SUBTREE
1404 #
1405 # 3.10 introduced remove_proc_subtree
1406 #
1407 AC_DEFUN([LC_HAVE_REMOVE_PROC_SUBTREE], [
1408 LB_CHECK_COMPILE([if 'remove_proc_subtree' is defined],
1409 remove_proc_subtree, [
1410         #include <linux/proc_fs.h>
1411 ],[
1412         remove_proc_subtree(NULL, NULL);
1413 ], [
1414         AC_DEFINE(HAVE_REMOVE_PROC_SUBTREE, 1,
1415                   [remove_proc_subtree is defined])
1416 ])
1417 ]) # LC_HAVE_REMOVE_PROC_SUBTREE
1418
1419 #
1420 # LC_HAVE_PROC_REMOVE
1421 #
1422 # 3.10 introduced proc_remove
1423 #
1424 AC_DEFUN([LC_HAVE_PROC_REMOVE], [
1425 LB_CHECK_COMPILE([if 'proc_remove' is defined],
1426 proc_remove, [
1427         #include <linux/proc_fs.h>
1428 ],[
1429         proc_remove(NULL);
1430 ], [
1431         AC_DEFINE(HAVE_PROC_REMOVE, 1,
1432                   [proc_remove is defined])
1433 ])
1434 ]) # LC_HAVE_PROC_REMOVE
1435
1436 AC_DEFUN([LC_HAVE_PROJECT_QUOTA], [
1437 LB_CHECK_COMPILE([if get_projid exists],
1438 get_projid, [
1439         #include <linux/quota.h>
1440 ],[
1441         struct dquot_operations ops;
1442
1443         ops.get_projid(NULL, NULL);
1444 ],[
1445         AC_DEFINE(HAVE_PROJECT_QUOTA, 1,
1446                 [get_projid function exists])
1447 ])
1448 ]) # LC_HAVE_PROJECT_QUOTA
1449
1450
1451 #
1452 # LC_HAVE_SECURITY_DENTRY_INIT_SECURITY
1453 #
1454 # 3.10 introduced security_dentry_init_security()
1455 #
1456 AC_DEFUN([LC_HAVE_SECURITY_DENTRY_INIT_SECURITY], [
1457 LB_CHECK_COMPILE([if 'security_dentry_init_security' is defined],
1458 security_dentry_init_security, [
1459         #include <linux/security.h>
1460 ],[
1461         security_dentry_init_security(NULL, 0, NULL, NULL, NULL);
1462 ],[
1463         AC_DEFINE(HAVE_SECURITY_DENTRY_INIT_SECURITY, 1,
1464                 [security_dentry_init_security' is defined])
1465 ])
1466 ]) # LC_HAVE_SECURITY_DENTRY_INIT_SECURITY
1467
1468 #
1469 # LC_INVALIDATE_RANGE
1470 #
1471 # 3.11 invalidatepage requires the length of the range to invalidate
1472 #
1473 AC_DEFUN([LC_INVALIDATE_RANGE], [
1474 LB_CHECK_COMPILE([if 'address_space_operations.invalidatepage' requires 3 arguments],
1475 address_space_ops_invalidatepage_3args, [
1476         #include <linux/fs.h>
1477 ],[
1478         struct address_space_operations a_ops;
1479         a_ops.invalidatepage(NULL, 0, 0);
1480 ],[
1481         AC_DEFINE(HAVE_INVALIDATE_RANGE, 1,
1482                 [address_space_operations.invalidatepage needs 3 arguments])
1483 ])
1484 ]) # LC_INVALIDATE_RANGE
1485
1486 #
1487 # LC_HAVE_DIR_CONTEXT
1488 #
1489 # 3.11 readdir now takes the new struct dir_context
1490 #
1491 AC_DEFUN([LC_HAVE_DIR_CONTEXT], [
1492 LB_CHECK_COMPILE([if 'dir_context' exist],
1493 dir_context, [
1494         #include <linux/fs.h>
1495 ],[
1496         struct dir_context ctx;
1497         ctx.pos = 0;
1498 ],[
1499         AC_DEFINE(HAVE_DIR_CONTEXT, 1,
1500                 [dir_context exist])
1501 ])
1502 ]) # LC_HAVE_DIR_CONTEXT
1503
1504 #
1505 # LC_D_COMPARE_5ARGS
1506 #
1507 # 3.11 dentry_operations.d_compare() taken 5 arguments.
1508 #
1509 AC_DEFUN([LC_D_COMPARE_5ARGS], [
1510 LB_CHECK_COMPILE([if 'd_compare' taken 5 arguments],
1511 d_compare_5args, [
1512         #include <linux/dcache.h>
1513 ],[
1514         ((struct dentry_operations*)0)->d_compare(NULL,NULL,0,NULL,NULL);
1515 ],[
1516         AC_DEFINE(HAVE_D_COMPARE_5ARGS, 1,
1517                 [d_compare need 5 arguments])
1518 ])
1519 ]) # LC_D_COMPARE_5ARGS
1520
1521 #
1522 # LC_HAVE_DCOUNT
1523 #
1524 # 3.11 need to access d_count to get dentry reference count
1525 #
1526 AC_DEFUN([LC_HAVE_DCOUNT], [
1527 LB_CHECK_COMPILE([if 'd_count' exist],
1528 d_count, [
1529         #include <linux/dcache.h>
1530 ],[
1531         struct dentry de;
1532         d_count(&de);
1533 ],[
1534         AC_DEFINE(HAVE_D_COUNT, 1,
1535                 [d_count exist])
1536 ])
1537 ]) # LC_HAVE_DCOUNT
1538
1539 #
1540 # LC_PID_NS_FOR_CHILDREN
1541 #
1542 # 3.11 replaces pid_ns by pid_ns_for_children in struct nsproxy
1543 #
1544 AC_DEFUN([LC_PID_NS_FOR_CHILDREN], [
1545 LB_CHECK_COMPILE([if 'struct nsproxy' has 'pid_ns_for_children'],
1546 pid_ns_for_children, [
1547         #include <linux/nsproxy.h>
1548 ],[
1549         struct nsproxy ns;
1550         ns.pid_ns_for_children = NULL;
1551 ],[
1552         AC_DEFINE(HAVE_PID_NS_FOR_CHILDREN, 1,
1553                   ['struct nsproxy' has 'pid_ns_for_children'])
1554 ])
1555 ]) # LC_PID_NS_FOR_CHILDREN
1556
1557 #
1558 # LC_OLDSIZE_TRUNCATE_PAGECACHE
1559 #
1560 # 3.12 truncate_pagecache without oldsize parameter
1561 #
1562 AC_DEFUN([LC_OLDSIZE_TRUNCATE_PAGECACHE], [
1563 LB_CHECK_COMPILE([if 'truncate_pagecache' with 'old_size' parameter],
1564 truncate_pagecache_old_size, [
1565         #include <linux/mm.h>
1566 ],[
1567         truncate_pagecache(NULL, 0, 0);
1568 ],[
1569         AC_DEFINE(HAVE_OLDSIZE_TRUNCATE_PAGECACHE, 1,
1570                 [with oldsize])
1571 ])
1572 ]) # LC_OLDSIZE_TRUNCATE_PAGECACHE
1573
1574 #
1575 # LC_HAVE_DENTRY_D_U_D_ALIAS
1576 #
1577 # 3.11 kernel moved d_alias to the union d_u in struct dentry
1578 #
1579 # Some distros move d_alias to d_u but it is still a struct list
1580 #
1581 AC_DEFUN([LC_HAVE_DENTRY_D_U_D_ALIAS], [
1582 AS_IF([test "x$lb_cv_compile_i_dentry_d_alias_list" = xyes], [
1583         LB_CHECK_COMPILE([if list 'dentry.d_u.d_alias' exist],
1584         d_alias, [
1585                 #include <linux/list.h>
1586                 #include <linux/dcache.h>
1587         ],[
1588                 struct dentry de;
1589                 INIT_LIST_HEAD(&de.d_u.d_alias);
1590         ],[
1591                 AC_DEFINE(HAVE_DENTRY_D_U_D_ALIAS, 1,
1592                         [list dentry.d_u.d_alias exist])
1593         ])
1594 ],[
1595         LB_CHECK_COMPILE([if hlist 'dentry.d_u.d_alias' exist],
1596         d_alias, [
1597                 #include <linux/list.h>
1598                 #include <linux/dcache.h>
1599         ],[
1600                 struct dentry de;
1601                 INIT_HLIST_NODE(&de.d_u.d_alias);
1602         ],[
1603                 AC_DEFINE(HAVE_DENTRY_D_U_D_ALIAS, 1,
1604                         [hlist dentry.d_u.d_alias exist])
1605         ])
1606 ])
1607 ]) # LC_HAVE_DENTRY_D_U_D_ALIAS
1608
1609 #
1610 # LC_HAVE_DENTRY_D_CHILD
1611 #
1612 # 3.11 kernel d_child has been moved out of the union d_u
1613 # in struct dentry
1614 #
1615 AC_DEFUN([LC_HAVE_DENTRY_D_CHILD], [
1616 LB_CHECK_COMPILE([if 'dentry.d_child' exist],
1617 d_child, [
1618         #include <linux/list.h>
1619         #include <linux/dcache.h>
1620 ],[
1621         struct dentry de;
1622         INIT_LIST_HEAD(&de.d_child);
1623 ],[
1624         AC_DEFINE(HAVE_DENTRY_D_CHILD, 1,
1625                 [dentry.d_child exist])
1626 ])
1627 ]) # LC_HAVE_DENTRY_D_CHILD
1628
1629 #
1630 # LC_KIOCB_KI_LEFT
1631 #
1632 # 3.12 ki_left removed from struct kiocb
1633 #
1634 AC_DEFUN([LC_KIOCB_KI_LEFT], [
1635 LB_CHECK_COMPILE([if 'struct kiocb' with 'ki_left' member],
1636 kiocb_ki_left, [
1637         #include <linux/aio.h>
1638 ],[
1639         ((struct kiocb*)0)->ki_left = 0;
1640 ],[
1641         AC_DEFINE(HAVE_KIOCB_KI_LEFT, 1,
1642                 [ki_left exist])
1643 ])
1644 ]) # LC_KIOCB_KI_LEFT
1645
1646 #
1647 # LC_VFS_RENAME_5ARGS
1648 #
1649 # 3.13 has vfs_rename with 5 args
1650 #
1651 AC_DEFUN([LC_VFS_RENAME_5ARGS], [
1652 LB_CHECK_COMPILE([if Linux kernel has 'vfs_rename' with 5 args],
1653 vfs_rename_5args, [
1654         #include <linux/fs.h>
1655 ],[
1656         vfs_rename(NULL, NULL, NULL, NULL, NULL);
1657 ], [
1658         AC_DEFINE(HAVE_VFS_RENAME_5ARGS, 1,
1659                 [kernel has vfs_rename with 5 args])
1660 ])
1661 ]) # LC_VFS_RENAME_5ARGS
1662
1663 #
1664 # LC_VFS_UNLINK_3ARGS
1665 #
1666 # 3.13 has vfs_unlink with 3 args
1667 #
1668 AC_DEFUN([LC_VFS_UNLINK_3ARGS], [
1669 LB_CHECK_COMPILE([if Linux kernel has 'vfs_unlink' with 3 args],
1670 vfs_unlink_3args, [
1671         #include <linux/fs.h>
1672 ],[
1673         vfs_unlink(NULL, NULL, NULL);
1674 ], [
1675         AC_DEFINE(HAVE_VFS_UNLINK_3ARGS, 1,
1676                 [kernel has vfs_unlink with 3 args])
1677 ])
1678 ]) # LC_VFS_UNLINK_3ARGS
1679
1680 #
1681 # LC_HAVE_BVEC_ITER
1682 #
1683 # 3.14 move some of its data in struct bio into the new
1684 # struct bvec_iter
1685 #
1686 AC_DEFUN([LC_HAVE_BVEC_ITER], [
1687 LB_CHECK_COMPILE([if Linux kernel has struct bvec_iter],
1688 have_bvec_iter, [
1689         #include <linux/bio.h>
1690 ],[
1691         struct bvec_iter iter;
1692         iter.bi_bvec_done = 0;
1693 ], [
1694         AC_DEFINE(HAVE_BVEC_ITER, 1,
1695                 [kernel has struct bvec_iter])
1696 ])
1697 ]) # LC_HAVE_BVEC_ITER
1698
1699 #
1700 # LC_IOP_SET_ACL
1701 #
1702 # 3.14 adds set_acl method to inode_operations
1703 # see kernel commit 893d46e443346370cd4ea81d9d35f72952c62a37
1704 #
1705 AC_DEFUN([LC_IOP_SET_ACL], [
1706 LB_CHECK_COMPILE([if 'inode_operations' has '.set_acl' member function],
1707 inode_ops_set_acl, [
1708         #include <linux/fs.h>
1709 ],[
1710         struct inode_operations iop;
1711         iop.set_acl = NULL;
1712 ],[
1713         AC_DEFINE(HAVE_IOP_SET_ACL, 1,
1714                 [inode_operations has .set_acl member function])
1715 ])
1716 ]) # LC_IOP_SET_ACL
1717
1718 #
1719 # LC_HAVE_BI_CNT
1720 #
1721 # 4.4 redefined bi_cnt as __bi_cnt
1722 #
1723 AC_DEFUN([LC_HAVE_BI_CNT], [
1724 LB_CHECK_COMPILE([if Linux kernel has bi_cnt in struct bio],
1725 have_bi_cnt, [
1726         #include <asm/atomic.h>
1727         #include <linux/bio.h>
1728 ],[
1729         struct bio bio;
1730         int cnt;
1731         cnt = atomic_read(&bio.bi_cnt);
1732 ], [
1733         AC_DEFINE(HAVE_BI_CNT, 1,
1734                 [struct bio has bi_cnt])
1735 ])
1736 ]) # LC_HAVE_BI_CNT
1737
1738 #
1739 # LC_HAVE_BI_RW
1740 #
1741 # 4.4 redefined bi_rw as bi_opf
1742 #
1743 AC_DEFUN([LC_HAVE_BI_RW], [
1744 LB_CHECK_COMPILE([if Linux kernel has bi_rw in struct bio],
1745 have_bi_rw, [
1746         #include <linux/bio.h>
1747 ],[
1748         struct bio bio;
1749         bio.bi_rw;
1750 ], [
1751         AC_DEFINE(HAVE_BI_RW, 1,
1752                 [struct bio has bi_rw])
1753 ])
1754 ]) # LC_HAVE_BI_RW
1755
1756 #
1757 # LC_HAVE_SUBMIT_BIO_2ARGS
1758 #
1759 # 4.4 removed an argument from submit_bio
1760 #
1761 AC_DEFUN([LC_HAVE_SUBMIT_BIO_2ARGS], [
1762 LB_CHECK_COMPILE([if submit_bio takes two arguments],
1763 have_submit_bio_2args, [
1764         #include <linux/bio.h>
1765 ],[
1766         struct bio bio;
1767         submit_bio(READ, &bio);
1768 ], [
1769         AC_DEFINE(HAVE_SUBMIT_BIO_2ARGS, 1,
1770                 [submit_bio takes two arguments])
1771 ])
1772 ]) # LC_HAVE_SUBMIT_BIO_2_ARGS
1773
1774 #
1775 # LC_HAVE_CLEAN_BDEV_ALIASES
1776 #
1777 # 4.4 unmap_underlying_metadata was replaced by clean_bdev_aliases
1778 #
1779 AC_DEFUN([LC_HAVE_CLEAN_BDEV_ALIASES], [
1780 LB_CHECK_COMPILE([if kernel has clean_bdev_aliases],
1781 have_clean_bdev_aliases, [
1782         #include <linux/buffer_head.h>
1783 ],[
1784         struct block_device bdev;
1785         clean_bdev_aliases(&bdev,1,1);
1786 ], [
1787         AC_DEFINE(HAVE_CLEAN_BDEV_ALIASES, 1,
1788                 [kernel has clean_bdev_aliases])
1789 ])
1790 ]) # LC_HAVE_CLEAN_BDEV_ALIASES
1791
1792 #
1793 # LC_HAVE_TRUNCATE_IPAGE_FINAL
1794 #
1795 # 3.14 bring truncate_inode_pages_final for evict_inode
1796 #
1797 AC_DEFUN([LC_HAVE_TRUNCATE_IPAGES_FINAL], [
1798 LB_CHECK_COMPILE([if Linux kernel has truncate_inode_pages_final],
1799 truncate_ipages_final, [
1800         #include <linux/mm.h>
1801 ],[
1802         truncate_inode_pages_final(NULL);
1803 ], [
1804         AC_DEFINE(HAVE_TRUNCATE_INODE_PAGES_FINAL, 1,
1805                 [kernel has truncate_inode_pages_final])
1806 ])
1807 ]) # LC_HAVE_TRUNCATE_IPAGES_FINAL
1808
1809 #
1810 # LC_IOPS_RENAME_WITH_FLAGS
1811 #
1812 # 3.14 has inode_operations->rename with 5 args
1813 # commit 520c8b16505236fc82daa352e6c5e73cd9870cff
1814 #
1815 AC_DEFUN([LC_IOPS_RENAME_WITH_FLAGS], [
1816 LB_CHECK_COMPILE([if 'inode_operations->rename' taken flags as argument],
1817 iops_rename_with_flags, [
1818         #include <linux/fs.h>
1819 ],[
1820         struct inode *i1 = NULL, *i2 = NULL;
1821         struct dentry *d1 = NULL, *d2 = NULL;
1822         int rc;
1823         rc = ((struct inode_operations *)0)->rename(i1, d1, i2, d2, 0);
1824 ], [
1825         AC_DEFINE(HAVE_IOPS_RENAME_WITH_FLAGS, 1,
1826                 [inode_operations->rename need flags as argument])
1827 ])
1828 ]) # LC_IOPS_RENAME_WITH_FLAGS
1829
1830 #
1831 # LC_VFS_RENAME_6ARGS
1832 #
1833 # 3.15 has vfs_rename with 6 args
1834 #
1835 AC_DEFUN([LC_VFS_RENAME_6ARGS], [
1836 LB_CHECK_COMPILE([if Linux kernel has 'vfs_rename' with 6 args],
1837 vfs_rename_6args, [
1838         #include <linux/fs.h>
1839 ],[
1840         vfs_rename(NULL, NULL, NULL, NULL, NULL, NULL);
1841 ], [
1842         AC_DEFINE(HAVE_VFS_RENAME_6ARGS, 1,
1843                 [kernel has vfs_rename with 6 args])
1844 ])
1845 ]) # LC_VFS_RENAME_6ARGS
1846
1847 #
1848 # LC_DIRECTIO_USE_ITER
1849 #
1850 # 3.16 kernel changes direct IO to use iov_iter
1851 #
1852 AC_DEFUN([LC_DIRECTIO_USE_ITER], [
1853 LB_CHECK_COMPILE([if direct IO uses iov_iter],
1854 direct_io_iter, [
1855         #include <linux/fs.h>
1856 ],[
1857         struct address_space_operations ops;
1858         struct iov_iter *iter = NULL;
1859         loff_t offset = 0;
1860
1861         ops.direct_IO(0, NULL, iter, offset);
1862 ],[
1863         AC_DEFINE(HAVE_DIRECTIO_ITER, 1,
1864                 [direct IO uses iov_iter])
1865 ])
1866 ]) # LC_DIRECTIO_USE_ITER
1867
1868 #
1869 # LC_HAVE_IOV_ITER_INIT_DIRECTION
1870 #
1871 #
1872 # 3.16 linux commit 71d8e532b1549a478e6a6a8a44f309d050294d00
1873 #      changed iov_iter_init api to start accepting a tag
1874 #      that defines if its a read or write operation
1875 #
1876 AC_DEFUN([LC_HAVE_IOV_ITER_INIT_DIRECTION], [
1877 tmp_flags="$EXTRA_KCFLAGS"
1878 EXTRA_KCFLAGS="-Werror"
1879 LB_CHECK_COMPILE([if 'iov_iter_init' takes a tag],
1880 iter_init, [
1881         #include <linux/uio.h>
1882         #include <linux/fs.h>
1883 ],[
1884         const struct iovec *iov = NULL;
1885
1886         iov_iter_init(NULL, READ, iov, 1, 0);
1887 ],[
1888         AC_DEFINE(HAVE_IOV_ITER_INIT_DIRECTION, 1,
1889                 [iov_iter_init handles directional tag])
1890 ])
1891 EXTRA_KCFLAGS="$tmp_flags"
1892 ]) # LC_HAVE_IOV_ITER_INIT_DIRECTION
1893
1894 #
1895 # LC_HAVE_IOV_ITER_TRUNCATE
1896 #
1897 #
1898 # 3.16 introduces a new API iov_iter_truncate()
1899 #
1900 AC_DEFUN([LC_HAVE_IOV_ITER_TRUNCATE], [
1901 tmp_flags="$EXTRA_KCFLAGS"
1902 EXTRA_KCFLAGS="-Werror"
1903 LB_CHECK_COMPILE([if 'iov_iter_truncate' exists ],
1904 iter_truncate, [
1905         #include <linux/uio.h>
1906         #include <linux/fs.h>
1907 ],[
1908         struct iov_iter *i = NULL;
1909
1910         iov_iter_truncate(i, 0);
1911 ],[
1912         AC_DEFINE(HAVE_IOV_ITER_TRUNCATE, 1, [iov_iter_truncate exists])
1913 ])
1914 EXTRA_KCFLAGS="$tmp_flags"
1915 ]) # LC_HAVE_IOV_ITER_TRUNCATE
1916
1917 #
1918 # LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
1919 #
1920 # 3.16 introduces [read|write]_iter to struct file_operations
1921 #
1922 AC_DEFUN([LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER], [
1923 LB_CHECK_COMPILE([if 'file_operations.[read|write]_iter' exist],
1924 file_function_iter, [
1925         #include <linux/fs.h>
1926 ],[
1927         ((struct file_operations *)NULL)->read_iter(NULL, NULL);
1928         ((struct file_operations *)NULL)->write_iter(NULL, NULL);
1929 ],[
1930         AC_DEFINE(HAVE_FILE_OPERATIONS_READ_WRITE_ITER, 1,
1931                 [file_operations.[read|write]_iter functions exist])
1932 ])
1933 ]) # LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
1934
1935 #
1936 # LC_KEY_MATCH_DATA
1937 #
1938 # 3.17  replaces key_type::match with match_preparse
1939 #       and has new struct key_match_data
1940 #
1941 AC_DEFUN([LC_KEY_MATCH_DATA], [
1942 LB_CHECK_COMPILE([if struct key_match field exist],
1943 key_match, [
1944         #include <linux/key-type.h>
1945 ],[
1946         struct key_match_data data;
1947 ],[
1948         AC_DEFINE(HAVE_KEY_MATCH_DATA, 1,
1949                 [struct key_match_data exist])
1950 ])
1951 ]) # LC_KEY_MATCH_DATA
1952
1953 #
1954 # LC_NFS_FILLDIR_USE_CTX
1955 #
1956 # 3.18 kernel moved from void cookie to struct dir_context
1957 #
1958 AC_DEFUN([LC_NFS_FILLDIR_USE_CTX], [
1959 tmp_flags="$EXTRA_KCFLAGS"
1960 EXTRA_KCFLAGS="-Werror"
1961 LB_CHECK_COMPILE([if filldir_t uses struct dir_context],
1962 filldir_ctx, [
1963         #include <linux/fs.h>
1964 ],[
1965         int filldir(struct dir_context *ctx, const char* name,
1966                     int i, loff_t off, u64 tmp, unsigned temp)
1967         {
1968                 return 0;
1969         }
1970
1971         struct dir_context ctx = {
1972                 .actor = filldir,
1973         };
1974
1975         ctx.actor(NULL, "test", 0, (loff_t) 0, 0, 0);
1976 ],[
1977         AC_DEFINE(HAVE_FILLDIR_USE_CTX, 1,
1978                 [filldir_t needs struct dir_context as argument])
1979 ])
1980 EXTRA_KCFLAGS="$tmp_flags"
1981 ]) # LC_NFS_FILLDIR_USE_CTX
1982
1983 #
1984 # LC_PERCPU_COUNTER_INIT
1985 #
1986 # 3.18  For kernels 3.18 and after percpu_counter_init starts
1987 #       to pass a GFP_* memory allocation flag for internal
1988 #       memory allocation purposes.
1989 #
1990 AC_DEFUN([LC_PERCPU_COUNTER_INIT], [
1991 LB_CHECK_COMPILE([if percpu_counter_init uses GFP_* flag as argument],
1992 percpu_counter_init, [
1993         #include <linux/percpu_counter.h>
1994 ],[
1995         percpu_counter_init(NULL, 0, GFP_KERNEL);
1996 ],[
1997         AC_DEFINE(HAVE_PERCPU_COUNTER_INIT_GFP_FLAG, 1,
1998                 [percpu_counter_init uses GFP_* flag])
1999 ])
2000 ]) # LC_PERCPU_COUNTER_INIT
2001
2002 #
2003 # LC_KIOCB_HAS_NBYTES
2004 #
2005 # 3.19 kernel removed ki_nbytes from struct kiocb
2006 #
2007 AC_DEFUN([LC_KIOCB_HAS_NBYTES], [
2008 LB_CHECK_COMPILE([if struct kiocb has ki_nbytes field],
2009 ki_nbytes, [
2010         #include <linux/fs.h>
2011 ],[
2012         struct kiocb iocb;
2013
2014         iocb.ki_nbytes = 0;
2015 ],[
2016         AC_DEFINE(HAVE_KI_NBYTES, 1, [ki_nbytes field exist])
2017 ])
2018 ]) # LC_KIOCB_HAS_NBYTES
2019
2020 #
2021 # LC_HAVE_DQUOT_QC_DQBLK
2022 #
2023 # 3.19 has quotactl_ops->[sg]et_dqblk that take struct kqid and qc_dqblk
2024 # Added in commit 14bf61ffe
2025 #
2026 AC_DEFUN([LC_HAVE_DQUOT_QC_DQBLK], [
2027 tmp_flags="$EXTRA_KCFLAGS"
2028 EXTRA_KCFLAGS="-Werror"
2029 LB_CHECK_COMPILE([if 'quotactl_ops.set_dqblk' takes struct qc_dqblk],
2030 qc_dqblk, [
2031         #include <linux/fs.h>
2032         #include <linux/quota.h>
2033 ],[
2034         ((struct quotactl_ops *)0)->set_dqblk(NULL, *((struct kqid*)0), (struct qc_dqblk*)0);
2035 ],[
2036         AC_DEFINE(HAVE_DQUOT_QC_DQBLK, 1,
2037                 [quotactl_ops.set_dqblk takes struct qc_dqblk])
2038         AC_DEFINE(HAVE_DQUOT_KQID, 1,
2039                 [quotactl_ops.set_dqblk takes struct kqid])
2040 ])
2041 EXTRA_KCFLAGS="$tmp_flags"
2042 ]) # LC_HAVE_DQUOT_QC_DQBLK
2043
2044 #
2045 # LC_BACKING_DEV_INFO_REMOVAL
2046 #
2047 # 3.20 kernel removed backing_dev_info from address_space
2048 #
2049 AC_DEFUN([LC_BACKING_DEV_INFO_REMOVAL], [
2050 LB_CHECK_COMPILE([if struct address_space has backing_dev_info],
2051 backing_dev_info, [
2052         #include <linux/fs.h>
2053 ],[
2054         struct address_space mapping;
2055
2056         mapping.backing_dev_info = NULL;
2057 ],[
2058         AC_DEFINE(HAVE_BACKING_DEV_INFO, 1, [backing_dev_info exist])
2059 ])
2060 ]) # LC_BACKING_DEV_INFO_REMOVAL
2061
2062 #
2063 # LC_HAVE_BDI_CAP_MAP_COPY
2064 #
2065 # 3.20  removed mmap handling for backing devices since
2066 #       it breaks on non-MMU systems. See kernel commit
2067 #       b4caecd48005fbed3949dde6c1cb233142fd69e9
2068 #
2069 AC_DEFUN([LC_HAVE_BDI_CAP_MAP_COPY], [
2070 LB_CHECK_COMPILE([if have 'BDI_CAP_MAP_COPY'],
2071 bdi_cap_map_copy, [
2072         #include <linux/backing-dev.h>
2073 ],[
2074         struct backing_dev_info info;
2075
2076         info.capabilities = BDI_CAP_MAP_COPY;
2077 ],[
2078         AC_DEFINE(HAVE_BDI_CAP_MAP_COPY, 1,
2079                 [BDI_CAP_MAP_COPY exist])
2080 ])
2081 ]) # LC_HAVE_BDI_CAP_MAP_COPY
2082
2083 #
2084 # LC_CANCEL_DIRTY_PAGE
2085 #
2086 # 4.0.0 kernel removed cancel_dirty_page
2087 #
2088 AC_DEFUN([LC_CANCEL_DIRTY_PAGE], [
2089 LB_CHECK_COMPILE([if cancel_dirty_page still exist],
2090 cancel_dirty_page, [
2091         #include <linux/mm.h>
2092 ],[
2093         cancel_dirty_page(NULL, PAGE_SIZE);
2094 ],[
2095         AC_DEFINE(HAVE_CANCEL_DIRTY_PAGE, 1,
2096                 [cancel_dirty_page is still available])
2097 ])
2098 ]) # LC_CANCEL_DIRTY_PAGE
2099
2100 #
2101 # LC_IOV_ITER_RW
2102 #
2103 # 4.1 kernel has iov_iter_rw
2104 #
2105 AC_DEFUN([LC_IOV_ITER_RW], [
2106 LB_CHECK_COMPILE([if iov_iter_rw exist],
2107 iov_iter_rw, [
2108         #include <linux/fs.h>
2109         #include <linux/uio.h>
2110 ],[
2111         struct iov_iter *iter = NULL;
2112
2113         iov_iter_rw(iter);
2114 ],[
2115         AC_DEFINE(HAVE_IOV_ITER_RW, 1,
2116                 [iov_iter_rw exist])
2117 ])
2118 ]) # LC_IOV_ITER_RW
2119
2120 #
2121 # LC_HAVE_SYNC_READ_WRITE
2122 #
2123 # 4.1 new_sync_[read|write] no longer exported
2124 #
2125 AC_DEFUN([LC_HAVE_SYNC_READ_WRITE], [
2126 LB_CHECK_EXPORT([new_sync_read], [fs/read_write.c],
2127         [AC_DEFINE(HAVE_SYNC_READ_WRITE, 1,
2128                         [new_sync_[read|write] is exported by the kernel])])
2129 ]) # LC_HAVE_SYNC_READ_WRITE
2130
2131 #
2132 # LC_NEW_CANCEL_DIRTY_PAGE
2133 #
2134 # 4.2 kernel has new cancel_dirty_page
2135 #
2136 AC_DEFUN([LC_NEW_CANCEL_DIRTY_PAGE], [
2137 LB_CHECK_COMPILE([if cancel_dirty_page with one argument exist],
2138 new_cancel_dirty_page, [
2139         #include <linux/mm.h>
2140 ],[
2141         cancel_dirty_page(NULL);
2142 ],[
2143         AC_DEFINE(HAVE_NEW_CANCEL_DIRTY_PAGE, 1,
2144                 [cancel_dirty_page with one arguement is available])
2145 ])
2146 ]) # LC_NEW_CANCEL_DIRTY_PAGE
2147
2148 #
2149 # LC_SYMLINK_OPS_USE_NAMEIDATA
2150 #
2151 # For the 4.2+ kernels the file system internal symlink api no
2152 # longer uses struct nameidata as a argument
2153 #
2154 AC_DEFUN([LC_SYMLINK_OPS_USE_NAMEIDATA], [
2155 LB_CHECK_COMPILE([if symlink inode operations have struct nameidata argument],
2156 symlink_use_nameidata, [
2157         #include <linux/namei.h>
2158         #include <linux/fs.h>
2159 ],[
2160         struct nameidata *nd = NULL;
2161
2162         ((struct inode_operations *)0)->follow_link(NULL, nd);
2163         ((struct inode_operations *)0)->put_link(NULL, nd, NULL);
2164 ],[
2165         AC_DEFINE(HAVE_SYMLINK_OPS_USE_NAMEIDATA, 1,
2166                 [symlink inode operations need struct nameidata argument])
2167 ])
2168 ]) # LC_SYMLINK_OPS_USE_NAMEIDATA
2169
2170 #
2171 # LC_BIO_ENDIO_USES_ONE_ARG
2172 #
2173 # 4.2 kernel bio_endio now only takes one argument
2174 #
2175 AC_DEFUN([LC_BIO_ENDIO_USES_ONE_ARG], [
2176 LB_CHECK_COMPILE([if 'bio_endio' with one argument exist],
2177 bio_endio, [
2178         #include <linux/bio.h>
2179 ],[
2180         bio_endio(NULL);
2181 ],[
2182         AC_DEFINE(HAVE_BIO_ENDIO_USES_ONE_ARG, 1,
2183                 [bio_endio takes only one argument])
2184 ])
2185 ]) # LC_BIO_ENDIO_USES_ONE_ARG
2186
2187 #
2188 # LC_HAVE_LOOP_CTL_GET_FREE
2189 #
2190 # 4.x kernel have moved userspace APIs to
2191 # the separate directory and all of them
2192 # support LOOP_CTL_GET_FREE
2193 #
2194 AC_DEFUN([LC_HAVE_LOOP_CTL_GET_FREE], [
2195 LB_CHECK_FILE([$LINUX/include/linux/loop.h], [
2196         LB_CHECK_COMPILE([if have 'HAVE_LOOP_CTL_GET_FREE'],
2197         LOOP_CTL_GET_FREE, [
2198                 #include <linux/loop.h>
2199         ],[
2200                 int i;
2201
2202                 i = LOOP_CTL_GET_FREE;
2203         ],[
2204                 AC_DEFINE(HAVE_LOOP_CTL_GET_FREE, 1,
2205                         [LOOP_CTL_GET_FREE exist])
2206         ])
2207 ],[
2208         AC_DEFINE(HAVE_LOOP_CTL_GET_FREE, 1,
2209                 [kernel has LOOP_CTL_GET_FREE])
2210 ])
2211 ]) # LC_HAVE_LOOP_CTL_GET_FREE
2212
2213 #
2214 # LC_HAVE_CACHE_HEAD_HLIST
2215 #
2216 # 4.3 kernel swiched to hlist for cache_head
2217 #
2218 AC_DEFUN([LC_HAVE_CACHE_HEAD_HLIST], [
2219 LB_CHECK_COMPILE([if 'struct cache_head' has 'cache_list' field],
2220 cache_head_has_hlist, [
2221         #include <linux/sunrpc/cache.h>
2222 ],[
2223         do {} while(sizeof(((struct cache_head *)0)->cache_list));
2224 ],[
2225         AC_DEFINE(HAVE_CACHE_HEAD_HLIST, 1,
2226                 [cache_head has hlist cache_list])
2227 ])
2228 ]) # LC_HAVE_CACHE_HEAD_HLIST
2229
2230 #
2231 # LC_HAVE_XATTR_HANDLER_SIMPLIFIED
2232 #
2233 # Kernel version 4.3 commit e409de992e3ea3674393465f07cc71c948edd87a
2234 # simplified xattr_handler handling by passing in the handler pointer
2235 #
2236 AC_DEFUN([LC_HAVE_XATTR_HANDLER_SIMPLIFIED], [
2237 tmp_flags="$EXTRA_KCFLAGS"
2238 EXTRA_KCFLAGS="-Werror"
2239 LB_CHECK_COMPILE([if 'struct xattr_handler' functions pass in handler pointer],
2240 xattr_handler_simplified, [
2241         #include <linux/xattr.h>
2242 ],[
2243         struct xattr_handler handler;
2244
2245         ((struct xattr_handler *)0)->get(&handler, NULL, NULL, NULL, 0);
2246         ((struct xattr_handler *)0)->set(&handler, NULL, NULL, NULL, 0, 0);
2247 ],[
2248         AC_DEFINE(HAVE_XATTR_HANDLER_SIMPLIFIED, 1, [handler pointer is parameter])
2249 ])
2250 EXTRA_KCFLAGS="$tmp_flags"
2251 ]) # LC_HAVE_XATTR_HANDLER_SIMPLIFIED
2252
2253 #
2254 # LC_HAVE_LOCKS_LOCK_FILE_WAIT
2255 #
2256 # 4.4 kernel have moved locks API users to
2257 # locks_lock_inode_wait()
2258 #
2259 AC_DEFUN([LC_HAVE_LOCKS_LOCK_FILE_WAIT], [
2260 LB_CHECK_COMPILE([if 'locks_lock_file_wait' exists],
2261 locks_lock_file_wait, [
2262         #include <linux/fs.h>
2263 ],[
2264         locks_lock_file_wait(NULL, NULL);
2265 ],[
2266         AC_DEFINE(HAVE_LOCKS_LOCK_FILE_WAIT, 1,
2267                 [kernel has locks_lock_file_wait])
2268 ])
2269 ]) # LC_HAVE_LOCKS_LOCK_FILE_WAIT
2270
2271 #
2272 # LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
2273 #
2274 # 4.4 kernel merged type-specific data with the payload data for keys
2275 #
2276 AC_DEFUN([LC_HAVE_KEY_PAYLOAD_DATA_ARRAY], [
2277 LB_CHECK_COMPILE([if 'struct key' has 'payload.data' as an array],
2278 key_payload_data_array, [
2279         #include <linux/key.h>
2280 ],[
2281         ((struct key *)0)->payload.data[0] = NULL;
2282 ],[
2283         AC_DEFINE(HAVE_KEY_PAYLOAD_DATA_ARRAY, 1, [payload.data is an array])
2284 ])
2285 ]) #LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
2286
2287 #
2288 # LC_HAVE_FILE_DENTRY
2289 #
2290 # 4.5 adds wrapper file_dentry
2291 #
2292 AC_DEFUN([LC_HAVE_FILE_DENTRY], [
2293 LB_CHECK_COMPILE([if Linux kernel has 'file_dentry'],
2294 file_dentry, [
2295         #include <linux/fs.h>
2296 ],[
2297         file_dentry(NULL);
2298 ], [
2299         AC_DEFINE(HAVE_FILE_DENTRY, 1,
2300                 [kernel has file_dentry])
2301 ])
2302 ]) # LC_HAVE_FILE_DENTRY
2303
2304 #
2305 # LC_HAVE_INODE_LOCK
2306 #
2307 # 4.5 introduced inode_lock
2308 #
2309 AC_DEFUN([LC_HAVE_INODE_LOCK], [
2310 LB_CHECK_COMPILE([if 'inode_lock' is defined],
2311 inode_lock, [
2312         #include <linux/fs.h>
2313 ],[
2314         inode_lock(NULL);
2315 ], [
2316         AC_DEFINE(HAVE_INODE_LOCK, 1,
2317                   [inode_lock is defined])
2318 ])
2319 ]) # LC_HAVE_INODE_LOCK
2320
2321 #
2322 # LC_HAVE_IOP_GET_LINK
2323 #
2324 # 4.5 vfs replaced iop->follow_link with
2325 # iop->get_link
2326 #
2327 AC_DEFUN([LC_HAVE_IOP_GET_LINK], [
2328 LB_CHECK_COMPILE([if 'iop' has 'get_link'],
2329 inode_ops_get_link, [
2330         #include <linux/fs.h>
2331 ],[
2332         struct inode_operations iop;
2333         iop.get_link = NULL;
2334 ],[
2335         AC_DEFINE(HAVE_IOP_GET_LINK, 1,
2336                 [have iop get_link])
2337 ])
2338 ]) # LC_HAVE_IOP_GET_LINK
2339
2340 #
2341 # LC_HAVE_IN_COMPAT_SYSCALL
2342 #
2343 # 4.6 renamed is_compat_task to in_compat_syscall
2344 #
2345 AC_DEFUN([LC_HAVE_IN_COMPAT_SYSCALL], [
2346 LB_CHECK_COMPILE([if 'in_compat_syscall' is defined],
2347 in_compat_syscall, [
2348         #include <linux/compat.h>
2349 ],[
2350         in_compat_syscall();
2351 ],[
2352         AC_DEFINE(HAVE_IN_COMPAT_SYSCALL, 1,
2353                 [have in_compat_syscall])
2354 ])
2355 ]) # LC_HAVE_IN_COMPAT_SYSCALL
2356
2357 #
2358 # LC_HAVE_XATTR_HANDLER_INODE_PARAM
2359 #
2360 # Kernel version 4.6 commit b296821a7c42fa58baa17513b2b7b30ae66f3336
2361 # and commit 5930122683dff58f0846b0f0405b4bd598a3ba6a added inode parameter
2362 # to xattr_handler functions
2363 #
2364 AC_DEFUN([LC_HAVE_XATTR_HANDLER_INODE_PARAM], [
2365 tmp_flags="$EXTRA_KCFLAGS"
2366 EXTRA_KCFLAGS="-Werror"
2367 LB_CHECK_COMPILE([if 'struct xattr_handler' functions have inode parameter],
2368 xattr_handler_inode_param, [
2369         #include <linux/xattr.h>
2370 ],[
2371         const struct xattr_handler handler;
2372
2373         ((struct xattr_handler *)0)->get(&handler, NULL, NULL, NULL, NULL, 0);
2374         ((struct xattr_handler *)0)->set(&handler, NULL, NULL, NULL, NULL, 0, 0);
2375 ],[
2376         AC_DEFINE(HAVE_XATTR_HANDLER_INODE_PARAM, 1, [needs inode parameter])
2377 ])
2378 EXTRA_KCFLAGS="$tmp_flags"
2379 ]) # LC_HAVE_XATTR_HANDLER_INODE_PARAM
2380
2381 #
2382 # LC_DIRECTIO_2ARGS
2383 #
2384 # Kernel version 4.7 commit c8b8e32d700fe943a935e435ae251364d016c497
2385 # direct-io: eliminate the offset argument to ->direct_IO
2386 #
2387 AC_DEFUN([LC_DIRECTIO_2ARGS], [
2388 LB_CHECK_COMPILE([if '->direct_IO()' taken 2 arguments],
2389 direct_io_2args, [
2390         #include <linux/fs.h>
2391 ],[
2392         struct address_space_operations ops;
2393         struct iov_iter *iter = NULL;
2394         struct kiocb *iocb = NULL;
2395         int rc;
2396         rc = ops.direct_IO(iocb, iter);
2397 ],[
2398         AC_DEFINE(HAVE_DIRECTIO_2ARGS, 1,
2399                 [direct_IO need 2 arguments])
2400 ])
2401 ]) # LC_DIRECTIO_2ARGS
2402
2403 #
2404 # LC_GENERIC_WRITE_SYNC_2ARGS
2405 #
2406 # Kernel version 4.7 commit c8b8e32d700fe943a935e435ae251364d016c497
2407 # direct-io: eliminate the offset argument to ->direct_IO
2408 #
2409 AC_DEFUN([LC_GENERIC_WRITE_SYNC_2ARGS], [
2410 LB_CHECK_COMPILE([if 'generic_write_sync()' taken 2 arguments],
2411 generic_write_sync_2args, [
2412         #include <linux/fs.h>
2413 ],[
2414         struct kiocb *iocb = NULL;
2415         ssize_t rc;
2416         rc = generic_write_sync(iocb, 0);
2417 ],[
2418         AC_DEFINE(HAVE_GENERIC_WRITE_SYNC_2ARGS, 1,
2419                 [generic_write_sync need 2 arguments])
2420 ])
2421 ]) # LC_GENERIC_WRITE_SYNC_2ARGS
2422
2423 #
2424 # LC_HAVE_POSIX_ACL_VALID_USER_NS
2425 #
2426 # 4.8 posix_acl_valid takes struct user_namespace
2427 #
2428 AC_DEFUN([LC_HAVE_POSIX_ACL_VALID_USER_NS], [
2429 LB_CHECK_COMPILE([if 'posix_acl_valid' takes 'struct user_namespace'],
2430 posix_acl_valid, [
2431         #include <linux/fs.h>
2432         #include <linux/posix_acl.h>
2433 ],[
2434         posix_acl_valid((struct user_namespace*)NULL, (const struct posix_acl*)NULL);
2435 ],[
2436         AC_DEFINE(HAVE_POSIX_ACL_VALID_USER_NS, 1,
2437                 [posix_acl_valid takes struct user_namespace])
2438 ])
2439 ]) # LC_HAVE_POSIX_ACL_VALID_USER_NS
2440
2441 #
2442 # LC_D_COMPARE_4ARGS
2443 #
2444 # Kernel version 4.8 commit 6fa67e707559303e086303aeecc9e8b91ef497d5
2445 # get rid of 'parent' argument of ->d_compare()
2446 #
2447 AC_DEFUN([LC_D_COMPARE_4ARGS], [
2448 LB_CHECK_COMPILE([if 'd_compare' taken 4 arguments],
2449 d_compare_4args, [
2450         #include <linux/dcache.h>
2451 ],[
2452         ((struct dentry_operations*)0)->d_compare(NULL,0,NULL,NULL);
2453 ],[
2454         AC_DEFINE(HAVE_D_COMPARE_4ARGS, 1,
2455                 [d_compare need 4 arguments])
2456 ])
2457 ]) # LC_D_COMPARE_4ARGS
2458
2459 #
2460 # LC_FULL_NAME_HASH_3ARGS
2461 #
2462 # Kernel version 4.8 commit 8387ff2577eb9ed245df9a39947f66976c6bcd02
2463 # vfs: make the string hashes salt the hash
2464 #
2465 AC_DEFUN([LC_FULL_NAME_HASH_3ARGS], [
2466 LB_CHECK_COMPILE([if 'full_name_hash' taken 3 arguments],
2467 full_name_hash_3args, [
2468         #include <linux/stringhash.h>
2469 ],[
2470         unsigned int hash;
2471         hash = full_name_hash(NULL,NULL,0);
2472 ],[
2473         AC_DEFINE(HAVE_FULL_NAME_HASH_3ARGS, 1,
2474                 [full_name_hash need 3 arguments])
2475 ])
2476 ]) # LC_FULL_NAME_HASH_3ARGS
2477
2478 #
2479 # LC_STRUCT_POSIX_ACL_XATTR
2480 #
2481 # Kernel version 4.8 commit 2211d5ba5c6c4e972ba6dbc912b2897425ea6621
2482 # posix_acl: xattr representation cleanups
2483 #
2484 AC_DEFUN([LC_STRUCT_POSIX_ACL_XATTR], [
2485 LB_CHECK_COMPILE([if 'struct posix_acl_xattr_{header,entry}' defined],
2486 struct_posix_acl_xattr, [
2487         #include <linux/fs.h>
2488         #include <linux/posix_acl_xattr.h>
2489 ],[
2490         struct posix_acl_xattr_header *h = NULL;
2491         struct posix_acl_xattr_entry  *e;
2492         e = (void *)(h + 1);
2493 ],[
2494         AC_DEFINE(HAVE_STRUCT_POSIX_ACL_XATTR, 1,
2495                 [struct posix_acl_xattr_{header,entry} defined])
2496 ])
2497 ]) # LC_STRUCT_POSIX_ACL_XATTR
2498
2499 #
2500 # LC_IOP_XATTR
2501 #
2502 # Kernel version 4.8 commit fd50ecaddf8372a1d96e0daeaac0f93cf04e4d42
2503 # removed {get,set,remove}xattr inode operations
2504 #
2505 AC_DEFUN([LC_IOP_XATTR], [
2506 LB_CHECK_COMPILE([if 'inode_operations' has {get,set,remove}xattr members],
2507 inode_ops_xattr, [
2508         #include <linux/fs.h>
2509 ],[
2510         struct inode_operations iop;
2511         iop.setxattr = NULL;
2512         iop.getxattr = NULL;
2513         iop.removexattr = NULL;
2514 ],[
2515         AC_DEFINE(HAVE_IOP_XATTR, 1,
2516                 [inode_operations has {get,set,remove}xattr members])
2517 ])
2518 ]) # LC_IOP_XATTR
2519
2520 #
2521 # LC_GROUP_INFO_GID
2522 #
2523 # Kernel version 4.9 commit 81243eacfa400f5f7b89f4c2323d0de9982bb0fb
2524 # cred: simpler, 1D supplementary groups
2525 #
2526 AC_DEFUN([LC_GROUP_INFO_GID], [
2527 LB_CHECK_COMPILE([if 'struct group_info' has member 'gid'],
2528 group_info_gid, [
2529         #include <linux/cred.h>
2530 ],[
2531         kgid_t *p;
2532         p = ((struct group_info *)0)->gid;
2533 ],[
2534         AC_DEFINE(HAVE_GROUP_INFO_GID, 1,
2535                 [struct group_info has member gid])
2536 ])
2537 ]) # LC_GROUP_INFO_GID
2538
2539 #
2540 # LC_VFS_SETXATTR
2541 #
2542 # Kernel version 4.9 commit 5d6c31910bc0713e37628dc0ce677dcb13c8ccf4
2543 # added __vfs_{get,set,remove}xattr helpers
2544 #
2545 AC_DEFUN([LC_VFS_SETXATTR], [
2546 LB_CHECK_COMPILE([if '__vfs_setxattr' helper is available],
2547 vfs_setxattr, [
2548         #include <linux/xattr.h>
2549 ],[
2550         __vfs_setxattr(NULL, NULL, NULL, NULL, 0, 0);
2551 ],[
2552         AC_DEFINE(HAVE_VFS_SETXATTR, 1,
2553                 ['__vfs_setxattr is available])
2554 ])
2555 ]) # LC_VFS_SETXATTR
2556
2557 #
2558 # LC_IOP_GENERIC_READLINK
2559 #
2560 # Kernel version 4.10 commit dfeef68862edd7d4bafe68ef7aeb5f658ef24bb5
2561 # removed generic_readlink from individual file systems
2562 #
2563 AC_DEFUN([LC_IOP_GENERIC_READLINK], [
2564 LB_CHECK_COMPILE([if 'generic_readlink' still exist],
2565 inode_ops_readlink, [
2566         #include <linux/fs.h>
2567 ],[
2568         struct inode_operations iop;
2569         iop.readlink = generic_readlink;
2570 ],[
2571         AC_DEFINE(HAVE_IOP_GENERIC_READLINK, 1,
2572                 [generic_readlink has been removed])
2573 ])
2574 ]) # LC_IOP_GENERIC_READLINK
2575
2576 #
2577 # LC_HAVE_VM_FAULT_ADDRESS
2578 #
2579 # Kernel version 4.10 commit 1a29d85eb0f19b7d8271923d8917d7b4f5540b3e
2580 # removed virtual_address field. Need to use address field instead
2581 #
2582 AC_DEFUN([LC_HAVE_VM_FAULT_ADDRESS], [
2583 LB_CHECK_COMPILE([if 'struct vm_fault' replaced virtual_address with address field],
2584 vm_fault_address, [
2585         #include <linux/mm.h>
2586 ],[
2587         struct vm_fault vmf;
2588         vmf.address = NULL;
2589 ],[
2590         AC_DEFINE(HAVE_VM_FAULT_ADDRESS, 1,
2591                 [virtual_address has been replaced by address field])
2592 ])
2593 ]) # LC_HAVE_VM_FAULT_ADDRESS
2594
2595 #
2596 # LC_INODEOPS_ENHANCED_GETATTR
2597 #
2598 # Kernel version 4.11 commit a528d35e8bfcc521d7cb70aaf03e1bd296c8493f
2599 # expanded getattr to be able to get more stat information.
2600 #
2601 AC_DEFUN([LC_INODEOPS_ENHANCED_GETATTR], [
2602 LB_CHECK_COMPILE([if 'inode_operations' getattr member can gather advance stats],
2603 getattr_path, [
2604         #include <linux/fs.h>
2605 ],[
2606         struct path path;
2607
2608         ((struct inode_operations *)1)->getattr(&path, NULL, 0, 0);
2609 ],[
2610         AC_DEFINE(HAVE_INODEOPS_ENHANCED_GETATTR, 1,
2611                 [inode_operations .getattr member function can gather advance stats])
2612 ])
2613 ]) # LC_INODEOPS_ENHANCED_GETATTR
2614
2615 #
2616 # LC_VM_OPERATIONS_REMOVE_VMF_ARG
2617 #
2618 # Kernel version 4.11 commit 11bac80004499ea59f361ef2a5516c84b6eab675
2619 # removed struct vm_area_struct as an argument for vm_operations since
2620 # in the same kernel version struct vma_area_struct was folded into
2621 # struct vm_fault.
2622 #
2623 AC_DEFUN([LC_VM_OPERATIONS_REMOVE_VMF_ARG], [
2624 LB_CHECK_COMPILE([if 'struct vm_operations' removed struct vm_area_struct],
2625 vm_operations_no_vm_area_struct, [
2626         #include <linux/mm.h>
2627 ],[
2628         struct vm_fault vmf;
2629
2630         ((struct vm_operations_struct *)0)->fault(&vmf);
2631         ((struct vm_operations_struct *)0)->page_mkwrite(&vmf);
2632 ],[
2633         AC_DEFINE(HAVE_VM_OPS_USE_VM_FAULT_ONLY, 1,
2634                 ['struct vm_operations' remove struct vm_area_struct argument])
2635 ])
2636 ]) # LC_VM_OPERATIONS_REMOVE_VMF_ARG
2637
2638 #
2639 # Kernel version 4.12 commit 47f38c539e9a42344ff5a664942075bd4df93876
2640 # CURRENT_TIME is not 64 bit time safe so it was replaced with
2641 # current_time()
2642 #
2643 AC_DEFUN([LC_CURRENT_TIME], [
2644 LB_CHECK_COMPILE([if CURRENT_TIME has been replaced with current_time],
2645 current_time, [
2646         #include <linux/fs.h>
2647 ],[
2648         struct timespec ts = current_time(NULL);
2649 ],[
2650         AC_DEFINE(HAVE_CURRENT_TIME, 1,
2651                 [current_time() has replaced CURRENT_TIME])
2652 ])
2653 ]) # LIBCFS_CURRENT_TIME
2654
2655 #
2656 # LC_PROG_LINUX
2657 #
2658 # Lustre linux kernel checks
2659 #
2660 AC_DEFUN([LC_PROG_LINUX], [
2661         AC_MSG_NOTICE([Lustre kernel checks
2662 ==============================================================================])
2663
2664         LC_CONFIG_PINGER
2665         LC_CONFIG_CHECKSUM
2666         LC_CONFIG_HEALTH_CHECK_WRITE
2667         LC_CONFIG_LRU_RESIZE
2668
2669         LC_GLIBC_SUPPORT_FHANDLES
2670         LC_CONFIG_GSS
2671         LC_OPENSSL_SSK
2672
2673         # 2.6.32
2674         LC_BLK_QUEUE_MAX_SEGMENTS
2675
2676         # 2.6.33
2677         LC_HAVE_XATTR_HANDLER_FLAGS
2678
2679         # 2.6.34
2680         LC_HAVE_DQUOT_FS_DISK_QUOTA
2681         LC_HAVE_DQUOT_SUSPEND
2682         LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE
2683
2684         # 2.6.35, 3.0.0
2685         LC_FILE_FSYNC
2686         LC_EXPORT_SIMPLE_SETATTR
2687         LC_EXPORT_TRUNCATE_COMPLETE_PAGE
2688
2689         # 2.6.36
2690         LC_FS_STRUCT_RWLOCK
2691         LC_SBOPS_EVICT_INODE
2692
2693         # 2.6.37
2694         LC_KERNEL_LOCKED
2695
2696         # 2.6.38
2697         LC_BLKDEV_GET_BY_DEV
2698         LC_GENERIC_PERMISSION
2699         LC_DCACHE_LOCK
2700         LC_INODE_I_RCU
2701         LC_D_COMPARE_7ARGS
2702         LC_D_DELETE_CONST
2703         LC_HAVE_BLK_PLUG
2704
2705         # 2.6.39
2706         LC_HAVE_FHANDLE_SYSCALLS
2707         LC_HAVE_FSTYPE_MOUNT
2708         LC_IOP_TRUNCATE
2709         LC_HAVE_INODE_OWNER_OR_CAPABLE
2710         LC_HAVE_SECURITY_IINITSEC
2711
2712         # 3.0
2713         LC_DIRTY_INODE_WITH_FLAG
2714         LC_SETNS
2715
2716         # 3.1
2717         LC_LM_XXX_LOCK_MANAGER_OPS
2718         LC_INODE_DIO_WAIT
2719         LC_IOP_GET_ACL
2720         LC_FILE_LLSEEK_SIZE
2721         LC_INODE_PERMISION_2ARGS
2722         LC_RADIX_EXCEPTION_ENTRY
2723         LC_HAVE_LOOP_CTL_GET_FREE
2724
2725         # 3.2
2726         LC_HAVE_PROTECT_I_NLINK
2727
2728         # 3.3
2729         LC_HAVE_MIGRATE_HEADER
2730         LC_MIGRATEPAGE_4ARGS
2731         LC_SUPEROPS_USE_DENTRY
2732         LC_INODEOPS_USE_UMODE_T
2733         LC_HAVE_CACHE_REGISTER
2734
2735         # 3.4
2736         LC_HAVE_D_MAKE_ROOT
2737         LC_KMAP_ATOMIC_HAS_1ARG
2738
2739         # 3.5
2740         LC_HAVE_CLEAR_INODE
2741         LC_HAVE_ENCODE_FH_PARENT
2742         LC_FILE_LLSEEK_SIZE_5ARG
2743
2744         # 3.6
2745         LC_DATA_FOR_LLITE_IS_LIST
2746         LC_DENTRY_OPEN_USE_PATH
2747         LC_HAVE_IOP_ATOMIC_OPEN
2748         LC_HAVE_SB_START_WRITE
2749
2750         # 3.7
2751         LC_HAVE_POSIXACL_USER_NS
2752
2753         # 3.8
2754         LC_HAVE_FILE_F_INODE
2755         LC_HAVE_FILE_INODE
2756         LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS
2757
2758         # 3.9
2759         LC_HAVE_HLIST_FOR_EACH_3ARG
2760         LC_HAVE_BIO_END_SECTOR
2761         LC_HAVE_IS_SXID
2762
2763         # 3.10
2764         LC_HAVE_REMOVE_PROC_SUBTREE
2765         LC_HAVE_PROC_REMOVE
2766         LC_HAVE_PROJECT_QUOTA
2767         LC_HAVE_SECURITY_DENTRY_INIT_SECURITY
2768
2769         # 3.11
2770         LC_INVALIDATE_RANGE
2771         LC_HAVE_DIR_CONTEXT
2772         LC_D_COMPARE_5ARGS
2773         LC_HAVE_DCOUNT
2774         LC_HAVE_DENTRY_D_U_D_ALIAS
2775         LC_HAVE_DENTRY_D_CHILD
2776         LC_PID_NS_FOR_CHILDREN
2777
2778         # 3.12
2779         LC_OLDSIZE_TRUNCATE_PAGECACHE
2780         LC_KIOCB_KI_LEFT
2781
2782         # 3.13
2783         LC_VFS_RENAME_5ARGS
2784         LC_VFS_UNLINK_3ARGS
2785
2786         # 3.14
2787         LC_HAVE_BVEC_ITER
2788         LC_HAVE_TRUNCATE_IPAGES_FINAL
2789         LC_IOPS_RENAME_WITH_FLAGS
2790         LC_IOP_SET_ACL
2791
2792         # 3.15
2793         LC_VFS_RENAME_6ARGS
2794
2795         # 3.16
2796         LC_DIRECTIO_USE_ITER
2797         LC_HAVE_IOV_ITER_INIT_DIRECTION
2798         LC_HAVE_IOV_ITER_TRUNCATE
2799         LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
2800
2801         # 3.17
2802         LC_KEY_MATCH_DATA
2803
2804         # 3.18
2805         LC_PERCPU_COUNTER_INIT
2806         LC_NFS_FILLDIR_USE_CTX
2807
2808         # 3.19
2809         LC_KIOCB_HAS_NBYTES
2810         LC_HAVE_DQUOT_QC_DQBLK
2811
2812         # 3.20
2813         LC_BACKING_DEV_INFO_REMOVAL
2814         LC_HAVE_BDI_CAP_MAP_COPY
2815
2816         # 4.0.0
2817         LC_CANCEL_DIRTY_PAGE
2818
2819         # 4.1.0
2820         LC_IOV_ITER_RW
2821         LC_HAVE_SYNC_READ_WRITE
2822
2823         # 4.2
2824         LC_NEW_CANCEL_DIRTY_PAGE
2825         LC_BIO_ENDIO_USES_ONE_ARG
2826         LC_SYMLINK_OPS_USE_NAMEIDATA
2827
2828         # 4.3
2829         LC_HAVE_CACHE_HEAD_HLIST
2830         LC_HAVE_XATTR_HANDLER_SIMPLIFIED
2831
2832         # 4.4
2833         LC_HAVE_LOCKS_LOCK_FILE_WAIT
2834         LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
2835         LC_HAVE_BI_CNT
2836         LC_HAVE_BI_RW
2837         LC_HAVE_SUBMIT_BIO_2ARGS
2838         LC_HAVE_CLEAN_BDEV_ALIASES
2839
2840         # 4.5
2841         LC_HAVE_FILE_DENTRY
2842
2843         # 4.5
2844         LC_HAVE_INODE_LOCK
2845         LC_HAVE_IOP_GET_LINK
2846
2847         # 4.6
2848         LC_HAVE_IN_COMPAT_SYSCALL
2849         LC_HAVE_XATTR_HANDLER_INODE_PARAM
2850
2851         # 4.7
2852         LC_DIRECTIO_2ARGS
2853         LC_GENERIC_WRITE_SYNC_2ARGS
2854
2855         # 4.8
2856         LC_HAVE_POSIX_ACL_VALID_USER_NS
2857         LC_D_COMPARE_4ARGS
2858         LC_FULL_NAME_HASH_3ARGS
2859         LC_STRUCT_POSIX_ACL_XATTR
2860         LC_IOP_XATTR
2861
2862         # 4.9
2863         LC_GROUP_INFO_GID
2864         LC_VFS_SETXATTR
2865
2866         # 4.10
2867         LC_IOP_GENERIC_READLINK
2868         LC_HAVE_VM_FAULT_ADDRESS
2869
2870         # 4.11
2871         LC_INODEOPS_ENHANCED_GETATTR
2872         LC_VM_OPERATIONS_REMOVE_VMF_ARG
2873
2874         # 4.12
2875         LC_CURRENT_TIME
2876
2877         #
2878         AS_IF([test "x$enable_server" != xno], [
2879                 LC_STACK_SIZE
2880                 LC_QUOTA64
2881                 LC_QUOTA_CONFIG
2882         ])
2883 ]) # LC_PROG_LINUX
2884
2885 #
2886 # LC_CONFIG_CLIENT
2887 #
2888 # Check whether to build the client side of Lustre
2889 #
2890 AC_DEFUN([LC_CONFIG_CLIENT], [
2891 AC_MSG_CHECKING([whether to build Lustre client support])
2892 AC_ARG_ENABLE([client],
2893         AC_HELP_STRING([--disable-client],
2894                 [disable Lustre client support]),
2895         [], [enable_client="yes"])
2896 AC_MSG_RESULT([$enable_client])
2897 ]) # LC_CONFIG_CLIENT
2898
2899 #
2900 # --enable-mpitests
2901 #
2902 AC_DEFUN([LB_CONFIG_MPITESTS], [
2903 AC_ARG_ENABLE([mpitests],
2904         AC_HELP_STRING([--enable-mpitests=<yes|no|mpicc wrapper>],
2905                        [include mpi tests]), [
2906                 enable_mpitests="yes"
2907                 case $enableval in
2908                 yes)
2909                         MPICC_WRAPPER="mpicc"
2910                         ;;
2911                 no)
2912                         enable_mpitests="no"
2913                         ;;
2914                 *)
2915                         MPICC_WRAPPER=$enableval
2916                         ;;
2917                 esac
2918         ], [
2919                 enable_mpitests="yes"
2920                 MPICC_WRAPPER="mpicc"
2921         ])
2922
2923         if test "x$enable_mpitests" != "xno"; then
2924                 oldcc=$CC
2925                 CC=$MPICC_WRAPPER
2926                 AC_CACHE_CHECK([whether mpitests can be built],
2927                 lb_cv_mpi_tests, [AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2928                         #include <mpi.h>
2929                         int main(void) {
2930                                 int flag;
2931                                 MPI_Initialized(&flag);
2932                                 return 0;
2933                         }
2934                 ])], [lb_cv_mpi_tests="yes"], [lb_cv_mpi_tests="no"])
2935                 ])
2936                 enable_mpitests=$lb_cv_mpi_tests
2937                 CC=$oldcc
2938         fi
2939         AC_SUBST(MPICC_WRAPPER)
2940 ]) # LB_CONFIG_MPITESTS
2941
2942 #
2943 # LC_CONFIG_QUOTA
2944 #
2945 # whether to enable quota support global control
2946 #
2947 AC_DEFUN([LC_CONFIG_QUOTA], [
2948 AC_MSG_CHECKING([whether to enable quota support global control])
2949 AC_ARG_ENABLE([quota],
2950         AC_HELP_STRING([--enable-quota],
2951                 [enable quota support]),
2952         [], [enable_quota="yes"])
2953 AS_IF([test "x$enable_quota" = xyes],
2954         [AC_MSG_RESULT([yes])],
2955         [AC_MSG_RESULT([no])])
2956 ]) # LC_CONFIG_QUOTA
2957
2958 #
2959 # LC_QUOTA
2960 #
2961 AC_DEFUN([LC_QUOTA], [
2962 #check global
2963 LC_CONFIG_QUOTA
2964 #check for utils
2965 AS_IF([test "x$enable_quota" != xno -a "x$enable_utils" != xno], [
2966         AC_CHECK_HEADER([sys/quota.h],
2967                 [AC_DEFINE(HAVE_SYS_QUOTA_H, 1,
2968                         [Define to 1 if you have <sys/quota.h>.])],
2969                 [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
2970 ])
2971 ]) # LC_QUOTA
2972
2973 #
2974 # LC_CONFIG_NODEMAP_PROC_DEBUG
2975 #
2976 # enable nodemap proc file debugging
2977 #
2978 AC_DEFUN([LC_NODEMAP_PROC_DEBUG], [
2979 AC_MSG_CHECKING([whether to enable nodemap proc debug])
2980 AC_ARG_ENABLE([nodemap_proc_debug],
2981         AC_HELP_STRING([--enable-nodemap-proc-debug],
2982                 [enable nodemap proc debug]),
2983         [], [enable_nodemap_proc_debug="no"])
2984 AC_MSG_RESULT([$enable_nodemap_proc_debug])
2985 AS_IF([test "x$enable_nodemap_proc_debug" != xno],
2986         [AC_DEFINE(NODEMAP_PROC_DEBUG, 1,
2987                 [enable nodemap proc debug support])])
2988 ]) # LC_NODEMAP_PROC_DEBUG
2989
2990 #
2991 # LC_OSD_ADDON
2992 #
2993 # configure support for optional OSD implementation
2994 #
2995 AC_DEFUN([LC_OSD_ADDON], [
2996 AC_MSG_CHECKING([whether to use OSD addon])
2997 AC_ARG_WITH([osd],
2998         AC_HELP_STRING([--with-osd=path],
2999                 [set path to optional osd]),
3000         [
3001         case "$with_osd" in
3002         no)
3003                 ENABLEOSDADDON=0
3004                 ;;
3005         *)
3006                 OSDADDON="$with_osd"
3007                 ENABLEOSDADDON=1
3008                 ;;
3009         esac
3010         ], [
3011                 ENABLEOSDADDON=0
3012         ])
3013 AS_IF([test $ENABLEOSDADDON -eq 0], [
3014         AC_MSG_RESULT([no])
3015         OSDADDON=""
3016 ], [
3017         OSDMODNAME=$(basename $OSDADDON)
3018         AS_IF([test -e $LUSTRE/$OSDMODNAME], [
3019                 AC_MSG_RESULT([can't link])
3020                 OSDADDON=""
3021         ], [ln -s $OSDADDON $LUSTRE/$OSDMODNAME], [
3022                 AC_MSG_RESULT([$OSDMODNAME])
3023                 OSDADDON="subdir-m += $OSDMODNAME"
3024         ], [
3025                 AC_MSG_RESULT([can't link])
3026                 OSDADDON=""
3027         ])
3028 ])
3029 AC_SUBST(OSDADDON)
3030 ]) # LC_OSD_ADDON
3031
3032 #
3033 # LC_CONFIGURE
3034 #
3035 # other configure checks
3036 #
3037 AC_DEFUN([LC_CONFIGURE], [
3038 AC_MSG_NOTICE([Lustre core checks
3039 ==============================================================================])
3040
3041 AS_IF([test $target_cpu == "i686" -o $target_cpu == "x86_64"],
3042         [CFLAGS="$CFLAGS -Wall -Werror"])
3043
3044 # maximum MDS thread count
3045 LC_MDS_MAX_THREADS
3046
3047 # lustre/utils/gss/gss_util.c
3048 # lustre/utils/gss/gssd_proc.c
3049 # lustre/utils/gss/krb5_util.c
3050 # lustre/utils/llog_reader.c
3051 # lustre/utils/create_iam.c
3052 # lustre/utils/libiam.c
3053 AC_CHECK_HEADERS([netdb.h endian.h])
3054 AC_CHECK_FUNCS([gethostbyname])
3055
3056 # lustre/utils/llverdev.c
3057 AC_CHECK_HEADERS([blkid/blkid.h])
3058
3059 # lustre/utils/llverfs.c
3060 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
3061
3062 SELINUX=""
3063 AC_CHECK_LIB([selinux], [is_selinux_enabled],
3064         [AC_CHECK_HEADERS([selinux/selinux.h],
3065                         [SELINUX="-lselinux"
3066                         AC_DEFINE([HAVE_SELINUX], 1,
3067                                 [support for selinux ])],
3068                         [AC_MSG_WARN([
3069
3070 No libselinux-devel package found, unable to build selinux enabled tools
3071 ])
3072 ])],
3073         [AC_MSG_WARN([
3074
3075 No selinux package found, unable to build selinux enabled tools
3076 ])
3077 ])
3078 AC_SUBST(SELINUX)
3079
3080 # Super safe df
3081 AC_MSG_CHECKING([whether to report minimum OST free space])
3082 AC_ARG_ENABLE([mindf],
3083         AC_HELP_STRING([--enable-mindf],
3084                 [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
3085         [], [enable_mindf="no"])
3086 AC_MSG_RESULT([$enable_mindf])
3087 AS_IF([test "$enable_mindf" = "yes"],
3088         [AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])])
3089
3090 AC_MSG_CHECKING([whether to randomly failing memory alloc])
3091 AC_ARG_ENABLE([fail_alloc],
3092         AC_HELP_STRING([--disable-fail-alloc],
3093                 [disable randomly alloc failure]),
3094         [], [enable_fail_alloc="yes"])
3095 AC_MSG_RESULT([$enable_fail_alloc])
3096 AS_IF([test "x$enable_fail_alloc" != xno],
3097         [AC_DEFINE([RANDOM_FAIL_ALLOC], 1,
3098                 [enable randomly alloc failure])])
3099
3100 AC_MSG_CHECKING([whether to check invariants (expensive cpu-wise)])
3101 AC_ARG_ENABLE([invariants],
3102         AC_HELP_STRING([--enable-invariants],
3103                 [enable invariant checking (cpu intensive)]),
3104         [], [enable_invariants="no"])
3105 AC_MSG_RESULT([$enable_invariants])
3106 AS_IF([test "x$enable_invariants" = xyes],
3107         [AC_DEFINE([CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK], 1,
3108                 [enable invariant checking])])
3109
3110 AC_MSG_CHECKING([whether to track references with lu_ref])
3111 AC_ARG_ENABLE([lu_ref],
3112         AC_HELP_STRING([--enable-lu_ref],
3113                 [enable lu_ref reference tracking code]),
3114         [], [enable_lu_ref="no"])
3115 AC_MSG_RESULT([$enable_lu_ref])
3116 AS_IF([test "x$enable_lu_ref" = xyes],
3117         [AC_DEFINE([USE_LU_REF], 1,
3118                 [enable lu_ref reference tracking code])])
3119
3120 AC_MSG_CHECKING([whether to enable page state tracking])
3121 AC_ARG_ENABLE([pgstate-track],
3122         AC_HELP_STRING([--enable-pgstate-track],
3123                 [enable page state tracking]),
3124         [], [enable_pgstat_track="no"])
3125 AC_MSG_RESULT([$enable_pgstat_track])
3126 AS_IF([test "x$enable_pgstat_track" = xyes],
3127         [AC_DEFINE([CONFIG_DEBUG_PAGESTATE_TRACKING], 1,
3128                 [enable page state tracking code])])
3129
3130 PKG_PROG_PKG_CONFIG
3131 AC_MSG_CHECKING([systemd unit file directory])
3132 AC_ARG_WITH([systemdsystemunitdir],
3133         [AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
3134                 [Directory for systemd service files])],
3135         [], [with_systemdsystemunitdir=auto])
3136 AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"],
3137         [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
3138         AS_IF([test "x$def_systemdsystemunitdir" = "x"],
3139                 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
3140                 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
3141                 with_systemdsystemunitdir=no],
3142         [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
3143 AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
3144         [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
3145 AC_MSG_RESULT([$with_systemdsystemunitdir])
3146 ]) # LC_CONFIGURE
3147
3148 #
3149 # LC_CONDITIONALS
3150 #
3151 # AM_CONDITIONALS for lustre
3152 #
3153 AC_DEFUN([LC_CONDITIONALS], [
3154 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
3155 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
3156 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
3157 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
3158 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
3159 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
3160 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
3161 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
3162 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
3163 AM_CONDITIONAL(GSS_SSK, test x$enable_ssk = xyes)
3164 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
3165 AM_CONDITIONAL(HAVE_SYSTEMD, test "x$with_systemdsystemunitdir" != "xno")
3166 AM_CONDITIONAL(XATTR_HANDLER, test "x$lb_cv_compile_xattr_handler_flags" = xyes)
3167 ]) # LC_CONDITIONALS
3168
3169 #
3170 # LC_CONFIG_FILES
3171 #
3172 # files that should be generated with AC_OUTPUT
3173 #
3174 AC_DEFUN([LC_CONFIG_FILES],
3175 [AC_CONFIG_FILES([
3176 lustre/Makefile
3177 lustre/autoMakefile
3178 lustre/autoconf/Makefile
3179 lustre/conf/Makefile
3180 lustre/contrib/Makefile
3181 lustre/doc/Makefile
3182 lustre/include/Makefile
3183 lustre/include/lustre/Makefile
3184 lustre/include/uapi/linux/lustre/Makefile
3185 lustre/kernel_patches/targets/3.10-rhel7.target
3186 lustre/kernel_patches/targets/2.6-rhel6.9.target
3187 lustre/kernel_patches/targets/2.6-rhel6.8.target
3188 lustre/kernel_patches/targets/2.6-rhel6.7.target
3189 lustre/kernel_patches/targets/2.6-rhel6.6.target
3190 lustre/kernel_patches/targets/2.6-rhel6.target
3191 lustre/kernel_patches/targets/2.6-rhel5.target
3192 lustre/kernel_patches/targets/2.6-sles11.target
3193 lustre/kernel_patches/targets/3.0-sles11.target
3194 lustre/kernel_patches/targets/3.0-sles11sp3.target
3195 lustre/kernel_patches/targets/3.0-sles11sp4.target
3196 lustre/kernel_patches/targets/3.12-sles12.target
3197 lustre/kernel_patches/targets/4.4-sles12.target
3198 lustre/kernel_patches/targets/4.4-sles12sp3.target
3199 lustre/kernel_patches/targets/2.6-fc11.target
3200 lustre/kernel_patches/targets/2.6-fc12.target
3201 lustre/kernel_patches/targets/2.6-fc15.target
3202 lustre/kernel_patches/targets/3.x-fc18.target
3203 lustre/ldlm/Makefile
3204 lustre/fid/Makefile
3205 lustre/fid/autoMakefile
3206 lustre/llite/Makefile
3207 lustre/llite/autoMakefile
3208 lustre/lov/Makefile
3209 lustre/lov/autoMakefile
3210 lustre/mdc/Makefile
3211 lustre/mdc/autoMakefile
3212 lustre/lmv/Makefile
3213 lustre/lmv/autoMakefile
3214 lustre/lfsck/Makefile
3215 lustre/lfsck/autoMakefile
3216 lustre/mdt/Makefile
3217 lustre/mdt/autoMakefile
3218 lustre/mdd/Makefile
3219 lustre/mdd/autoMakefile
3220 lustre/fld/Makefile
3221 lustre/fld/autoMakefile
3222 lustre/obdclass/Makefile
3223 lustre/obdclass/autoMakefile
3224 lustre/obdclass/linux/Makefile
3225 lustre/obdecho/Makefile
3226 lustre/obdecho/autoMakefile
3227 lustre/ofd/Makefile
3228 lustre/ofd/autoMakefile
3229 lustre/osc/Makefile
3230 lustre/osc/autoMakefile
3231 lustre/ost/Makefile
3232 lustre/ost/autoMakefile
3233 lustre/osd-ldiskfs/Makefile
3234 lustre/osd-ldiskfs/autoMakefile
3235 lustre/osd-zfs/Makefile
3236 lustre/osd-zfs/autoMakefile
3237 lustre/mgc/Makefile
3238 lustre/mgc/autoMakefile
3239 lustre/mgs/Makefile
3240 lustre/mgs/autoMakefile
3241 lustre/target/Makefile
3242 lustre/ptlrpc/Makefile
3243 lustre/ptlrpc/autoMakefile
3244 lustre/ptlrpc/gss/Makefile
3245 lustre/ptlrpc/gss/autoMakefile
3246 lustre/quota/Makefile
3247 lustre/quota/autoMakefile
3248 lustre/scripts/Makefile
3249 lustre/scripts/systemd/Makefile
3250 lustre/tests/Makefile
3251 lustre/tests/mpi/Makefile
3252 lustre/tests/kernel/Makefile
3253 lustre/tests/kernel/autoMakefile
3254 lustre/utils/Makefile
3255 lustre/utils/gss/Makefile
3256 lustre/osp/Makefile
3257 lustre/osp/autoMakefile
3258 lustre/lod/Makefile
3259 lustre/lod/autoMakefile
3260 ])
3261 ]) # LC_CONFIG_FILES