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