Whamcloud - gitweb
LU-9859 libcfs: handle missing refcount.h
[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 ldiskfs_is_ext4="yes"
9 ])
10
11 #
12 # LC_PATH_DEFAULTS
13 #
14 # lustre specific paths
15 #
16 AC_DEFUN([LC_PATH_DEFAULTS], [
17 # ptlrpc kernel build requires this
18 LUSTRE="$PWD/lustre"
19 AC_SUBST(LUSTRE)
20
21 # mount.lustre
22 rootsbindir='/sbin'
23 AC_SUBST(rootsbindir)
24
25 demodir='$(docdir)/demo'
26 AC_SUBST(demodir)
27
28 pkgexampledir='${pkgdatadir}/examples'
29 AC_SUBST(pkgexampledir)
30 ]) # LC_PATH_DEFAULTS
31
32 #
33 # LC_TARGET_SUPPORTED
34 #
35 # is the target os supported?
36 #
37 AC_DEFUN([LC_TARGET_SUPPORTED], [
38 case $target_os in
39         linux*)
40 $1
41                 ;;
42         *)
43 $2
44                 ;;
45 esac
46 ]) # LC_TARGET_SUPPORTED
47
48 #
49 # LC_GLIBC_SUPPORT_FHANDLES
50 #
51 AC_DEFUN([LC_GLIBC_SUPPORT_FHANDLES], [
52 AC_CHECK_FUNCS([name_to_handle_at],
53         [AC_DEFINE(HAVE_FHANDLE_GLIBC_SUPPORT, 1,
54                 [file handle and related syscalls are supported])],
55         [AC_MSG_WARN([file handle and related syscalls are not supported])])
56 ]) # LC_GLIBC_SUPPORT_FHANDLES
57
58 #
59 # LC_STACK_SIZE
60 #
61 # Ensure the stack size is at least 8k in Lustre server (all kernels)
62 #
63 AC_DEFUN([LC_STACK_SIZE], [
64 LB_CHECK_COMPILE([if stack size is at least 8k],
65 stack_size_8k, [
66         #include <linux/thread_info.h>
67 ], [
68         #if THREAD_SIZE < 8192
69         #error "stack size < 8192"
70         #endif
71 ], [], [AC_MSG_ERROR([
72
73 Lustre requires that Linux is configured with at least a 8KB stack.
74 ])])
75 ]) # LC_STACK_SIZE
76
77 #
78 # LC_MDS_MAX_THREADS
79 #
80 # Allow the user to set the MDS thread upper limit
81 #
82 AC_DEFUN([LC_MDS_MAX_THREADS], [
83 AC_MSG_CHECKING([for maximum number of MDS threads])
84 AC_ARG_WITH([mds_max_threads],
85         AC_HELP_STRING([--with-mds-max-threads=count],
86                 [maximum threads available on the MDS: (default=512)]),
87         [AC_DEFINE_UNQUOTED(MDS_MAX_THREADS, $with_mds_max_threads,
88                 [maximum number of MDS threads])])
89 AC_MSG_RESULT([$with_mds_max_threads])
90 ]) # LC_MDS_MAX_THREADS
91
92 #
93 # LC_CONFIG_PINGER
94 #
95 # the pinger is temporary, until we have the recovery node in place
96 #
97 AC_DEFUN([LC_CONFIG_PINGER], [
98 AC_MSG_CHECKING([whether to enable Lustre pinger support])
99 AC_ARG_ENABLE([pinger],
100         AC_HELP_STRING([--disable-pinger],
101                 [disable recovery pinger support]),
102         [], [enable_pinger="yes"])
103 AC_MSG_RESULT([$enable_pinger])
104 AS_IF([test "x$enable_pinger" != xno],
105         [AC_DEFINE(CONFIG_LUSTRE_PINGER, 1,[Use the Pinger])])
106 ]) # LC_CONFIG_PINGER
107
108 #
109 # LC_CONFIG_CHECKSUM
110 #
111 # do checksum of bulk data between client and OST
112 #
113 AC_DEFUN([LC_CONFIG_CHECKSUM], [
114 AC_MSG_CHECKING([whether to enable data checksum support])
115 AC_ARG_ENABLE([checksum],
116         AC_HELP_STRING([--disable-checksum],
117                 [disable data checksum support]),
118         [], [enable_checksum="yes"])
119 AC_MSG_RESULT([$enable_checksum])
120 AS_IF([test "x$enable_checksum" != xno],
121         [AC_DEFINE(ENABLE_CHECKSUM, 1, [do data checksums])])
122 ]) # LC_CONFIG_CHECKSUM
123
124 #
125 # LC_CONFIG_FLOCK
126 #
127 # enable distributed flock by default
128 #
129 AC_DEFUN([LC_CONFIG_FLOCK], [
130 AC_MSG_CHECKING([whether to enable flock by default])
131 AC_ARG_ENABLE([flock],
132         AC_HELP_STRING([--disable-flock],
133                 [disable flock by default]),
134         [], [enable_flock="yes"])
135 AC_MSG_RESULT([$enable_flock])
136 AS_IF([test "x$enable_flock" != xno],
137         [AC_DEFINE(ENABLE_FLOCK, 1, [enable flock by default])])
138 ]) # LC_CONFIG_FLOCK
139
140 #
141 # LC_CONFIG_HEALTH_CHECK_WRITE
142 #
143 # Turn off the actual write to the disk
144 #
145 AC_DEFUN([LC_CONFIG_HEALTH_CHECK_WRITE], [
146 AC_MSG_CHECKING([whether to enable a write with the health check])
147 AC_ARG_ENABLE([health_write],
148         AC_HELP_STRING([--enable-health_write],
149                 [enable disk writes when doing health check]),
150         [], [enable_health_write="no"])
151 AC_MSG_RESULT([$enable_health_write])
152 AS_IF([test "x$enable_health_write" != xno],
153         [AC_DEFINE(USE_HEALTH_CHECK_WRITE, 1, [Write when Checking Health])])
154 ]) # LC_CONFIG_HEALTH_CHECK_WRITE
155
156 #
157 # LC_CONFIG_LRU_RESIZE
158 #
159 AC_DEFUN([LC_CONFIG_LRU_RESIZE], [
160 AC_MSG_CHECKING([whether to enable lru self-adjusting])
161 AC_ARG_ENABLE([lru_resize],
162         AC_HELP_STRING([--enable-lru-resize],
163                 [enable lru resize support]),
164         [], [enable_lru_resize="yes"])
165 AC_MSG_RESULT([$enable_lru_resize])
166 AS_IF([test "x$enable_lru_resize" != xno],
167         [AC_DEFINE(HAVE_LRU_RESIZE_SUPPORT, 1, [Enable lru resize support])])
168 ]) # LC_CONFIG_LRU_RESIZE
169
170 #
171 # LC_QUOTA_CONFIG
172 #
173 # Quota support. The kernel must support CONFIG_QUOTA.
174 #
175 AC_DEFUN([LC_QUOTA_CONFIG], [
176 LB_CHECK_CONFIG_IM([QUOTA], [],
177         [AC_MSG_ERROR([
178
179 Lustre quota requires that CONFIG_QUOTA is enabled in your kernel.
180 ])])
181 ]) # LC_QUOTA_CONFIG
182
183 #
184 # LC_CONFIG_FHANDLE
185 #
186 # fhandle kernel support for open_by_handle_at() and name_to_handle_at()
187 # system calls. The kernel must support CONFIG_FHANDLE.
188 #
189 AC_DEFUN([LC_CONFIG_FHANDLE], [
190 LB_CHECK_CONFIG_IM([FHANDLE], [],
191         [AC_MSG_ERROR([
192
193 Lustre fid handling requires that CONFIG_FHANDLE is enabled in your kernel.
194 ])])
195 ]) # LC_CONFIG_FHANDLE
196
197 #
198 # LC_POSIX_ACL_CONFIG
199 #
200 # POSIX ACL support.
201 #
202 AC_DEFUN([LC_POSIX_ACL_CONFIG], [
203 LB_CHECK_CONFIG_IM([FS_POSIX_ACL],
204         [AC_DEFINE(CONFIG_LUSTRE_FS_POSIX_ACL, 1, [Enable POSIX acl])
205 ], [ ])
206 ]) # LC_POSIX_ACL_CONFIG
207
208 LB_CHECK_CONFIG_IM([CRYPTO_MD5], [],
209                 [AC_MSG_WARN([kernel MD5 support is recommended by using GSS.])])
210
211 #
212 # LC_CONFIG_GSS_KEYRING
213 #
214 # default 'auto', tests for dependencies, if found, enables;
215 # only called if gss is enabled
216 #
217 AC_DEFUN([LC_CONFIG_GSS_KEYRING], [
218 AC_MSG_CHECKING([whether to enable gss keyring backend])
219 AC_ARG_ENABLE([gss_keyring],
220         [AC_HELP_STRING([--disable-gss-keyring],
221                 [disable gss keyring backend])],
222         [], [enable_gss_keyring="auto"])
223 AC_MSG_RESULT([$enable_gss_keyring])
224 AS_IF([test "x$enable_gss_keyring" != xno], [
225         LB_CHECK_CONFIG_IM([KEYS], [], [
226                 gss_keyring_conf_test="fail"
227                 AC_MSG_WARN([GSS keyring backend requires that CONFIG_KEYS be enabled in your kernel.])])
228
229         AC_CHECK_LIB([keyutils], [keyctl_search], [], [
230                 gss_keyring_conf_test="fail"
231                 AC_MSG_WARN([GSS keyring backend requires libkeyutils])])
232
233         AS_IF([test "x$gss_keyring_conf_test" != xfail], [
234                 AC_DEFINE([HAVE_GSS_KEYRING], [1],
235                         [Define this if you enable gss keyring backend])
236                 enable_gss_keyring="yes"
237         ], [
238                 AS_IF([test "x$enable_gss_keyring" = xyes], [
239                         AC_MSG_ERROR([Cannot enable gss_keyring. See above for details.])
240                 ])
241         ])
242 ])
243 ]) # LC_CONFIG_GSS_KEYRING
244
245 #
246 # LC_KEY_TYPE_INSTANTIATE_2ARGS
247 #
248 # rhel7 key_type->instantiate takes 2 args (struct key, struct key_preparsed_payload)
249 #
250 AC_DEFUN([LC_KEY_TYPE_INSTANTIATE_2ARGS], [
251 LB_CHECK_COMPILE([if 'key_type->instantiate' has two args],
252 key_type_instantiate_2args, [
253         #include <linux/key-type.h>
254 ],[
255         ((struct key_type *)0)->instantiate(0, NULL);
256 ],[
257         AC_DEFINE(HAVE_KEY_TYPE_INSTANTIATE_2ARGS, 1,
258                 [key_type->instantiate has two args])
259 ])
260 ]) # LC_KEY_TYPE_INSTANTIATE_2ARGS
261
262 #
263 # LC_CONFIG_SUNRPC
264 #
265 AC_DEFUN([LC_CONFIG_SUNRPC], [
266 LB_CHECK_CONFIG_IM([SUNRPC], [], [
267         AS_IF([test "x$sunrpc_required" = xyes], [
268                 AC_MSG_ERROR([
269
270 kernel SUNRPC support is required by using GSS.
271 ])
272         ])])
273 ]) # LC_CONFIG_SUNRPC
274
275 #
276 # LC_CONFIG_GSS (default 'auto' (tests for dependencies, if found, enables))
277 #
278 # Build gss and related tools of Lustre. Currently both kernel and user space
279 # parts are depend on linux platform.
280 #
281 AC_DEFUN([LC_CONFIG_GSS], [
282 AC_MSG_CHECKING([whether to enable gss support])
283 AC_ARG_ENABLE([gss],
284         [AC_HELP_STRING([--enable-gss], [enable gss support])],
285         [], [enable_gss="auto"])
286 AC_MSG_RESULT([$enable_gss])
287
288 AS_IF([test "x$enable_gss" != xno], [
289         LC_CONFIG_GSS_KEYRING
290         LC_KEY_TYPE_INSTANTIATE_2ARGS
291         sunrpc_required=$enable_gss
292         LC_CONFIG_SUNRPC
293         sunrpc_required="no"
294
295         LB_CHECK_CONFIG_IM([CRYPTO_MD5], [],
296                 [AC_MSG_WARN([kernel MD5 support is recommended by using GSS.])])
297         LB_CHECK_CONFIG_IM([CRYPTO_SHA1], [],
298                 [AC_MSG_WARN([kernel SHA1 support is recommended by using GSS.])])
299         LB_CHECK_CONFIG_IM([CRYPTO_SHA256], [],
300                 [AC_MSG_WARN([kernel SHA256 support is recommended by using GSS.])])
301         LB_CHECK_CONFIG_IM([CRYPTO_SHA512], [],
302                 [AC_MSG_WARN([kernel SHA512 support is recommended by using GSS.])])
303
304         require_krb5=$enable_gss
305         AC_KERBEROS_V5
306         require_krb5="no"
307
308         AS_IF([test -n "$KRBDIR"], [
309                 gss_conf_test="success"
310         ], [
311                 gss_conf_test="failure"
312         ])
313
314         AS_IF([test "x$gss_conf_test" = xsuccess && test "x$enable_gss" != xno], [
315                 AC_DEFINE([HAVE_GSS], [1], [Define this is if you enable gss])
316                 enable_gss="yes"
317         ], [
318                 enable_gss_keyring="no"
319                 enable_gss="no"
320         ])
321
322         enable_ssk=$enable_gss
323 ], [
324         enable_gss_keyring="no"
325 ])
326 ]) # LC_CONFIG_GSS
327
328 # LC_OPENSSL_SSK
329 #
330 # OpenSSL 1.0+ return int for HMAC functions but older SLES11 versions do not
331 AC_DEFUN([LC_OPENSSL_SSK], [
332 AC_MSG_CHECKING([whether OpenSSL has functions needed for SSK])
333 AS_IF([test "x$enable_ssk" != xno], [
334 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
335         #include <openssl/hmac.h>
336         #include <openssl/evp.h>
337
338         int main(void) {
339                 int rc;
340                 rc = HMAC_Init_ex(NULL, "test", 4, EVP_md_null(), NULL);
341         }
342 ])],[AC_DEFINE(HAVE_OPENSSL_SSK, 1,
343                [OpenSSL HMAC functions needed for SSK])],
344         [enable_ssk="no"])
345 ])
346 AC_MSG_RESULT([$enable_ssk])
347 ]) # LC_OPENSSL_SSK
348
349 # LC_OPENSSL_GETSEPOL
350 #
351 # OpenSSL is needed for l_getsepol
352 AC_DEFUN([LC_OPENSSL_GETSEPOL], [
353 AC_MSG_CHECKING([whether openssl-devel is present])
354 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
355         #include <openssl/evp.h>
356
357         int main(void) {
358                 EVP_MD_CTX *mdctx = EVP_MD_CTX_create();
359         }
360 ])],[
361         AC_DEFINE(HAVE_OPENSSL_GETSEPOL, 1, [openssl-devel is present])
362         enable_getsepol="yes"
363
364 ],[
365         enable_getsepol="no"
366         AC_MSG_WARN([
367
368 No openssk-devel headers found, unable to build l_getsepol and SELinux status checking
369 ])
370 ])
371 AC_MSG_RESULT([$enable_getsepol])
372 ]) # LC_OPENSSL_GETSEPOL
373
374 AC_DEFUN([LC_HAVE_PROJECT_QUOTA], [
375 LB_CHECK_COMPILE([if get_projid exists],
376 get_projid, [
377         struct inode;
378         #include <linux/quota.h>
379 ],[
380         struct dquot_operations ops = { };
381
382         ops.get_projid(NULL, NULL);
383 ],[
384         AC_DEFINE(HAVE_PROJECT_QUOTA, 1,
385                 [get_projid function exists])
386 ])
387 ]) # LC_HAVE_PROJECT_QUOTA
388
389 #
390 # LC_INVALIDATE_RANGE
391 #
392 # 3.11 invalidatepage requires the length of the range to invalidate
393 #
394 AC_DEFUN([LC_INVALIDATE_RANGE], [
395 LB_CHECK_COMPILE([if 'address_space_operations.invalidatepage' requires 3 arguments],
396 address_space_ops_invalidatepage_3args, [
397         #include <linux/fs.h>
398 ],[
399         struct address_space_operations a_ops;
400         a_ops.invalidatepage(NULL, 0, 0);
401 ],[
402         AC_DEFINE(HAVE_INVALIDATE_RANGE, 1,
403                 [address_space_operations.invalidatepage needs 3 arguments])
404 ])
405 ]) # LC_INVALIDATE_RANGE
406
407 #
408 # LC_HAVE_DIR_CONTEXT
409 #
410 # 3.11 readdir now takes the new struct dir_context
411 #
412 AC_DEFUN([LC_HAVE_DIR_CONTEXT], [
413 LB_CHECK_COMPILE([if 'dir_context' exist],
414 dir_context, [
415         #include <linux/fs.h>
416 ],[
417 #ifdef FMODE_KABI_ITERATE
418 #error "back to use readdir in kabi_extand mode"
419 #else
420         struct dir_context ctx;
421
422         ctx.pos = 0;
423 #endif
424 ],[
425         AC_DEFINE(HAVE_DIR_CONTEXT, 1,
426                 [dir_context exist])
427 ])
428 ]) # LC_HAVE_DIR_CONTEXT
429
430 #
431 # LC_HAVE_DCOUNT
432 #
433 # 3.11 need to access d_count to get dentry reference count
434 #
435 AC_DEFUN([LC_HAVE_DCOUNT], [
436 LB_CHECK_COMPILE([if 'd_count' exists],
437 d_count, [
438         #include <linux/dcache.h>
439 ],[
440         struct dentry de = { };
441         int count;
442
443         count = d_count(&de);
444 ],[
445         AC_DEFINE(HAVE_D_COUNT, 1,
446                 [d_count exist])
447 ])
448 ]) # LC_HAVE_DCOUNT
449
450 #
451 # LC_PID_NS_FOR_CHILDREN
452 #
453 # 3.11 replaces pid_ns by pid_ns_for_children in struct nsproxy
454 #
455 AC_DEFUN([LC_PID_NS_FOR_CHILDREN], [
456 LB_CHECK_COMPILE([if 'struct nsproxy' has 'pid_ns_for_children'],
457 pid_ns_for_children, [
458         #include <linux/nsproxy.h>
459 ],[
460         struct nsproxy ns;
461         ns.pid_ns_for_children = NULL;
462 ],[
463         AC_DEFINE(HAVE_PID_NS_FOR_CHILDREN, 1,
464                   ['struct nsproxy' has 'pid_ns_for_children'])
465 ])
466 ]) # LC_PID_NS_FOR_CHILDREN
467
468 #
469 # LC_OLDSIZE_TRUNCATE_PAGECACHE
470 #
471 # 3.12 truncate_pagecache without oldsize parameter
472 #
473 AC_DEFUN([LC_OLDSIZE_TRUNCATE_PAGECACHE], [
474 LB_CHECK_COMPILE([if 'truncate_pagecache' with 'old_size' parameter],
475 truncate_pagecache_old_size, [
476         #include <linux/mm.h>
477 ],[
478         truncate_pagecache(NULL, 0, 0);
479 ],[
480         AC_DEFINE(HAVE_OLDSIZE_TRUNCATE_PAGECACHE, 1,
481                 [with oldsize])
482 ])
483 ]) # LC_OLDSIZE_TRUNCATE_PAGECACHE
484
485 #
486 # LC_PTR_ERR_OR_ZERO
487 #
488 # For some reason SLES11SP4 is missing the PTR_ERR_OR_ZERO macro
489 # It was added to linux kernel 3.12
490 #
491 AC_DEFUN([LC_PTR_ERR_OR_ZERO_MISSING], [
492 LB_CHECK_COMPILE([if 'PTR_ERR_OR_ZERO' is missing],
493 is_err_or_null, [
494         #include <linux/err.h>
495 ],[
496         if (PTR_ERR_OR_ZERO(NULL)) return 0;
497 ],[
498         AC_DEFINE(HAVE_PTR_ERR_OR_ZERO, 1,
499                 ['PTR_ERR_OR_ZERO' exist])
500 ])
501 ]) # LC_PTR_ERR_OR_ZERO_MISSING
502
503 #
504 # LC_HAVE_DENTRY_D_U_D_ALIAS
505 #
506 # 3.11 kernel moved d_alias to the union d_u in struct dentry
507 #
508 # Some distros move d_alias to d_u but it is still a struct list
509 #
510 AC_DEFUN([LC_HAVE_DENTRY_D_U_D_ALIAS], [
511 AS_IF([test "x$lb_cv_compile_i_dentry_d_alias_list" = xyes], [
512         LB_CHECK_COMPILE([if list 'dentry.d_u.d_alias' exist],
513         d_alias, [
514                 #include <linux/list.h>
515                 #include <linux/dcache.h>
516         ],[
517                 struct dentry de;
518                 INIT_LIST_HEAD(&de.d_u.d_alias);
519         ],[
520                 AC_DEFINE(HAVE_DENTRY_D_U_D_ALIAS, 1,
521                         [list dentry.d_u.d_alias exist])
522         ])
523 ],[
524         LB_CHECK_COMPILE([if hlist 'dentry.d_u.d_alias' exist],
525         d_alias, [
526                 #include <linux/list.h>
527                 #include <linux/dcache.h>
528         ],[
529                 struct dentry de;
530                 INIT_HLIST_NODE(&de.d_u.d_alias);
531         ],[
532                 AC_DEFINE(HAVE_DENTRY_D_U_D_ALIAS, 1,
533                         [hlist dentry.d_u.d_alias exist])
534         ])
535 ])
536 ]) # LC_HAVE_DENTRY_D_U_D_ALIAS
537
538 #
539 # LC_HAVE_DENTRY_D_CHILD
540 #
541 # 3.11 kernel d_child has been moved out of the union d_u
542 # in struct dentry
543 #
544 AC_DEFUN([LC_HAVE_DENTRY_D_CHILD], [
545 LB_CHECK_COMPILE([if 'dentry.d_child' exist],
546 d_child, [
547         #include <linux/list.h>
548         #include <linux/dcache.h>
549 ],[
550         struct dentry de;
551         INIT_LIST_HEAD(&de.d_child);
552 ],[
553         AC_DEFINE(HAVE_DENTRY_D_CHILD, 1,
554                 [dentry.d_child exist])
555 ])
556 ]) # LC_HAVE_DENTRY_D_CHILD
557
558 #
559 # LC_KIOCB_KI_LEFT
560 #
561 # 3.12 ki_left removed from struct kiocb
562 #
563 AC_DEFUN([LC_KIOCB_KI_LEFT], [
564 LB_CHECK_COMPILE([if 'struct kiocb' with 'ki_left' member],
565 kiocb_ki_left, [
566         #include <linux/aio.h>
567 ],[
568         ((struct kiocb*)0)->ki_left = 0;
569 ],[
570         AC_DEFINE(HAVE_KIOCB_KI_LEFT, 1,
571                 [ki_left exist])
572 ])
573 ]) # LC_KIOCB_KI_LEFT
574
575 #
576 # LC_VFS_RENAME_5ARGS
577 #
578 # 3.13 has vfs_rename with 5 args
579 #
580 AC_DEFUN([LC_VFS_RENAME_5ARGS], [
581 LB_CHECK_COMPILE([if Linux kernel has 'vfs_rename' with 5 args],
582 vfs_rename_5args, [
583         #include <linux/fs.h>
584 ],[
585         vfs_rename(NULL, NULL, NULL, NULL, NULL);
586 ], [
587         AC_DEFINE(HAVE_VFS_RENAME_5ARGS, 1,
588                 [kernel has vfs_rename with 5 args])
589 ])
590 ]) # LC_VFS_RENAME_5ARGS
591
592 #
593 # LC_VFS_UNLINK_3ARGS
594 #
595 # 3.13 has vfs_unlink with 3 args
596 #
597 AC_DEFUN([LC_VFS_UNLINK_3ARGS], [
598 LB_CHECK_COMPILE([if Linux kernel has 'vfs_unlink' with 3 args],
599 vfs_unlink_3args, [
600         #include <linux/fs.h>
601 ],[
602         vfs_unlink(NULL, NULL, NULL);
603 ], [
604         AC_DEFINE(HAVE_VFS_UNLINK_3ARGS, 1,
605                 [kernel has vfs_unlink with 3 args])
606 ])
607 ]) # LC_VFS_UNLINK_3ARGS
608
609 # LC_HAVE_D_IS_POSITIVE
610 #
611 # Kernel version 3.13 b18825a7c8e37a7cf6abb97a12a6ad71af160de7
612 # d_is_positive is added
613 #
614 AC_DEFUN([LC_HAVE_D_IS_POSITIVE], [
615 LB_CHECK_COMPILE([if 'd_is_positive' exist],
616 d_is_positive, [
617         #include <linux/dcache.h>
618 ],[
619         d_is_positive(NULL);
620 ],[
621         AC_DEFINE(HAVE_D_IS_POSITIVE, 1,
622                 ['d_is_positive' is available])
623 ])
624 ]) # LC_HAVE_D_IS_POSITIVE
625
626 #
627 # LC_HAVE_BVEC_ITER
628 #
629 # 3.14 move some of its data in struct bio into the new
630 # struct bvec_iter
631 #
632 AC_DEFUN([LC_HAVE_BVEC_ITER], [
633 LB_CHECK_COMPILE([if Linux kernel has struct bvec_iter],
634 have_bvec_iter, [
635         #include <linux/bio.h>
636 ],[
637         struct bvec_iter iter;
638
639         iter.bi_bvec_done = 0;
640 ], [
641         AC_DEFINE(HAVE_BVEC_ITER, 1,
642                 [kernel has struct bvec_iter])
643 ])
644 ]) # LC_HAVE_BVEC_ITER
645
646 #
647 # LC_IOP_SET_ACL
648 #
649 # 3.14 adds set_acl method to inode_operations
650 # see kernel commit 893d46e443346370cd4ea81d9d35f72952c62a37
651 #
652 AC_DEFUN([LC_IOP_SET_ACL], [
653 LB_CHECK_COMPILE([if 'inode_operations' has '.set_acl' member function],
654 inode_ops_set_acl, [
655         #include <linux/fs.h>
656 ],[
657         struct inode_operations iop;
658         iop.set_acl = NULL;
659 ],[
660         AC_DEFINE(HAVE_IOP_SET_ACL, 1,
661                 [inode_operations has .set_acl member function])
662 ])
663 ]) # LC_IOP_SET_ACL
664
665 #
666 # LC_HAVE_TRUNCATE_IPAGE_FINAL
667 #
668 # 3.14 bring truncate_inode_pages_final for evict_inode
669 #
670 AC_DEFUN([LC_HAVE_TRUNCATE_IPAGES_FINAL], [
671 LB_CHECK_COMPILE([if Linux kernel has truncate_inode_pages_final],
672 truncate_ipages_final, [
673         #include <linux/mm.h>
674 ],[
675         truncate_inode_pages_final(NULL);
676 ], [
677         AC_DEFINE(HAVE_TRUNCATE_INODE_PAGES_FINAL, 1,
678                 [kernel has truncate_inode_pages_final])
679 ])
680 ]) # LC_HAVE_TRUNCATE_IPAGES_FINAL
681
682 #
683 # LC_IOPS_RENAME_WITH_FLAGS
684 #
685 # 3.14 has inode_operations->rename with 5 args
686 # commit 520c8b16505236fc82daa352e6c5e73cd9870cff
687 #
688 AC_DEFUN([LC_IOPS_RENAME_WITH_FLAGS], [
689 LB_CHECK_COMPILE([if 'inode_operations->rename' taken flags as argument],
690 iops_rename_with_flags, [
691         #include <linux/fs.h>
692 ],[
693         struct inode *i1 = NULL, *i2 = NULL;
694         struct dentry *d1 = NULL, *d2 = NULL;
695         int rc;
696         rc = ((struct inode_operations *)0)->rename(i1, d1, i2, d2, 0);
697 ], [
698         AC_DEFINE(HAVE_IOPS_RENAME_WITH_FLAGS, 1,
699                 [inode_operations->rename need flags as argument])
700 ])
701 ]) # LC_IOPS_RENAME_WITH_FLAGS
702
703 #
704 # LC_VFS_RENAME_6ARGS
705 #
706 # 3.15 has vfs_rename with 6 args
707 #
708 AC_DEFUN([LC_VFS_RENAME_6ARGS], [
709 LB_CHECK_COMPILE([if Linux kernel has 'vfs_rename' with 6 args],
710 vfs_rename_6args, [
711         #include <linux/fs.h>
712 ],[
713         vfs_rename(NULL, NULL, NULL, NULL, NULL, NULL);
714 ], [
715         AC_DEFINE(HAVE_VFS_RENAME_6ARGS, 1,
716                 [kernel has vfs_rename with 6 args])
717 ])
718 ]) # LC_VFS_RENAME_6ARGS
719
720 #
721 # LC_DIRECTIO_USE_ITER
722 #
723 # 3.16 kernel changes direct IO to use iov_iter
724 #
725 AC_DEFUN([LC_DIRECTIO_USE_ITER], [
726 LB_CHECK_COMPILE([if direct IO uses iov_iter],
727 direct_io_iter, [
728         #include <linux/fs.h>
729 ],[
730         struct address_space_operations ops = { };
731         struct iov_iter *iter = NULL;
732         loff_t offset = 0;
733
734         ops.direct_IO(0, NULL, iter, offset);
735 ],[
736         AC_DEFINE(HAVE_DIRECTIO_ITER, 1,
737                 [direct IO uses iov_iter])
738 ])
739 ]) # LC_DIRECTIO_USE_ITER
740
741 #
742 # LC_HAVE_IOV_ITER_INIT_DIRECTION
743 #
744 #
745 # 3.16 linux commit 71d8e532b1549a478e6a6a8a44f309d050294d00
746 #      changed iov_iter_init api to start accepting a tag
747 #      that defines if its a read or write operation
748 #
749 AC_DEFUN([LC_HAVE_IOV_ITER_INIT_DIRECTION], [
750 tmp_flags="$EXTRA_KCFLAGS"
751 EXTRA_KCFLAGS="-Werror"
752 LB_CHECK_COMPILE([if 'iov_iter_init' takes a tag],
753 iter_init, [
754         #include <linux/uio.h>
755         #include <linux/fs.h>
756 ],[
757         const struct iovec *iov = NULL;
758
759         iov_iter_init(NULL, READ, iov, 1, 0);
760 ],[
761         AC_DEFINE(HAVE_IOV_ITER_INIT_DIRECTION, 1,
762                 [iov_iter_init handles directional tag])
763 ])
764 EXTRA_KCFLAGS="$tmp_flags"
765 ]) # LC_HAVE_IOV_ITER_INIT_DIRECTION
766
767 #
768 # LC_HAVE_IOV_ITER_TRUNCATE
769 #
770 #
771 # 3.16 introduces a new API iov_iter_truncate()
772 #
773 AC_DEFUN([LC_HAVE_IOV_ITER_TRUNCATE], [
774 tmp_flags="$EXTRA_KCFLAGS"
775 EXTRA_KCFLAGS="-Werror"
776 LB_CHECK_COMPILE([if 'iov_iter_truncate' exists ],
777 iter_truncate, [
778         #include <linux/uio.h>
779         #include <linux/fs.h>
780 ],[
781         struct iov_iter *i = NULL;
782
783         iov_iter_truncate(i, 0);
784 ],[
785         AC_DEFINE(HAVE_IOV_ITER_TRUNCATE, 1, [iov_iter_truncate exists])
786 ])
787 EXTRA_KCFLAGS="$tmp_flags"
788 ]) # LC_HAVE_IOV_ITER_TRUNCATE
789
790 #
791 # LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
792 #
793 # 3.16 introduces [read|write]_iter to struct file_operations
794 #
795 AC_DEFUN([LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER], [
796 LB_CHECK_COMPILE([if 'file_operations.[read|write]_iter' exist],
797 file_function_iter, [
798         #include <linux/fs.h>
799 ],[
800         ((struct file_operations *)NULL)->read_iter(NULL, NULL);
801         ((struct file_operations *)NULL)->write_iter(NULL, NULL);
802 ],[
803         AC_DEFINE(HAVE_FILE_OPERATIONS_READ_WRITE_ITER, 1,
804                 [file_operations.[read|write]_iter functions exist])
805 ])
806 ]) # LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
807
808 #
809 # LC_HAVE_INTERVAL_BLK_INTEGRITY
810 #
811 # 3.17 replace sector_size with interval in struct blk_integrity
812 #
813 AC_DEFUN([LC_HAVE_INTERVAL_BLK_INTEGRITY], [
814 LB_CHECK_COMPILE([if 'blk_integrity.interval' exist],
815 interval_blk_integrity, [
816         #include <linux/blkdev.h>
817 ],[
818         ((struct blk_integrity *)0)->interval = 0;
819 ],[
820         AC_DEFINE(HAVE_INTERVAL_BLK_INTEGRITY, 1,
821                 [blk_integrity.interval exist])
822 ])
823 ]) # LC_HAVE_INTERVAL_BLK_INTEGRITY
824
825 #
826 # LC_KEY_MATCH_DATA
827 #
828 # 3.17  replaces key_type::match with match_preparse
829 #       and has new struct key_match_data
830 #
831 AC_DEFUN([LC_KEY_MATCH_DATA], [
832 LB_CHECK_COMPILE([if struct key_match field exist],
833 key_match, [
834         #include <linux/key-type.h>
835 ],[
836         struct key_match_data data;
837
838         data.raw_data = NULL;
839 ],[
840         AC_DEFINE(HAVE_KEY_MATCH_DATA, 1,
841                 [struct key_match_data exist])
842 ])
843 ]) # LC_KEY_MATCH_DATA
844
845 #
846 # LC_NFS_FILLDIR_USE_CTX
847 #
848 # 3.18 kernel moved from void cookie to struct dir_context
849 #
850 AC_DEFUN([LC_NFS_FILLDIR_USE_CTX], [
851 tmp_flags="$EXTRA_KCFLAGS"
852 EXTRA_KCFLAGS="-Werror"
853 LB_CHECK_COMPILE([if filldir_t uses struct dir_context],
854 filldir_ctx, [
855         #include <linux/fs.h>
856 ],[
857         int filldir(struct dir_context *ctx, const char* name,
858                     int i, loff_t off, u64 tmp, unsigned temp)
859         {
860                 return 0;
861         }
862
863         struct dir_context ctx = {
864                 .actor = filldir,
865         };
866
867         ctx.actor(NULL, "test", 0, (loff_t) 0, 0, 0);
868 ],[
869         AC_DEFINE(HAVE_FILLDIR_USE_CTX, 1,
870                 [filldir_t needs struct dir_context as argument])
871 ])
872 EXTRA_KCFLAGS="$tmp_flags"
873 ]) # LC_NFS_FILLDIR_USE_CTX
874
875 #
876 # LC_PERCPU_COUNTER_INIT
877 #
878 # 3.18  For kernels 3.18 and after percpu_counter_init starts
879 #       to pass a GFP_* memory allocation flag for internal
880 #       memory allocation purposes.
881 #
882 AC_DEFUN([LC_PERCPU_COUNTER_INIT], [
883 LB_CHECK_COMPILE([if percpu_counter_init uses GFP_* flag as argument],
884 percpu_counter_init, [
885         #include <linux/percpu_counter.h>
886 ],[
887         percpu_counter_init(NULL, 0, GFP_KERNEL);
888 ],[
889         AC_DEFINE(HAVE_PERCPU_COUNTER_INIT_GFP_FLAG, 1,
890                 [percpu_counter_init uses GFP_* flag])
891 ])
892 ]) # LC_PERCPU_COUNTER_INIT
893
894 #
895 # LC_KIOCB_HAS_NBYTES
896 #
897 # 3.19 kernel removed ki_nbytes from struct kiocb
898 #
899 AC_DEFUN([LC_KIOCB_HAS_NBYTES], [
900 LB_CHECK_COMPILE([if struct kiocb has ki_nbytes field],
901 ki_nbytes, [
902         #include <linux/fs.h>
903 ],[
904         struct kiocb iocb = { };
905
906         iocb.ki_nbytes = 0;
907 ],[
908         AC_DEFINE(HAVE_KI_NBYTES, 1, [ki_nbytes field exist])
909 ])
910 ]) # LC_KIOCB_HAS_NBYTES
911
912 #
913 # LC_HAVE_DQUOT_QC_DQBLK
914 #
915 # 3.19 has quotactl_ops->[sg]et_dqblk that take struct kqid and qc_dqblk
916 # Added in commit 14bf61ffe
917 #
918 AC_DEFUN([LC_HAVE_DQUOT_QC_DQBLK], [
919 tmp_flags="$EXTRA_KCFLAGS"
920 EXTRA_KCFLAGS="-Werror"
921 LB_CHECK_COMPILE([if 'quotactl_ops.set_dqblk' takes struct qc_dqblk],
922 qc_dqblk, [
923         #include <linux/fs.h>
924         #include <linux/quota.h>
925 ],[
926         ((struct quotactl_ops *)0)->set_dqblk(NULL, *((struct kqid*)0), (struct qc_dqblk*)0);
927 ],[
928         AC_DEFINE(HAVE_DQUOT_QC_DQBLK, 1,
929                 [quotactl_ops.set_dqblk takes struct qc_dqblk])
930         AC_DEFINE(HAVE_DQUOT_KQID, 1,
931                 [quotactl_ops.set_dqblk takes struct kqid])
932 ])
933 EXTRA_KCFLAGS="$tmp_flags"
934 ]) # LC_HAVE_DQUOT_QC_DQBLK
935
936 #
937 # LC_HAVE_AIO_COMPLETE
938 #
939 # 3.19 kernel makes aio_complete() static
940 #
941 AC_DEFUN([LC_HAVE_AIO_COMPLETE], [
942 LB_CHECK_COMPILE([if kernel has exported aio_complete() ],
943 aio_complete, [
944         #include <linux/aio.h>
945 ],[
946         aio_complete(NULL, 0, 0);
947 ],[
948         AC_DEFINE(HAVE_AIO_COMPLETE, 1, [aio_complete defined])
949 ])
950 ]) # LC_HAVE_AIO_COMPLETE
951
952 #
953 # LC_BACKING_DEV_INFO_REMOVAL
954 #
955 # 3.20 kernel removed backing_dev_info from address_space
956 #
957 AC_DEFUN([LC_BACKING_DEV_INFO_REMOVAL], [
958 LB_CHECK_COMPILE([if struct address_space has backing_dev_info],
959 backing_dev_info, [
960         #include <linux/fs.h>
961 ],[
962         struct address_space mapping;
963
964         mapping.backing_dev_info = NULL;
965 ],[
966         AC_DEFINE(HAVE_BACKING_DEV_INFO, 1, [backing_dev_info exist])
967 ])
968 ]) # LC_BACKING_DEV_INFO_REMOVAL
969
970 #
971 # LC_HAVE_BDI_CAP_MAP_COPY
972 #
973 # 3.20  removed mmap handling for backing devices since
974 #       it breaks on non-MMU systems. See kernel commit
975 #       b4caecd48005fbed3949dde6c1cb233142fd69e9
976 #
977 AC_DEFUN([LC_HAVE_BDI_CAP_MAP_COPY], [
978 LB_CHECK_COMPILE([if have 'BDI_CAP_MAP_COPY'],
979 bdi_cap_map_copy, [
980         #include <linux/backing-dev.h>
981 ],[
982         struct backing_dev_info info;
983
984         info.capabilities = BDI_CAP_MAP_COPY;
985 ],[
986         AC_DEFINE(HAVE_BDI_CAP_MAP_COPY, 1,
987                 [BDI_CAP_MAP_COPY exist])
988 ])
989 ]) # LC_HAVE_BDI_CAP_MAP_COPY
990
991 #
992 # LC_IOV_ITER_RW
993 #
994 # 4.1 kernel has iov_iter_rw
995 #
996 AC_DEFUN([LC_IOV_ITER_RW], [
997 LB_CHECK_COMPILE([if iov_iter_rw exist],
998 iov_iter_rw, [
999         #include <linux/fs.h>
1000         #include <linux/uio.h>
1001 ],[
1002         struct iov_iter *iter = NULL;
1003
1004         iov_iter_rw(iter);
1005 ],[
1006         AC_DEFINE(HAVE_IOV_ITER_RW, 1,
1007                 [iov_iter_rw exist])
1008 ])
1009 ]) # LC_IOV_ITER_RW
1010
1011 #
1012 # LC_HAVE_SYNC_READ_WRITE
1013 #
1014 # 4.1 new_sync_[read|write] no longer exported
1015 #
1016 AC_DEFUN([LC_HAVE_SYNC_READ_WRITE], [
1017 LB_CHECK_EXPORT([new_sync_read], [fs/read_write.c],
1018         [AC_DEFINE(HAVE_SYNC_READ_WRITE, 1,
1019                         [new_sync_[read|write] is exported by the kernel])])
1020 ]) # LC_HAVE_SYNC_READ_WRITE
1021
1022 #
1023 # LC_HAVE___BI_CNT
1024 #
1025 # 4.1 redefined bi_cnt as __bi_cnt in commit dac56212e8127dbc0
1026 #
1027 AC_DEFUN([LC_HAVE___BI_CNT], [
1028 LB_CHECK_COMPILE([if Linux kernel has __bi_cnt in struct bio],
1029 have___bi_cnt, [
1030         #include <asm/atomic.h>
1031         #include <linux/bio.h>
1032         #include <linux/blk_types.h>
1033 ],[
1034         struct bio bio = { };
1035         int cnt;
1036         cnt = atomic_read(&bio.__bi_cnt);
1037 ], [
1038         AC_DEFINE(HAVE___BI_CNT, 1,
1039                 [struct bio has __bi_cnt])
1040 ])
1041 ]) # LC_HAVE___BI_CNT
1042
1043 #
1044 # LC_SYMLINK_OPS_USE_NAMEIDATA
1045 #
1046 # For the 4.2+ kernels the file system internal symlink api no
1047 # longer uses struct nameidata as a argument
1048 #
1049 AC_DEFUN([LC_SYMLINK_OPS_USE_NAMEIDATA], [
1050 LB_CHECK_COMPILE([if symlink inode operations have struct nameidata argument],
1051 symlink_use_nameidata, [
1052         #include <linux/namei.h>
1053         #include <linux/fs.h>
1054 ],[
1055         struct nameidata *nd = NULL;
1056
1057         ((struct inode_operations *)0)->follow_link(NULL, nd);
1058         ((struct inode_operations *)0)->put_link(NULL, nd, NULL);
1059 ],[
1060         AC_DEFINE(HAVE_SYMLINK_OPS_USE_NAMEIDATA, 1,
1061                 [symlink inode operations need struct nameidata argument])
1062 ])
1063 ]) # LC_SYMLINK_OPS_USE_NAMEIDATA
1064
1065 #
1066 # LC_BIO_ENDIO_USES_ONE_ARG
1067 #
1068 # 4.2 kernel bio_endio now only takes one argument
1069 #
1070 AC_DEFUN([LC_BIO_ENDIO_USES_ONE_ARG], [
1071 LB_CHECK_COMPILE([if 'bio_endio' with one argument exist],
1072 bio_endio, [
1073         #include <linux/bio.h>
1074 ],[
1075         bio_endio(NULL);
1076 ],[
1077         AC_DEFINE(HAVE_BIO_ENDIO_USES_ONE_ARG, 1,
1078                 [bio_endio takes only one argument])
1079 ])
1080 ]) # LC_BIO_ENDIO_USES_ONE_ARG
1081
1082 #
1083 # LC_ACCOUNT_PAGE_DIRTIED_3ARGS
1084 #
1085 # 4.2 [to 4.5] kernel page dirtied takes 3 arguments
1086 #
1087 AC_DEFUN([LC_ACCOUNT_PAGE_DIRTIED_3ARGS], [
1088 LB_CHECK_COMPILE([if 'account_page_dirtied' with 3 args exists],
1089 account_page_dirtied, [
1090         #include <linux/mm.h>
1091 ],[
1092         account_page_dirtied(NULL, NULL, NULL);
1093 ],[
1094         AC_DEFINE(HAVE_ACCOUNT_PAGE_DIRTIED_3ARGS, 1,
1095                 [account_page_dirtied takes three arguments])
1096 ])
1097 ]) # LC_ACCOUNT_PAGE_DIRTIED_3ARGS
1098
1099 #
1100 # LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
1101 #
1102 # 4.3 replace interval with interval_exp in 'struct blk_integrity'
1103 # 'struct blk_integrity_profile' is also added in this version,
1104 # thus use this to determine whether 'struct blk_integrity' has profile
1105 #
1106 AC_DEFUN([LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY], [
1107 LB_CHECK_COMPILE([if 'blk_integrity.interval_exp' exist],
1108 blk_integrity_interval_exp, [
1109         #include <linux/blkdev.h>
1110 ],[
1111         ((struct blk_integrity *)0)->interval_exp = 0;
1112 ],[
1113         AC_DEFINE(HAVE_INTERVAL_EXP_BLK_INTEGRITY, 1,
1114                 [blk_integrity.interval_exp exist])
1115 ])
1116 ]) # LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
1117
1118 #
1119 # LC_HAVE_CACHE_HEAD_HLIST
1120 #
1121 # 4.3 kernel swiched to hlist for cache_head
1122 #
1123 AC_DEFUN([LC_HAVE_CACHE_HEAD_HLIST], [
1124 LB_CHECK_COMPILE([if 'struct cache_head' has 'cache_list' field],
1125 cache_head_has_hlist, [
1126         #include <linux/sunrpc/cache.h>
1127 ],[
1128         do {} while(sizeof(((struct cache_head *)0)->cache_list));
1129 ],[
1130         AC_DEFINE(HAVE_CACHE_HEAD_HLIST, 1,
1131                 [cache_head has hlist cache_list])
1132 ])
1133 ]) # LC_HAVE_CACHE_HEAD_HLIST
1134
1135 #
1136 # LC_HAVE_XATTR_HANDLER_SIMPLIFIED
1137 #
1138 # Kernel version 4.3 commit e409de992e3ea3674393465f07cc71c948edd87a
1139 # simplified xattr_handler handling by passing in the handler pointer
1140 #
1141 AC_DEFUN([LC_HAVE_XATTR_HANDLER_SIMPLIFIED], [
1142 tmp_flags="$EXTRA_KCFLAGS"
1143 EXTRA_KCFLAGS="-Werror"
1144 LB_CHECK_COMPILE([if 'struct xattr_handler' functions pass in handler pointer],
1145 xattr_handler_simplified, [
1146         #include <linux/xattr.h>
1147 ],[
1148         struct xattr_handler handler;
1149
1150         ((struct xattr_handler *)0)->get(&handler, NULL, NULL, NULL, 0);
1151         ((struct xattr_handler *)0)->set(&handler, NULL, NULL, NULL, 0, 0);
1152 ],[
1153         AC_DEFINE(HAVE_XATTR_HANDLER_SIMPLIFIED, 1, [handler pointer is parameter])
1154 ])
1155 EXTRA_KCFLAGS="$tmp_flags"
1156 ]) # LC_HAVE_XATTR_HANDLER_SIMPLIFIED
1157
1158 #
1159 # LC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD
1160 #
1161 # 4.3 replace interval with interval_exp in 'struct blk_integrity'.
1162 #
1163 AC_DEFUN([LC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD], [
1164 LB_CHECK_COMPILE([if 'bio_integrity_payload.bip_iter' exist],
1165 bio_integrity_payload_bip_iter, [
1166         #include <linux/bio.h>
1167 ],[
1168         ((struct bio_integrity_payload *)0)->bip_iter.bi_size = 0;
1169 ],[
1170         AC_DEFINE(HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD, 1,
1171                 [bio_integrity_payload.bip_iter exist])
1172 ])
1173 ]) # LC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD
1174
1175 #
1176 # LC_BIO_INTEGRITY_PREP_FN
1177 #
1178 # Lustre kernel patch extents bio_integrity_prep to accept optional
1179 # generate/verify_fn as extra args.
1180 #
1181 AC_DEFUN([LC_BIO_INTEGRITY_PREP_FN], [
1182 LB_CHECK_COMPILE([if 'bio_integrity_prep_fn' exists],
1183 bio_integrity_prep_fn, [
1184         #include <linux/bio.h>
1185 ],[
1186         bio_integrity_prep_fn(NULL, NULL, NULL);
1187 ],[
1188         AC_DEFINE(HAVE_BIO_INTEGRITY_PREP_FN, 1,
1189                 [kernel has bio_integrity_prep_fn])
1190         AC_SUBST(PATCHED_INTEGRITY_INTF)
1191 ],[
1192         AC_SUBST(PATCHED_INTEGRITY_INTF, [#])
1193 ])
1194 ]) # LC_BIO_INTEGRITY_PREP_FN
1195
1196 #
1197 # LC_HAVE_BI_OPF
1198 #
1199 # 4.4/4.8 redefined bi_rw as bi_opf (SLES12/kernel commit 4382e33ad37486)
1200 #
1201 AC_DEFUN([LC_HAVE_BI_OPF], [
1202 LB_CHECK_COMPILE([if Linux kernel has bi_opf in struct bio],
1203 have_bi_opf, [
1204         #include <linux/bio.h>
1205 ],[
1206         struct bio bio;
1207
1208         bio.bi_opf = 0;
1209 ], [
1210         AC_DEFINE(HAVE_BI_OPF, 1,
1211                 [struct bio has bi_opf])
1212 ])
1213 ]) # LC_HAVE_BI_OPF
1214
1215 #
1216 # LC_HAVE_SUBMIT_BIO_2ARGS
1217 #
1218 # 4.4 removed an argument from submit_bio
1219 #
1220 AC_DEFUN([LC_HAVE_SUBMIT_BIO_2ARGS], [
1221 LB_CHECK_COMPILE([if submit_bio takes two arguments],
1222 have_submit_bio_2args, [
1223         #include <linux/bio.h>
1224 ],[
1225         struct bio bio;
1226         submit_bio(READ, &bio);
1227 ], [
1228         AC_DEFINE(HAVE_SUBMIT_BIO_2ARGS, 1,
1229                 [submit_bio takes two arguments])
1230 ])
1231 ]) # LC_HAVE_SUBMIT_BIO_2_ARGS
1232
1233 #
1234 # LC_HAVE_CLEAN_BDEV_ALIASES
1235 #
1236 # 4.4/4.9 unmap_underlying_metadata was replaced by clean_bdev_aliases
1237 # (SLES12/kernel commit 29f3ad7d8380364c)
1238 #
1239 AC_DEFUN([LC_HAVE_CLEAN_BDEV_ALIASES], [
1240 LB_CHECK_COMPILE([if kernel has clean_bdev_aliases],
1241 have_clean_bdev_aliases, [
1242         #include <linux/buffer_head.h>
1243 ],[
1244         struct block_device bdev;
1245         clean_bdev_aliases(&bdev,1,1);
1246 ], [
1247         AC_DEFINE(HAVE_CLEAN_BDEV_ALIASES, 1,
1248                 [kernel has clean_bdev_aliases])
1249 ])
1250 ]) # LC_HAVE_CLEAN_BDEV_ALIASES
1251
1252 #
1253 # LC_HAVE_LOCKS_LOCK_FILE_WAIT
1254 #
1255 # 4.4 kernel have moved locks API users to
1256 # locks_lock_inode_wait()
1257 #
1258 AC_DEFUN([LC_HAVE_LOCKS_LOCK_FILE_WAIT], [
1259 LB_CHECK_COMPILE([if 'locks_lock_file_wait' exists],
1260 locks_lock_file_wait, [
1261         #include <linux/fs.h>
1262 ],[
1263         locks_lock_file_wait(NULL, NULL);
1264 ],[
1265         AC_DEFINE(HAVE_LOCKS_LOCK_FILE_WAIT, 1,
1266                 [kernel has locks_lock_file_wait])
1267 ])
1268 ]) # LC_HAVE_LOCKS_LOCK_FILE_WAIT
1269
1270 #
1271 # LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
1272 #
1273 # 4.4 kernel merged type-specific data with the payload data for keys
1274 #
1275 AC_DEFUN([LC_HAVE_KEY_PAYLOAD_DATA_ARRAY], [
1276 LB_CHECK_COMPILE([if 'struct key' has 'payload.data' as an array],
1277 key_payload_data_array, [
1278         #include <linux/key.h>
1279 ],[
1280         struct key key = { };
1281
1282         key.payload.data[0] = NULL;
1283 ],[
1284         AC_DEFINE(HAVE_KEY_PAYLOAD_DATA_ARRAY, 1, [payload.data is an array])
1285 ])
1286 ]) #LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
1287
1288 #
1289 # LC_HAVE_XATTR_HANDLER_NAME
1290 #
1291 # Kernel version 4.4 commit 98e9cb5711c68223f0e4d5201b9a6add255ec550
1292 # add a name member to struct xattr_handler
1293 #
1294 AC_DEFUN([LC_HAVE_XATTR_HANDLER_NAME], [
1295 tmp_flags="$EXTRA_KCFLAGS"
1296 EXTRA_KCFLAGS="-Werror"
1297 LB_CHECK_COMPILE([if 'struct xattr_handler' has a name member],
1298 xattr_handler_name, [
1299         #include <linux/xattr.h>
1300 ],[
1301         ((struct xattr_handler *)NULL)->name = NULL;
1302 ],[
1303         AC_DEFINE(HAVE_XATTR_HANDLER_NAME, 1, [xattr_handler has a name member])
1304 ])
1305 EXTRA_KCFLAGS="$tmp_flags"
1306 ]) # LC_HAVE_XATTR_HANDLER_NAME
1307
1308 #
1309 # LC_HAVE_FILE_DENTRY
1310 #
1311 # 4.5 adds wrapper file_dentry
1312 #
1313 AC_DEFUN([LC_HAVE_FILE_DENTRY], [
1314 LB_CHECK_COMPILE([if Linux kernel has 'file_dentry'],
1315 file_dentry, [
1316         #include <linux/fs.h>
1317 ],[
1318         file_dentry(NULL);
1319 ], [
1320         AC_DEFINE(HAVE_FILE_DENTRY, 1,
1321                 [kernel has file_dentry])
1322 ])
1323 ]) # LC_HAVE_FILE_DENTRY
1324
1325 #
1326 # LC_HAVE_INODE_LOCK
1327 #
1328 # 4.5 introduced inode_lock
1329 #
1330 AC_DEFUN([LC_HAVE_INODE_LOCK], [
1331 LB_CHECK_COMPILE([if 'inode_lock' is defined],
1332 inode_lock, [
1333         #include <linux/fs.h>
1334 ],[
1335         inode_lock(NULL);
1336 ], [
1337         AC_DEFINE(HAVE_INODE_LOCK, 1,
1338                   [inode_lock is defined])
1339 ])
1340 ]) # LC_HAVE_INODE_LOCK
1341
1342 #
1343 # LC_HAVE_IOP_GET_LINK
1344 #
1345 # 4.5 vfs replaced iop->follow_link with
1346 # iop->get_link
1347 #
1348 AC_DEFUN([LC_HAVE_IOP_GET_LINK], [
1349 LB_CHECK_COMPILE([if 'iop' has 'get_link'],
1350 inode_ops_get_link, [
1351         #include <linux/fs.h>
1352 ],[
1353         struct inode_operations iop;
1354         iop.get_link = NULL;
1355 ],[
1356         AC_DEFINE(HAVE_IOP_GET_LINK, 1,
1357                 [have iop get_link])
1358 ])
1359 ]) # LC_HAVE_IOP_GET_LINK
1360
1361 #
1362 # LC_HAVE_IN_COMPAT_SYSCALL
1363 #
1364 # 4.6 renamed is_compat_task to in_compat_syscall
1365 #
1366 AC_DEFUN([LC_HAVE_IN_COMPAT_SYSCALL], [
1367 LB_CHECK_COMPILE([if 'in_compat_syscall' is defined],
1368 in_compat_syscall, [
1369         #include <linux/compat.h>
1370 ],[
1371         in_compat_syscall();
1372 ],[
1373         AC_DEFINE(HAVE_IN_COMPAT_SYSCALL, 1,
1374                 [have in_compat_syscall])
1375 ])
1376 ]) # LC_HAVE_IN_COMPAT_SYSCALL
1377
1378 #
1379 # LC_HAVE_XATTR_HANDLER_INODE_PARAM
1380 #
1381 # Kernel version 4.6 commit b296821a7c42fa58baa17513b2b7b30ae66f3336
1382 # and commit 5930122683dff58f0846b0f0405b4bd598a3ba6a added inode parameter
1383 # to xattr_handler functions
1384 #
1385 AC_DEFUN([LC_HAVE_XATTR_HANDLER_INODE_PARAM], [
1386 tmp_flags="$EXTRA_KCFLAGS"
1387 EXTRA_KCFLAGS="-Werror"
1388 LB_CHECK_COMPILE([if 'struct xattr_handler' functions have inode parameter],
1389 xattr_handler_inode_param, [
1390         #include <linux/xattr.h>
1391 ],[
1392         const struct xattr_handler handler;
1393
1394         ((struct xattr_handler *)0)->get(&handler, NULL, NULL, NULL, NULL, 0);
1395         ((struct xattr_handler *)0)->set(&handler, NULL, NULL, NULL, NULL, 0, 0);
1396 ],[
1397         AC_DEFINE(HAVE_XATTR_HANDLER_INODE_PARAM, 1, [needs inode parameter])
1398 ])
1399 EXTRA_KCFLAGS="$tmp_flags"
1400 ]) # LC_HAVE_XATTR_HANDLER_INODE_PARAM
1401
1402 #
1403 # LC_D_IN_LOOKUP
1404 #
1405 # Kernel version 4.6 commit 85c7f81041d57cfe9dc97f4680d5586b54534a39
1406 # introduced parallel lookups in the VFS layer. The inline function
1407 # d_in_lookup was added to notify when the same item was being queried
1408 # at the same time.
1409 #
1410 AC_DEFUN([LC_D_IN_LOOKUP], [
1411 tmp_flags="$EXTRA_KCFLAGS"
1412 EXTRA_KCFLAGS="-Werror"
1413 LB_CHECK_COMPILE([if 'd_in_lookup' is defined],
1414 d_in_lookup, [
1415         #include <linux/dcache.h>
1416 ],[
1417         d_in_lookup(NULL);
1418 ],[
1419         AC_DEFINE(HAVE_D_IN_LOOKUP, 1, [d_in_lookup is defined])
1420 ])
1421 EXTRA_KCFLAGS="$tmp_flags"
1422 ]) # LC_D_IN_LOOKUP
1423
1424 #
1425 # LC_LOCK_PAGE_MEMCG
1426 #
1427 # Kernel version 4.6 adds lock_page_memcg
1428 #
1429 AC_DEFUN([LC_LOCK_PAGE_MEMCG], [
1430 LB_CHECK_COMPILE([if 'lock_page_memcg' is defined],
1431 lock_page_memcg, [
1432         #include <linux/memcontrol.h>
1433 ],[
1434         lock_page_memcg(NULL);
1435 ],[
1436         AC_DEFINE(HAVE_LOCK_PAGE_MEMCG, 1,
1437                 [lock_page_memcg is defined])
1438 ])
1439 ]) # LC_LOCK_PAGE_MEMCG
1440
1441 #
1442 # LC_DIRECTIO_2ARGS
1443 #
1444 # Kernel version 4.7 commit c8b8e32d700fe943a935e435ae251364d016c497
1445 # direct-io: eliminate the offset argument to ->direct_IO
1446 #
1447 AC_DEFUN([LC_DIRECTIO_2ARGS], [
1448 LB_CHECK_COMPILE([if '->direct_IO()' taken 2 arguments],
1449 direct_io_2args, [
1450         #include <linux/fs.h>
1451 ],[
1452         struct address_space_operations ops = { };
1453         struct iov_iter *iter = NULL;
1454         struct kiocb *iocb = NULL;
1455         int rc;
1456
1457         rc = ops.direct_IO(iocb, iter);
1458 ],[
1459         AC_DEFINE(HAVE_DIRECTIO_2ARGS, 1,
1460                 [direct_IO need 2 arguments])
1461 ])
1462 ]) # LC_DIRECTIO_2ARGS
1463
1464 #
1465 # LC_GENERIC_WRITE_SYNC_2ARGS
1466 #
1467 # Kernel version 4.7 commit dde0c2e79848298cc25621ad080d47f94dbd7cce
1468 # fs: add IOCB_SYNC and IOCB_DSYNC
1469 #
1470 AC_DEFUN([LC_GENERIC_WRITE_SYNC_2ARGS], [
1471 LB_CHECK_COMPILE([if 'generic_write_sync()' taken 2 arguments],
1472 generic_write_sync_2args, [
1473         #include <linux/fs.h>
1474 ],[
1475         struct kiocb *iocb = NULL;
1476         ssize_t rc;
1477
1478         rc = generic_write_sync(iocb, 0);
1479 ],[
1480         AC_DEFINE(HAVE_GENERIC_WRITE_SYNC_2ARGS, 1,
1481                 [generic_write_sync need 2 arguments])
1482 ])
1483 ]) # LC_GENERIC_WRITE_SYNC_2ARGS
1484
1485 #
1486 # LC_FOP_ITERATE_SHARED
1487 #
1488 # Kernel v4.6-rc3-29-g6192269 adds iterate_shared method to file_operations
1489 #
1490 AC_DEFUN([LC_FOP_ITERATE_SHARED], [
1491 LB_CHECK_COMPILE([if 'file_operations' has 'iterate_shared'],
1492 fop_iterate_shared, [
1493         #include <linux/fs.h>
1494 ],[
1495         struct file_operations fop;
1496         fop.iterate_shared = NULL;
1497 ],[
1498         AC_DEFINE(HAVE_FOP_ITERATE_SHARED, 1,
1499                 [file_operations has iterate_shared])
1500 ])
1501 ]) # LC_FOP_ITERATE_SHARED
1502
1503 #
1504 # LC_HAVE_POSIX_ACL_VALID_USER_NS
1505 #
1506 # 4.8 posix_acl_valid takes struct user_namespace
1507 #
1508 AC_DEFUN([LC_HAVE_POSIX_ACL_VALID_USER_NS], [
1509 LB_CHECK_COMPILE([if 'posix_acl_valid' takes 'struct user_namespace'],
1510 posix_acl_valid, [
1511         #include <linux/fs.h>
1512         #include <linux/posix_acl.h>
1513 ],[
1514         posix_acl_valid((struct user_namespace*)NULL, (const struct posix_acl*)NULL);
1515 ],[
1516         AC_DEFINE(HAVE_POSIX_ACL_VALID_USER_NS, 1,
1517                 [posix_acl_valid takes struct user_namespace])
1518 ])
1519 ]) # LC_HAVE_POSIX_ACL_VALID_USER_NS
1520
1521 #
1522 # LC_FULL_NAME_HASH_3ARGS
1523 #
1524 # Kernel version 4.8 commit 8387ff2577eb9ed245df9a39947f66976c6bcd02
1525 # vfs: make the string hashes salt the hash
1526 #
1527 AC_DEFUN([LC_FULL_NAME_HASH_3ARGS], [
1528 LB_CHECK_COMPILE([if 'full_name_hash' taken 3 arguments],
1529 full_name_hash_3args, [
1530         #include <linux/stringhash.h>
1531 ],[
1532         unsigned int hash;
1533         hash = full_name_hash(NULL,NULL,0);
1534 ],[
1535         AC_DEFINE(HAVE_FULL_NAME_HASH_3ARGS, 1,
1536                 [full_name_hash need 3 arguments])
1537 ])
1538 ]) # LC_FULL_NAME_HASH_3ARGS
1539
1540 #
1541 # LC_STRUCT_POSIX_ACL_XATTR
1542 #
1543 # Kernel version 4.8 commit 2211d5ba5c6c4e972ba6dbc912b2897425ea6621
1544 # posix_acl: xattr representation cleanups
1545 #
1546 AC_DEFUN([LC_STRUCT_POSIX_ACL_XATTR], [
1547 LB_CHECK_COMPILE([if 'struct posix_acl_xattr_{header,entry}' defined],
1548 struct_posix_acl_xattr, [
1549         #include <linux/fs.h>
1550         #include <linux/posix_acl_xattr.h>
1551 ],[
1552         struct posix_acl_xattr_header *h = NULL;
1553         struct posix_acl_xattr_entry  *e;
1554         e = (void *)(h + 1);
1555 ],[
1556         AC_DEFINE(HAVE_STRUCT_POSIX_ACL_XATTR, 1,
1557                 [struct posix_acl_xattr_{header,entry} defined])
1558 ])
1559 ]) # LC_STRUCT_POSIX_ACL_XATTR
1560
1561 #
1562 # LC_IOP_XATTR
1563 #
1564 # Kernel version 4.8 commit fd50ecaddf8372a1d96e0daeaac0f93cf04e4d42
1565 # removed {get,set,remove}xattr inode operations
1566 #
1567 AC_DEFUN([LC_IOP_XATTR], [
1568 LB_CHECK_COMPILE([if 'inode_operations' has {get,set,remove}xattr members],
1569 inode_ops_xattr, [
1570         #include <linux/fs.h>
1571 ],[
1572         struct inode_operations iop;
1573         iop.setxattr = NULL;
1574         iop.getxattr = NULL;
1575         iop.removexattr = NULL;
1576 ],[
1577         AC_DEFINE(HAVE_IOP_XATTR, 1,
1578                 [inode_operations has {get,set,remove}xattr members])
1579 ])
1580 ]) # LC_IOP_XATTR
1581
1582 #
1583 # LC_GROUP_INFO_GID
1584 #
1585 # Kernel version 4.9 commit 81243eacfa400f5f7b89f4c2323d0de9982bb0fb
1586 # cred: simpler, 1D supplementary groups
1587 #
1588 AC_DEFUN([LC_GROUP_INFO_GID], [
1589 LB_CHECK_COMPILE([if 'struct group_info' has member 'gid'],
1590 group_info_gid, [
1591         #include <linux/cred.h>
1592 ],[
1593         kgid_t *p;
1594         p = ((struct group_info *)0)->gid;
1595 ],[
1596         AC_DEFINE(HAVE_GROUP_INFO_GID, 1,
1597                 [struct group_info has member gid])
1598 ])
1599 ]) # LC_GROUP_INFO_GID
1600
1601 #
1602 # LC_VFS_SETXATTR
1603 #
1604 # Kernel version 4.9 commit 5d6c31910bc0713e37628dc0ce677dcb13c8ccf4
1605 # added __vfs_{get,set,remove}xattr helpers
1606 #
1607 AC_DEFUN([LC_VFS_SETXATTR], [
1608 LB_CHECK_COMPILE([if '__vfs_setxattr' helper is available],
1609 vfs_setxattr, [
1610         #include <linux/xattr.h>
1611 ],[
1612         __vfs_setxattr(NULL, NULL, NULL, NULL, 0, 0);
1613 ],[
1614         AC_DEFINE(HAVE_VFS_SETXATTR, 1,
1615                 ['__vfs_setxattr is available])
1616 ])
1617 ]) # LC_VFS_SETXATTR
1618
1619 #
1620 # LC_POSIX_ACL_UPDATE_MODE
1621 #
1622 # Kernel version 4.9 commit 073931017b49d9458aa351605b43a7e34598caef
1623 # posix_acl: Clear SGID bit when setting file permissions
1624 #
1625 AC_DEFUN([LC_POSIX_ACL_UPDATE_MODE], [
1626 LB_CHECK_COMPILE([if 'posix_acl_update_mode' exists],
1627 posix_acl_update_mode, [
1628         #include <linux/fs.h>
1629         #include <linux/posix_acl.h>
1630 ],[
1631         posix_acl_update_mode(NULL, NULL, NULL);
1632 ],[
1633         AC_DEFINE(HAVE_POSIX_ACL_UPDATE_MODE, 1,
1634                 ['posix_acl_update_mode' is available])
1635 ])
1636 ]) # LC_POSIX_ACL_UPDATE_MODE
1637
1638 #
1639 # LC_IOP_GENERIC_READLINK
1640 #
1641 # Kernel version 4.10 commit dfeef68862edd7d4bafe68ef7aeb5f658ef24bb5
1642 # removed generic_readlink from individual file systems
1643 #
1644 AC_DEFUN([LC_IOP_GENERIC_READLINK], [
1645 LB_CHECK_COMPILE([if 'generic_readlink' still exist],
1646 inode_ops_readlink, [
1647         #include <linux/fs.h>
1648 ],[
1649         struct inode_operations iop;
1650         iop.readlink = generic_readlink;
1651 ],[
1652         AC_DEFINE(HAVE_IOP_GENERIC_READLINK, 1,
1653                 [generic_readlink has been removed])
1654 ])
1655 ]) # LC_IOP_GENERIC_READLINK
1656
1657 #
1658 # LC_HAVE_VM_FAULT_ADDRESS
1659 #
1660 # Kernel version 4.10 commit 1a29d85eb0f19b7d8271923d8917d7b4f5540b3e
1661 # removed virtual_address field. Need to use address field instead
1662 #
1663 AC_DEFUN([LC_HAVE_VM_FAULT_ADDRESS], [
1664 LB_CHECK_COMPILE([if 'struct vm_fault' replaced virtual_address with address field],
1665 vm_fault_address, [
1666         #include <linux/mm.h>
1667 ],[
1668         struct vm_fault vmf;
1669         vmf.address = NULL;
1670 ],[
1671         AC_DEFINE(HAVE_VM_FAULT_ADDRESS, 1,
1672                 [virtual_address has been replaced by address field])
1673 ])
1674 ]) # LC_HAVE_VM_FAULT_ADDRESS
1675
1676 #
1677 # LC_INODEOPS_ENHANCED_GETATTR
1678 #
1679 # Kernel version 4.11 commit a528d35e8bfcc521d7cb70aaf03e1bd296c8493f
1680 # expanded getattr to be able to get more stat information.
1681 #
1682 AC_DEFUN([LC_INODEOPS_ENHANCED_GETATTR], [
1683 LB_CHECK_COMPILE([if 'inode_operations' getattr member can gather advance stats],
1684 getattr_path, [
1685         #include <linux/fs.h>
1686 ],[
1687         struct path path;
1688
1689         ((struct inode_operations *)1)->getattr(&path, NULL, 0, 0);
1690 ],[
1691         AC_DEFINE(HAVE_INODEOPS_ENHANCED_GETATTR, 1,
1692                 [inode_operations .getattr member function can gather advance stats])
1693 ])
1694 ]) # LC_INODEOPS_ENHANCED_GETATTR
1695
1696 #
1697 # LC_VM_OPERATIONS_REMOVE_VMF_ARG
1698 #
1699 # Kernel version 4.11 commit 11bac80004499ea59f361ef2a5516c84b6eab675
1700 # removed struct vm_area_struct as an argument for vm_operations since
1701 # in the same kernel version struct vma_area_struct was folded into
1702 # struct vm_fault.
1703 #
1704 AC_DEFUN([LC_VM_OPERATIONS_REMOVE_VMF_ARG], [
1705 LB_CHECK_COMPILE([if 'struct vm_operations' removed struct vm_area_struct],
1706 vm_operations_no_vm_area_struct, [
1707         #include <linux/mm.h>
1708 ],[
1709         struct vm_fault vmf;
1710
1711         ((struct vm_operations_struct *)0)->fault(&vmf);
1712         ((struct vm_operations_struct *)0)->page_mkwrite(&vmf);
1713 ],[
1714         AC_DEFINE(HAVE_VM_OPS_USE_VM_FAULT_ONLY, 1,
1715                 ['struct vm_operations' remove struct vm_area_struct argument])
1716 ])
1717 ]) # LC_VM_OPERATIONS_REMOVE_VMF_ARG
1718
1719 #
1720 # LC_HAVE_KEY_USAGE_REFCOUNT
1721 #
1722 # Kernel version 4.11 commit fff292914d3a2f1efd05ca71c2ba72a3c663201e
1723 # converted key.usage from atomic_t to refcount_t.
1724 #
1725 AC_DEFUN([LC_HAVE_KEY_USAGE_REFCOUNT], [
1726 LB_CHECK_COMPILE([if 'key.usage' is refcount_t],
1727 key_usage_refcount, [
1728         #include <linux/key.h>
1729 ],[
1730         struct key key = { };
1731
1732         refcount_read(&key.usage);
1733 ],[
1734         AC_DEFINE(HAVE_KEY_USAGE_REFCOUNT, 1, [key.usage is of type refcount_t])
1735 ])
1736 ]) #LC_HAVE_KEY_USAGE_REFCOUNT
1737
1738 #
1739 # LC_HAVE_CRYPTO_MAX_ALG_NAME_128
1740 #
1741 # Kernel version 4.11 commit f437a3f477cce402dbec6537b29e9e33962c9f73
1742 # switched CRYPTO_MAX_ALG_NAME from 64 to 128.
1743 #
1744 AC_DEFUN([LC_HAVE_CRYPTO_MAX_ALG_NAME_128], [
1745 LB_CHECK_COMPILE([if 'CRYPTO_MAX_ALG_NAME' is 128],
1746 crypto_max_alg_name, [
1747         #include <linux/crypto.h>
1748 ],[
1749         #if CRYPTO_MAX_ALG_NAME != 128
1750         exit(1);
1751         #endif
1752 ],[
1753         AC_DEFINE(HAVE_CRYPTO_MAX_ALG_NAME_128, 1,
1754                 ['CRYPTO_MAX_ALG_NAME' is 128])
1755 ])
1756 ]) # LC_HAVE_CRYPTO_MAX_ALG_NAME_128
1757
1758 #
1759 # Kernel version 4.12 commit 47f38c539e9a42344ff5a664942075bd4df93876
1760 # CURRENT_TIME is not 64 bit time safe so it was replaced with
1761 # current_time()
1762 #
1763 AC_DEFUN([LC_CURRENT_TIME], [
1764 LB_CHECK_COMPILE([if CURRENT_TIME has been replaced with current_time],
1765 current_time, [
1766         #include <linux/fs.h>
1767 ],[
1768         struct iattr attr;
1769
1770         attr.ia_atime = current_time(NULL);
1771 ],[
1772         AC_DEFINE(HAVE_CURRENT_TIME, 1,
1773                 [current_time() has replaced CURRENT_TIME])
1774 ])
1775 ]) # LIBCFS_CURRENT_TIME
1776
1777 #
1778 # Kernel version 4.12-rc3 85787090a21eb749d8b347eaf9ff1a455637473c
1779 # changed struct super_block s_uuid into a proper uuid_t
1780 #
1781 AC_DEFUN([LC_SUPER_BLOCK_S_UUID], [
1782 LB_CHECK_COMPILE([if 'struct super_block' s_uuid is uuid_t],
1783 super_block_s_uuid, [
1784         #include <linux/fs.h>
1785 ],[
1786         struct super_block sb;
1787
1788         uuid_parse(NULL, &sb.s_uuid);
1789 ],[
1790         AC_DEFINE(HAVE_S_UUID_AS_UUID_T, 1, ['s_uuid' is an uuid_t])
1791 ])
1792 ]) # LC_SUPER_BLOCK_S_UUID
1793
1794 #
1795 # LC_SUPER_SETUP_BDI_NAME
1796 #
1797 # Kernel version 4.12 commit 9594caf216dc0fe3e318b34af0127276db661241
1798 # unified bdi handling
1799 #
1800 AC_DEFUN([LC_SUPER_SETUP_BDI_NAME], [
1801 LB_CHECK_COMPILE([if 'super_setup_bdi_name' exist],
1802 super_setup_bdi_name, [
1803         #include <linux/fs.h>
1804 ],[
1805         super_setup_bdi_name(NULL, "lustre");
1806 ],[
1807         AC_DEFINE(HAVE_SUPER_SETUP_BDI_NAME, 1,
1808                 ['super_setup_bdi_name' is available])
1809 ])
1810 ]) # LC_SUPER_SETUP_BDI_NAME
1811
1812 #
1813 # LC_BI_STATUS
1814 #
1815 # 4.12 replace bi_error to bi_status
1816 #
1817 AC_DEFUN([LC_BI_STATUS], [
1818 LB_CHECK_COMPILE([if 'bi_status' exist],
1819 bi_status, [
1820         #include <linux/blk_types.h>
1821 ],[
1822         ((struct bio *)0)->bi_status = 0;
1823 ],[
1824         AC_DEFINE(HAVE_BI_STATUS, 1,
1825                 ['bi_status' is available])
1826 ])
1827 ]) # LC_BI_STATUS
1828
1829 #
1830 # LC_BIO_INTEGRITY_ENABLED
1831 #
1832 # 4.13 removed bio_integrity_enabled
1833 #
1834 AC_DEFUN([LC_BIO_INTEGRITY_ENABLED], [
1835 LB_CHECK_COMPILE([if 'bio_integrity_enabled' exist],
1836 bio_integrity_enabled, [
1837         #include <linux/bio.h>
1838 ],[
1839         bio_integrity_enabled(NULL);
1840 ],[
1841         AC_DEFINE(HAVE_BIO_INTEGRITY_ENABLED, 1,
1842                 ['bio_integrity_enabled' is available])
1843 ])
1844 ]) # LC_BIO_INTEGRITY_ENABLED
1845
1846 #
1847 # LC_PAGEVEC_INIT_ONE_PARAM
1848 #
1849 # 4.14 pagevec_init takes one parameter
1850 #
1851 AC_DEFUN([LC_PAGEVEC_INIT_ONE_PARAM], [
1852 LB_CHECK_COMPILE([if 'pagevec_init' takes one parameter],
1853 pagevec_init, [
1854         #include <linux/pagevec.h>
1855 ],[
1856         pagevec_init(NULL);
1857 ],[
1858         AC_DEFINE(HAVE_PAGEVEC_INIT_ONE_PARAM, 1,
1859                 ['pagevec_init' takes one parameter])
1860 ])
1861 ]) # LC_PAGEVEC_INIT_ONE_PARAM
1862
1863 #
1864 # LC_BI_BDEV
1865 #
1866 # 4.14 replaced bi_bdev to bi_disk
1867 #
1868 AC_DEFUN([LC_BI_BDEV], [
1869 LB_CHECK_COMPILE([if 'bi_bdev' exist],
1870 bi_bdev, [
1871         #include <linux/bio.h>
1872 ],[
1873         ((struct bio *)0)->bi_bdev = NULL;
1874 ],[
1875         AC_DEFINE(HAVE_BI_BDEV, 1,
1876                 ['bi_bdev' is available])
1877 ])
1878 ]) # LC_BI_BDEV
1879
1880 #
1881 # LC_IS_ENCRYPTED
1882 #
1883 # 4.14 introduced IS_ENCRYPTED and S_ENCRYPTED
1884 #
1885 AC_DEFUN([LC_IS_ENCRYPTED], [
1886 LB_CHECK_COMPILE([if IS_ENCRYPTED is defined],
1887 is_encrypted, [
1888         #include <linux/fs.h>
1889 ],[
1890         IS_ENCRYPTED((struct inode *)0);
1891 ],[
1892         has_is_encrypted="yes"
1893 ])
1894 ]) # LC_IS_ENCRYPTED
1895
1896 #
1897 # LC_I_PAGES
1898 #
1899 # kernel 4.17 commit b93b016313b3ba8003c3b8bb71f569af91f19fc7
1900 #
1901 AC_DEFUN([LC_I_PAGES], [
1902 LB_CHECK_COMPILE([if struct address_space has i_pages],
1903 i_pages, [
1904         #include <linux/fs.h>
1905 ],[
1906         struct address_space mapping = {};
1907         void *i_pages;
1908
1909         i_pages = &mapping.i_pages;
1910 ],[
1911         AC_DEFINE(HAVE_I_PAGES, 1,
1912                 [struct address_space has i_pages])
1913 ])
1914 ]) # LC_I_PAGES
1915
1916 #
1917 # LC_VM_FAULT_T
1918 #
1919 # kernel 4.17 commit 3d3539018d2cbd12e5af4a132636ee7fd8d43ef0
1920 # mm: create the new vm_fault_t type
1921 #
1922 AC_DEFUN([LC_VM_FAULT_T], [
1923 LB_CHECK_COMPILE([if vm_fault_t type exists],
1924 vm_fault_t, [
1925         #include <linux/mm_types.h>
1926 ],[
1927         vm_fault_t x = VM_FAULT_SIGBUS;
1928         (void)x
1929 ],[
1930         AC_DEFINE(HAVE_VM_FAULT_T, 1,
1931                 [if vm_fault_t type exists])
1932 ])
1933 ]) # LC_VM_FAULT_T
1934
1935 #
1936 # LC_INODE_TIMESPEC64
1937 #
1938 # kernel 4.17-rc7 commit 8efd6894ff089adeeac7cb9f32125b85d963d1bc
1939 # fs: add timespec64_truncate()
1940 # kernel 4.18 commit 95582b00838837fc07e042979320caf917ce3fe6
1941 # inode timestamps switched to timespec64
1942 # kernel 4.19-rc2 commit 976516404ff3fab2a8caa8bd6f5efc1437fed0b8
1943 # y2038: remove unused time interfaces
1944 # ...
1945 #  timespec_trunc
1946 # ...
1947 # When inode times are timespec64 stop using the deprecated
1948 # time interfaces.
1949 #
1950 AC_DEFUN([LC_INODE_TIMESPEC64], [
1951 tmp_flags="$EXTRA_KCFLAGS"
1952 EXTRA_KCFLAGS="-Werror"
1953 LB_CHECK_COMPILE([if inode timestamps are struct timespec64],
1954 inode_timespec64, [
1955         #include <linux/fs.h>
1956 ],[
1957         struct inode *inode = NULL;
1958         struct timespec64 ts = {};
1959
1960         inode->i_atime = timespec64_trunc(ts, 1);
1961         (void)inode;
1962 ],[
1963         AC_DEFINE(HAVE_INODE_TIMESPEC64, 1,
1964                 [inode times are using timespec64])
1965 ])
1966 EXTRA_KCFLAGS="$tmp_flags"
1967 ]) # LC_INODE_TIMESPEC64
1968
1969 #
1970 # LC_XA_IS_VALUE
1971 # kernel 4.19-rc6 commit 3159f943aafdbacb2f94c38fdaadabf2bbde2a14
1972 # xarray: Replace exceptional entries
1973 # adds xa_is_value
1974 #
1975 AC_DEFUN([LC_XA_IS_VALUE], [
1976 LB_CHECK_COMPILE([xa_is_value exist],
1977 xa_is_value, [
1978         #include <linux/xarray.h>
1979 ],[
1980         xa_is_value(NULL);
1981 ],[
1982         AC_DEFINE(HAVE_XA_IS_VALUE, 1, [xa_is_value exist])
1983 ])
1984 ]) # LC_XA_IS_VALUE
1985
1986 #
1987 # LC___XA_SET_MARK
1988 #
1989 # kernel 4.20 commit v4.19-rc5-248-g9b89a0355144
1990 # xarray: Add XArray marks
1991 #
1992 AC_DEFUN([LC___XA_SET_MARK], [
1993 LB_CHECK_COMPILE([if '__xa_set_mark' exists],
1994 __xa_set_mark, [
1995         #include <linux/xarray.h>
1996         #include <linux/fs.h>
1997 ],[
1998         struct xarray *xa = NULL;
1999
2000         __xa_set_mark(xa, 0, PAGECACHE_TAG_DIRTY);
2001 ],[
2002         AC_DEFINE(HAVE___XA_SET_MARK, 1,
2003                 [__xa_set_mark exists])
2004 ])
2005 ]) # LC___XA_SET_MARK
2006
2007 #
2008 # LC_UAPI_LINUX_MOUNT_H
2009 #
2010 # kernel 4.20 commit e262e32d6bde0f77fb0c95d977482fc872c51996
2011 # vfs: Suppress MS_* flag defs within the kernel ...
2012 #
2013 AC_DEFUN([LC_UAPI_LINUX_MOUNT_H], [
2014 tmp_flags="$EXTRA_KCFLAGS"
2015 EXTRA_KCFLAGS="-Werror"
2016 LB_CHECK_COMPILE([if MS_RDONLY was moved to uapi/linux/mount.h],
2017 uapi_linux_mount, [
2018         #include <uapi/linux/mount.h>
2019 ],[
2020         int x = MS_RDONLY;
2021         (void)x;
2022 ],[
2023         AC_DEFINE(HAVE_UAPI_LINUX_MOUNT_H, 1,
2024                 [if MS_RDONLY was moved to uapi/linux/mount.h])
2025 ])
2026 EXTRA_KCFLAGS="$tmp_flags"
2027 ]) # LC_UAPI_LINUX_MOUNT_H
2028
2029 #
2030 # LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
2031 #
2032 # kernel 4.20 commit 1863d77f15da0addcd293a1719fa5d3ef8cde3ca
2033 # SUNRPC: Replace the cache_detail->hash_lock with a regular spinlock
2034 #
2035 # Now that the reader functions are all RCU protected, use a regular
2036 # spinlock rather than a reader/writer lock.
2037 #
2038 AC_DEFUN([LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK], [
2039 tmp_flags="$EXTRA_KCFLAGS"
2040 EXTRA_KCFLAGS="-Werror"
2041 LB_CHECK_COMPILE([if cache_detail->hash_lock is a spinlock],
2042 hash_lock_isa_spinlock_t, [
2043         #include <linux/sunrpc/cache.h>
2044 ],[
2045         spinlock_t *lock = &(((struct cache_detail *)0)->hash_lock);
2046         spin_lock(lock);
2047 ],[
2048         AC_DEFINE(HAVE_CACHE_HASH_SPINLOCK, 1,
2049                 [if cache_detail->hash_lock is a spinlock])
2050 ])
2051 EXTRA_KCFLAGS="$tmp_flags"
2052 ]) # LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
2053
2054 #
2055 # LC_HAS_LINUX_SELINUX_ENABLED
2056 #
2057 # kernel 5.1 commit 3d252529480c68bfd6a6774652df7c8968b28e41
2058 # SELinux: Remove unused selinux_is_enabled
2059 #
2060 AC_DEFUN([LC_HAS_LINUX_SELINUX_ENABLED], [
2061 tmp_flags="$EXTRA_KCFLAGS"
2062 EXTRA_KCFLAGS="-Werror"
2063 LB_CHECK_COMPILE([if linux/selinux.h exists],
2064 selinux_is_enabled, [
2065         #include <linux/selinux.h>
2066 ],[
2067         bool has_selinux = selinux_is_enabled();
2068         (void)has_selinux;
2069 ],[
2070         AC_DEFINE(HAVE_LINUX_SELINUX_IS_ENABLED, 1,
2071                 [if linux/selinux.h exists])
2072 ])
2073 EXTRA_KCFLAGS="$tmp_flags"
2074 ]) # LC_HAS_LINUX_SELINUX_ENABLED
2075
2076 #
2077 # LB_HAVE_BVEC_ITER_ALL
2078 #
2079 # kernel 5.1 commit 6dc4f100c175dd0511ae8674786e7c9006cdfbfa
2080 # block: allow bio_for_each_segment_all() to iterate over multi-page bvec
2081 #
2082 AC_DEFUN([LB_HAVE_BVEC_ITER_ALL], [
2083 tmp_flags="$EXTRA_KCFLAGS"
2084 EXTRA_KCFLAGS="-Werror"
2085 LB_CHECK_COMPILE([if bvec_iter_all exists for multi-page bvec iternation],
2086 ext4fs_dirhash, [
2087         #include <linux/bvec.h>
2088 ],[
2089         struct bvec_iter_all iter;
2090         (void)iter;
2091 ],[
2092         AC_DEFINE(HAVE_BVEC_ITER_ALL, 1,
2093                 [if bvec_iter_all exists for multi-page bvec iternation])
2094 ])
2095 EXTRA_KCFLAGS="$tmp_flags"
2096 ]) # LB_HAVE_BVEC_ITER_ALL
2097
2098 #
2099 # LC_ACCOUNT_PAGE_DIRTIED
2100 #
2101 # After 5.2 kernel page dirtied is not exported
2102 #
2103 AC_DEFUN([LC_ACCOUNT_PAGE_DIRTIED], [
2104 LB_CHECK_EXPORT([account_page_dirtied], [mm/page-writeback.c],
2105         [AC_DEFINE(HAVE_ACCOUNT_PAGE_DIRTIED_EXPORT, 1,
2106                         [account_page_dirtied is exported])])
2107 ]) # LC_ACCOUNT_PAGE_DIRTIED
2108
2109 #
2110 # LC_KEYRING_SEARCH_4ARGS
2111 #
2112 # Kernel 5.2 commit dcf49dbc8077
2113 # keys: Add a 'recurse' flag for keyring searches
2114 #
2115 AC_DEFUN([LC_KEYRING_SEARCH_4ARGS], [
2116 LB_CHECK_COMPILE([if 'keyring_search' has 4 args],
2117 keyring_search_4args, [
2118         #include <linux/key.h>
2119 ],[
2120         key_ref_t keyring;
2121         keyring_search(keyring, NULL, NULL, false);
2122 ],[
2123         AC_DEFINE(HAVE_KEYRING_SEARCH_4ARGS, 1,
2124                 [keyring_search has 4 args])
2125 ])
2126 ]) # LC_KEYRING_SEARCH_4ARGS
2127
2128 #
2129 # LC_BIO_BI_PHYS_SEGMENTS
2130 #
2131 # kernel 5.3-rc1 commit 14ccb66b3f585b2bc21e7256c96090abed5a512c
2132 # block: remove the bi_phys_segments field in struct bio
2133 #
2134 AC_DEFUN([LC_BIO_BI_PHYS_SEGMENTS], [
2135 tmp_flags="$EXTRA_KCFLAGS"
2136 EXTRA_KCFLAGS="-Werror"
2137 LB_CHECK_COMPILE([if struct bio has bi_phys_segments member],
2138 bye_bio_bi_phys_segments, [
2139         #include <linux/bio.h>
2140 ],[
2141         struct bio *bio = NULL;
2142         bio->bi_phys_segments++;
2143 ],[
2144         AC_DEFINE(HAVE_BIO_BI_PHYS_SEGMENTS, 1,
2145                 [struct bio has bi_phys_segments member])
2146 ])
2147 EXTRA_KCFLAGS="$tmp_flags"
2148 ]) # LC_BIO_BI_PHYS_SEGMENTS
2149
2150 #
2151 # LC_LM_COMPARE_OWNER_EXISTS
2152 #
2153 # kernel 5.3-rc3 commit f85d93385e9fe6886a751f647f6812a89bf6bee3
2154 # locks: Cleanup lm_compare_owner and lm_owner_key
2155 # removed lm_compare_owner
2156 #
2157 AC_DEFUN([LC_LM_COMPARE_OWNER_EXISTS], [
2158 tmp_flags="$EXTRA_KCFLAGS"
2159 EXTRA_KCFLAGS="-Werror"
2160 LB_CHECK_COMPILE([if lock_manager_operations has lm_compare_owner],
2161 lock_manager_ops_lm_compare_owner, [
2162         #include <linux/fs.h>
2163 ],[
2164         struct lock_manager_operations lm_ops;
2165         lm_ops.lm_compare_owner = NULL;
2166 ],[
2167         AC_DEFINE(HAVE_LM_COMPARE_OWNER, 1,
2168                 [lock_manager_operations has lm_compare_owner])
2169 ])
2170 EXTRA_KCFLAGS="$tmp_flags"
2171 ]) # LC_LM_COMPARE_OWNER_EXISTS
2172
2173 #
2174 # LC_FSCRYPT_SUPPORT
2175 #
2176 # 5.4 introduced fscrypt encryption policies v2
2177 #
2178 AC_DEFUN([LC_FSCRYPT_SUPPORT], [
2179 LB_CHECK_COMPILE([for fscrypt in-kernel support],
2180 fscrypt_support, [
2181         #define __FS_HAS_ENCRYPTION 0
2182         #include <linux/fscrypt.h>
2183 ],[
2184         fscrypt_ioctl_get_policy_ex(NULL, NULL);
2185 ],[
2186         has_fscrypt_support="yes"
2187 ])
2188 ]) # LC_FSCRYPT_SUPPORT
2189
2190 #
2191 # LC_PROG_LINUX
2192 #
2193 # Lustre linux kernel checks
2194 #
2195 AC_DEFUN([LC_PROG_LINUX], [
2196         AC_MSG_NOTICE([Lustre kernel checks
2197 ==============================================================================])
2198
2199         LC_CONFIG_PINGER
2200         LC_CONFIG_CHECKSUM
2201         LC_CONFIG_FLOCK
2202         LC_CONFIG_HEALTH_CHECK_WRITE
2203         LC_CONFIG_LRU_RESIZE
2204         LC_CONFIG_FHANDLE
2205         LC_CONFIG_GSS
2206
2207         LC_GLIBC_SUPPORT_FHANDLES
2208         LC_OPENSSL_SSK
2209         LC_OPENSSL_GETSEPOL
2210
2211         # 3.10
2212         LC_HAVE_PROJECT_QUOTA
2213
2214         # 3.11
2215         LC_INVALIDATE_RANGE
2216         LC_HAVE_DIR_CONTEXT
2217         LC_HAVE_DCOUNT
2218         LC_HAVE_DENTRY_D_U_D_ALIAS
2219         LC_HAVE_DENTRY_D_CHILD
2220         LC_PID_NS_FOR_CHILDREN
2221
2222         # 3.12
2223         LC_OLDSIZE_TRUNCATE_PAGECACHE
2224         LC_PTR_ERR_OR_ZERO_MISSING
2225         LC_KIOCB_KI_LEFT
2226
2227         # 3.13
2228         LC_VFS_RENAME_5ARGS
2229         LC_VFS_UNLINK_3ARGS
2230         LC_HAVE_D_IS_POSITIVE
2231
2232         # 3.14
2233         LC_HAVE_BVEC_ITER
2234         LC_HAVE_TRUNCATE_IPAGES_FINAL
2235         LC_IOPS_RENAME_WITH_FLAGS
2236         LC_IOP_SET_ACL
2237
2238         # 3.15
2239         LC_VFS_RENAME_6ARGS
2240
2241         # 3.16
2242         LC_DIRECTIO_USE_ITER
2243         LC_HAVE_IOV_ITER_INIT_DIRECTION
2244         LC_HAVE_IOV_ITER_TRUNCATE
2245         LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
2246
2247         # 3.17
2248         LC_HAVE_INTERVAL_BLK_INTEGRITY
2249         LC_KEY_MATCH_DATA
2250
2251         # 3.18
2252         LC_PERCPU_COUNTER_INIT
2253         LC_NFS_FILLDIR_USE_CTX
2254
2255         # 3.19
2256         LC_KIOCB_HAS_NBYTES
2257         LC_HAVE_DQUOT_QC_DQBLK
2258         LC_HAVE_AIO_COMPLETE
2259
2260         # 3.20
2261         LC_BACKING_DEV_INFO_REMOVAL
2262         LC_HAVE_BDI_CAP_MAP_COPY
2263
2264         # 4.1.0
2265         LC_IOV_ITER_RW
2266         LC_HAVE_SYNC_READ_WRITE
2267         LC_HAVE___BI_CNT
2268
2269         # 4.2
2270         LC_BIO_ENDIO_USES_ONE_ARG
2271         LC_SYMLINK_OPS_USE_NAMEIDATA
2272         LC_ACCOUNT_PAGE_DIRTIED_3ARGS
2273
2274         # 4.3
2275         LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
2276         LC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD
2277         LC_HAVE_CACHE_HEAD_HLIST
2278         LC_HAVE_XATTR_HANDLER_SIMPLIFIED
2279
2280         # 4.4
2281         LC_HAVE_LOCKS_LOCK_FILE_WAIT
2282         LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
2283         LC_HAVE_XATTR_HANDLER_NAME
2284         LC_HAVE_BI_OPF
2285         LC_HAVE_SUBMIT_BIO_2ARGS
2286         LC_HAVE_CLEAN_BDEV_ALIASES
2287
2288         # 4.5
2289         LC_HAVE_FILE_DENTRY
2290
2291         # 4.5
2292         LC_HAVE_INODE_LOCK
2293         LC_HAVE_IOP_GET_LINK
2294
2295         # 4.6
2296         LC_HAVE_IN_COMPAT_SYSCALL
2297         LC_HAVE_XATTR_HANDLER_INODE_PARAM
2298         LC_LOCK_PAGE_MEMCG
2299
2300         # 4.7
2301         LC_D_IN_LOOKUP
2302         LC_DIRECTIO_2ARGS
2303         LC_GENERIC_WRITE_SYNC_2ARGS
2304         LC_FOP_ITERATE_SHARED
2305
2306         # 4.8
2307         LC_HAVE_POSIX_ACL_VALID_USER_NS
2308         LC_FULL_NAME_HASH_3ARGS
2309         LC_STRUCT_POSIX_ACL_XATTR
2310         LC_IOP_XATTR
2311
2312         # 4.9
2313         LC_GROUP_INFO_GID
2314         LC_VFS_SETXATTR
2315         LC_POSIX_ACL_UPDATE_MODE
2316
2317         # 4.10
2318         LC_IOP_GENERIC_READLINK
2319         LC_HAVE_VM_FAULT_ADDRESS
2320
2321         # 4.11
2322         LC_INODEOPS_ENHANCED_GETATTR
2323         LC_VM_OPERATIONS_REMOVE_VMF_ARG
2324         LC_HAVE_KEY_USAGE_REFCOUNT
2325         LC_HAVE_CRYPTO_MAX_ALG_NAME_128
2326
2327         # 4.12
2328         LC_CURRENT_TIME
2329         LC_SUPER_BLOCK_S_UUID
2330         LC_SUPER_SETUP_BDI_NAME
2331         LC_BI_STATUS
2332
2333         # 4.13
2334         LC_BIO_INTEGRITY_ENABLED
2335
2336         # 4.14
2337         LC_PAGEVEC_INIT_ONE_PARAM
2338         LC_BI_BDEV
2339
2340         # 4.17
2341         LC_VM_FAULT_T
2342         LC_I_PAGES
2343
2344         # 4.18
2345         LC_INODE_TIMESPEC64
2346         LC_XA_IS_VALUE
2347
2348         # 4.20
2349         LC___XA_SET_MARK
2350         LC_UAPI_LINUX_MOUNT_H
2351         LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
2352
2353         # 5.1
2354         LC_HAS_LINUX_SELINUX_ENABLED
2355         LB_HAVE_BVEC_ITER_ALL
2356
2357         # 5.2
2358         LC_ACCOUNT_PAGE_DIRTIED
2359         LC_KEYRING_SEARCH_4ARGS
2360
2361         # 5.3
2362         LC_BIO_BI_PHYS_SEGMENTS
2363         LC_LM_COMPARE_OWNER_EXISTS
2364
2365         # kernel patch to extend integrity interface
2366         LC_BIO_INTEGRITY_PREP_FN
2367
2368         #
2369         AS_IF([test "x$enable_server" != xno], [
2370                 LC_STACK_SIZE
2371                 LC_QUOTA_CONFIG
2372         ])
2373         LC_POSIX_ACL_CONFIG
2374 ]) # LC_PROG_LINUX
2375
2376 #
2377 # LC_CONFIG_CLIENT
2378 #
2379 # Check whether to build the client side of Lustre
2380 #
2381 AC_DEFUN([LC_CONFIG_CLIENT], [
2382 AC_MSG_CHECKING([whether to build Lustre client support])
2383 AC_ARG_ENABLE([client],
2384         AC_HELP_STRING([--disable-client],
2385                 [disable Lustre client support]),
2386         [], [enable_client="yes"])
2387 AC_MSG_RESULT([$enable_client])
2388 ]) # LC_CONFIG_CLIENT
2389
2390 #
2391 # --enable-mpitests
2392 #
2393 AC_DEFUN([LB_CONFIG_MPITESTS], [
2394 AC_ARG_ENABLE([mpitests],
2395         AC_HELP_STRING([--enable-mpitests=<yes|no|mpicc wrapper>],
2396                        [include mpi tests]), [
2397                 enable_mpitests="yes"
2398                 case $enableval in
2399                 yes)
2400                         MPICC_WRAPPER="mpicc"
2401                         MPI_BIN=$(eval which $MPICC_WRAPPER | xargs dirname)
2402                         ;;
2403                 no)
2404                         enable_mpitests="no"
2405                         MPI_BIN=""
2406                         ;;
2407                 *)
2408                         MPICC_WRAPPER=$enableval
2409                         MPI_BIN=$(eval echo $MPICC_WRAPPER | xargs dirname)
2410                         ;;
2411                 esac
2412         ], [
2413                 enable_mpitests="yes"
2414                 MPICC_WRAPPER="mpicc"
2415                 MPI_BIN=$(eval which $MPICC_WRAPPER | xargs dirname)
2416         ])
2417
2418         if test "x$enable_mpitests" != "xno"; then
2419                 oldcc=$CC
2420                 CC=$MPICC_WRAPPER
2421                 AC_CACHE_CHECK([whether mpitests can be built],
2422                 lb_cv_mpi_tests, [AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2423                         #include <mpi.h>
2424                         int main(void) {
2425                                 int flag;
2426                                 MPI_Initialized(&flag);
2427                                 return 0;
2428                         }
2429                 ])], [lb_cv_mpi_tests="yes"], [lb_cv_mpi_tests="no"])
2430                 ])
2431                 enable_mpitests=$lb_cv_mpi_tests
2432                 CC=$oldcc
2433         fi
2434         AC_SUBST(MPI_BIN)
2435         AC_SUBST(MPICC_WRAPPER)
2436 ]) # LB_CONFIG_MPITESTS
2437
2438 #
2439 # LC_CONFIG_QUOTA
2440 #
2441 # whether to enable quota support global control
2442 #
2443 AC_DEFUN([LC_CONFIG_QUOTA], [
2444 AC_MSG_CHECKING([whether to enable quota support global control])
2445 AC_ARG_ENABLE([quota],
2446         AC_HELP_STRING([--enable-quota],
2447                 [enable quota support]),
2448         [], [enable_quota="yes"])
2449 AS_IF([test "x$enable_quota" = xyes],
2450         [AC_MSG_RESULT([yes])],
2451         [AC_MSG_RESULT([no])])
2452 ]) # LC_CONFIG_QUOTA
2453
2454 #
2455 # LC_QUOTA
2456 #
2457 AC_DEFUN([LC_QUOTA], [
2458 #check global
2459 LC_CONFIG_QUOTA
2460 #check for utils
2461 AS_IF([test "x$enable_quota" != xno -a "x$enable_utils" != xno], [
2462         AC_CHECK_HEADER([sys/quota.h],
2463                 [AC_DEFINE(HAVE_SYS_QUOTA_H, 1,
2464                         [Define to 1 if you have <sys/quota.h>.])],
2465                 [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
2466 ])
2467 ]) # LC_QUOTA
2468
2469 #
2470 # LC_OSD_ADDON
2471 #
2472 # configure support for optional OSD implementation
2473 #
2474 AC_DEFUN([LC_OSD_ADDON], [
2475 AC_MSG_CHECKING([whether to use OSD addon])
2476 AC_ARG_WITH([osd],
2477         AC_HELP_STRING([--with-osd=path],
2478                 [set path to optional osd]),
2479         [
2480         case "$with_osd" in
2481         no)
2482                 ENABLEOSDADDON=0
2483                 ;;
2484         *)
2485                 OSDADDON="$with_osd"
2486                 ENABLEOSDADDON=1
2487                 ;;
2488         esac
2489         ], [
2490                 ENABLEOSDADDON=0
2491         ])
2492 AS_IF([test $ENABLEOSDADDON -eq 0], [
2493         AC_MSG_RESULT([no])
2494         OSDADDON=""
2495 ], [
2496         OSDMODNAME=$(basename $OSDADDON)
2497         AS_IF([test -e $LUSTRE/$OSDMODNAME], [
2498                 AC_MSG_RESULT([can't link])
2499                 OSDADDON=""
2500         ], [ln -s $OSDADDON $LUSTRE/$OSDMODNAME], [
2501                 AC_MSG_RESULT([$OSDMODNAME])
2502                 OSDADDON="obj-m += $OSDMODNAME/"
2503         ], [
2504                 AC_MSG_RESULT([can't link])
2505                 OSDADDON=""
2506         ])
2507 ])
2508 AC_SUBST(OSDADDON)
2509 ]) # LC_OSD_ADDON
2510
2511 #
2512 # LC_CONFIG_CRYPTO
2513 #
2514 # Check whether to enable Lustre client crypto
2515 #
2516 AC_DEFUN([LC_CONFIG_CRYPTO], [
2517 AC_MSG_CHECKING([whether to enable Lustre client crypto])
2518 AC_ARG_ENABLE([crypto],
2519         AC_HELP_STRING([--enable-crypto],
2520                 [enable Lustre client crypto]),
2521         [], [enable_crypto="auto"])
2522 AS_IF([test "x$enable_crypto" != xno -a "x$enable_dist" = xno], [
2523         AC_MSG_RESULT(
2524         )
2525         LC_IS_ENCRYPTED
2526         LC_FSCRYPT_SUPPORT])
2527 AS_IF([test "x$has_fscrypt_support" = xyes], [
2528         AC_DEFINE(HAVE_LUSTRE_CRYPTO, 1, [Enable Lustre client crypto via in-kernel fscrypt])
2529         enable_crypto=yes],
2530         [AS_IF([test "x$has_is_encrypted" = xyes], [
2531               AC_DEFINE(HAVE_LUSTRE_CRYPTO, 1, [Enable Lustre client crypto via embedded llcrypt])
2532               AC_DEFINE(CONFIG_LL_ENCRYPTION, 1, [embedded llcrypt])
2533               enable_crypto=yes
2534               enable_llcrypt=yes], [
2535               AS_IF([test "x$enable_crypto" = xyes],
2536                     [AC_MSG_ERROR([Lustre client crypto cannot be enabled because of lack of encryption support in your kernel.])])
2537               AS_IF([test "x$enable_crypto" != xno -a "x$enable_dist" = xno],
2538                     [AC_MSG_WARN(Lustre client crypto cannot be enabled because of lack of encryption support in your kernel.)])
2539               enable_crypto=no])])
2540 AS_IF([test "x$enable_dist" != xno], [
2541         enable_crypto=yes
2542         enable_llcrypt=yes])
2543 AC_MSG_RESULT([$enable_crypto])
2544 ]) # LC_CONFIG_CRYPTO
2545
2546 #
2547 # LC_CONFIGURE
2548 #
2549 # other configure checks
2550 #
2551 AC_DEFUN([LC_CONFIGURE], [
2552 AC_MSG_NOTICE([Lustre core checks
2553 ==============================================================================])
2554
2555 AS_IF([test $target_cpu == "i686" -o $target_cpu == "x86_64"],
2556         [CFLAGS="$CFLAGS -Wall -Werror"])
2557
2558 # maximum MDS thread count
2559 LC_MDS_MAX_THREADS
2560
2561 # lustre/utils/gss/gss_util.c
2562 # lustre/utils/gss/gssd_proc.c
2563 # lustre/utils/gss/krb5_util.c
2564 # lustre/utils/llog_reader.c
2565 # lustre/utils/create_iam.c
2566 # lustre/utils/libiam.c
2567 AC_CHECK_HEADERS([netdb.h endian.h])
2568 AC_CHECK_FUNCS([gethostbyname])
2569
2570 # lustre/utils/llverfs.c lustre/utils/libmount_utils_ldiskfs.c
2571 AC_CHECK_HEADERS([ext2fs/ext2fs.h], [], [
2572         AS_IF([test "x$enable_utils" = xyes -a "x$enable_ldiskfs" = xyes], [
2573                 AC_MSG_ERROR([
2574 ext2fs.h not found. Please install e2fsprogs development package.
2575                 ])
2576         ])
2577 ])
2578
2579 # lustre/utils/lfs.c
2580 AS_IF([test "$enable_dist" = "no"], [
2581                 AC_CHECK_LIB([z], [crc32], [
2582                                  AC_CHECK_HEADER([zlib.h], [], [
2583                                                  AC_MSG_ERROR([zlib.h not found.])])
2584                                  ], [
2585                                  AC_MSG_ERROR([
2586                 zlib library not found. Please install zlib development package.])
2587                 ])
2588 ])
2589
2590 SELINUX=""
2591
2592 AC_CHECK_LIB([selinux], [is_selinux_enabled],
2593         [AC_CHECK_HEADERS([selinux/selinux.h],
2594                         [SELINUX="-lselinux"
2595                         AC_DEFINE([HAVE_SELINUX], 1,
2596                                 [support for selinux ])],
2597                         [AC_MSG_WARN([
2598
2599 No libselinux-devel package found, unable to build selinux enabled tools
2600 ])
2601 ])],
2602         [AC_MSG_WARN([
2603
2604 No selinux package found, unable to build selinux enabled tools
2605 ])
2606 ])
2607 AC_SUBST(SELINUX)
2608
2609 # Super safe df
2610 AC_MSG_CHECKING([whether to report minimum OST free space])
2611 AC_ARG_ENABLE([mindf],
2612         AC_HELP_STRING([--enable-mindf],
2613                 [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
2614         [], [enable_mindf="no"])
2615 AC_MSG_RESULT([$enable_mindf])
2616 AS_IF([test "$enable_mindf" = "yes"],
2617         [AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])])
2618
2619 AC_MSG_CHECKING([whether to randomly failing memory alloc])
2620 AC_ARG_ENABLE([fail_alloc],
2621         AC_HELP_STRING([--disable-fail-alloc],
2622                 [disable randomly alloc failure]),
2623         [], [enable_fail_alloc="yes"])
2624 AC_MSG_RESULT([$enable_fail_alloc])
2625 AS_IF([test "x$enable_fail_alloc" != xno],
2626         [AC_DEFINE([RANDOM_FAIL_ALLOC], 1,
2627                 [enable randomly alloc failure])])
2628
2629 AC_MSG_CHECKING([whether to check invariants (expensive cpu-wise)])
2630 AC_ARG_ENABLE([invariants],
2631         AC_HELP_STRING([--enable-invariants],
2632                 [enable invariant checking (cpu intensive)]),
2633         [], [enable_invariants="no"])
2634 AC_MSG_RESULT([$enable_invariants])
2635 AS_IF([test "x$enable_invariants" = xyes],
2636         [AC_DEFINE([CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK], 1,
2637                 [enable invariant checking])])
2638
2639 AC_MSG_CHECKING([whether to track references with lu_ref])
2640 AC_ARG_ENABLE([lu_ref],
2641         AC_HELP_STRING([--enable-lu_ref],
2642                 [enable lu_ref reference tracking code]),
2643         [], [enable_lu_ref="no"])
2644 AC_MSG_RESULT([$enable_lu_ref])
2645 AS_IF([test "x$enable_lu_ref" = xyes],
2646         [AC_DEFINE([USE_LU_REF], 1,
2647                 [enable lu_ref reference tracking code])])
2648
2649 AC_MSG_CHECKING([whether to enable page state tracking])
2650 AC_ARG_ENABLE([pgstate-track],
2651         AC_HELP_STRING([--enable-pgstate-track],
2652                 [enable page state tracking]),
2653         [], [enable_pgstat_track="no"])
2654 AC_MSG_RESULT([$enable_pgstat_track])
2655 AS_IF([test "x$enable_pgstat_track" = xyes],
2656         [AC_DEFINE([CONFIG_DEBUG_PAGESTATE_TRACKING], 1,
2657                 [enable page state tracking code])])
2658
2659 PKG_PROG_PKG_CONFIG
2660 AC_MSG_CHECKING([systemd unit file directory])
2661 AC_ARG_WITH([systemdsystemunitdir],
2662         [AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
2663                 [Directory for systemd service files])],
2664         [], [with_systemdsystemunitdir=auto])
2665 AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"],
2666         [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
2667         AS_IF([test "x$def_systemdsystemunitdir" = "x"],
2668                 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
2669                 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
2670                 with_systemdsystemunitdir=no],
2671         [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
2672 AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
2673         [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
2674 AC_MSG_RESULT([$with_systemdsystemunitdir])
2675
2676 AC_MSG_CHECKING([bash-completion directory])
2677 AC_ARG_WITH([bash-completion-dir],
2678         AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
2679                 [Install the bash auto-completion script in this directory.]),
2680         [],
2681         [with_bash_completion_dir=yes])
2682 AS_IF([test "x$with_bash_completion_dir" = "xyes"], [
2683         BASH_COMPLETION_DIR="`pkg-config --variable=completionsdir bash-completion`"
2684         AS_IF([test "x$BASH_COMPLETION_DIR" = "x"], [
2685                 [BASH_COMPLETION_DIR="$datadir/bash-completion/completions"]
2686         ])
2687 ], [
2688         BASH_COMPLETION_DIR="$with_bash_completion_dir"
2689 ])
2690 AC_SUBST([BASH_COMPLETION_DIR])
2691 AC_MSG_RESULT([$BASH_COMPLETION_DIR])
2692 ]) # LC_CONFIGURE
2693
2694 #
2695 # LC_CONDITIONALS
2696 #
2697 # AM_CONDITIONALS for lustre
2698 #
2699 AC_DEFUN([LC_CONDITIONALS], [
2700 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
2701 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
2702 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
2703 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
2704 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
2705 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
2706 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
2707 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
2708 AM_CONDITIONAL(GSS_SSK, test x$enable_ssk = xyes)
2709 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
2710 AM_CONDITIONAL(HAVE_SYSTEMD, test "x$with_systemdsystemunitdir" != "xno")
2711 AM_CONDITIONAL(ENABLE_BASH_COMPLETION, test "x$with_bash_completion_dir" != "xno")
2712 AM_CONDITIONAL(XATTR_HANDLER, test "x$lb_cv_compile_xattr_handler_flags" = xyes)
2713 AM_CONDITIONAL(SELINUX, test "$SELINUX" = "-lselinux")
2714 AM_CONDITIONAL(GETSEPOL, test x$enable_getsepol = xyes)
2715 AM_CONDITIONAL(LLCRYPT, test x$enable_llcrypt = xyes)
2716 ]) # LC_CONDITIONALS
2717
2718 #
2719 # LC_CONFIG_FILES
2720 #
2721 # files that should be generated with AC_OUTPUT
2722 #
2723 AC_DEFUN([LC_CONFIG_FILES],
2724 [AC_CONFIG_FILES([
2725 lustre/Makefile
2726 lustre/autoMakefile
2727 lustre/autoconf/Makefile
2728 lustre/conf/Makefile
2729 lustre/conf/resource/Makefile
2730 lustre/contrib/Makefile
2731 lustre/doc/Makefile
2732 lustre/include/Makefile
2733 lustre/include/lustre/Makefile
2734 lustre/include/uapi/linux/lustre/Makefile
2735 lustre/kernel_patches/targets/4.18-rhel8.1.target
2736 lustre/kernel_patches/targets/4.18-rhel8.target
2737 lustre/kernel_patches/targets/3.10-rhel7.8.target
2738 lustre/kernel_patches/targets/3.10-rhel7.7.target
2739 lustre/kernel_patches/targets/3.10-rhel7.6.target
2740 lustre/kernel_patches/targets/3.10-rhel7.5.target
2741 lustre/kernel_patches/targets/4.14-rhel7.5.target
2742 lustre/kernel_patches/targets/4.14-rhel7.6.target
2743 lustre/kernel_patches/targets/3.0-sles11.target
2744 lustre/kernel_patches/targets/3.0-sles11sp3.target
2745 lustre/kernel_patches/targets/3.0-sles11sp4.target
2746 lustre/kernel_patches/targets/3.12-sles12.target
2747 lustre/kernel_patches/targets/4.4-sles12.target
2748 lustre/kernel_patches/targets/4.4-sles12sp3.target
2749 lustre/kernel_patches/targets/4.12-sles12sp4.target
2750 lustre/kernel_patches/targets/4.12-sles15sp1.target
2751 lustre/kernel_patches/targets/3.x-fc18.target
2752 lustre/ldlm/Makefile
2753 lustre/fid/Makefile
2754 lustre/fid/autoMakefile
2755 lustre/llite/Makefile
2756 lustre/llite/autoMakefile
2757 lustre/lov/Makefile
2758 lustre/lov/autoMakefile
2759 lustre/mdc/Makefile
2760 lustre/mdc/autoMakefile
2761 lustre/lmv/Makefile
2762 lustre/lmv/autoMakefile
2763 lustre/lfsck/Makefile
2764 lustre/lfsck/autoMakefile
2765 lustre/mdt/Makefile
2766 lustre/mdt/autoMakefile
2767 lustre/mdd/Makefile
2768 lustre/mdd/autoMakefile
2769 lustre/fld/Makefile
2770 lustre/fld/autoMakefile
2771 lustre/obdclass/Makefile
2772 lustre/obdclass/autoMakefile
2773 lustre/obdecho/Makefile
2774 lustre/obdecho/autoMakefile
2775 lustre/ofd/Makefile
2776 lustre/ofd/autoMakefile
2777 lustre/osc/Makefile
2778 lustre/osc/autoMakefile
2779 lustre/ost/Makefile
2780 lustre/ost/autoMakefile
2781 lustre/osd-ldiskfs/Makefile
2782 lustre/osd-ldiskfs/autoMakefile
2783 lustre/osd-zfs/Makefile
2784 lustre/osd-zfs/autoMakefile
2785 lustre/mgc/Makefile
2786 lustre/mgc/autoMakefile
2787 lustre/mgs/Makefile
2788 lustre/mgs/autoMakefile
2789 lustre/target/Makefile
2790 lustre/ptlrpc/Makefile
2791 lustre/ptlrpc/autoMakefile
2792 lustre/ptlrpc/gss/Makefile
2793 lustre/ptlrpc/gss/autoMakefile
2794 lustre/quota/Makefile
2795 lustre/quota/autoMakefile
2796 lustre/scripts/Makefile
2797 lustre/scripts/systemd/Makefile
2798 lustre/tests/Makefile
2799 lustre/tests/mpi/Makefile
2800 lustre/tests/kernel/Makefile
2801 lustre/tests/kernel/autoMakefile
2802 lustre/utils/Makefile
2803 lustre/utils/gss/Makefile
2804 lustre/osp/Makefile
2805 lustre/osp/autoMakefile
2806 lustre/lod/Makefile
2807 lustre/lod/autoMakefile
2808 ])
2809 ]) # LC_CONFIG_FILES