Whamcloud - gitweb
LU-17504 build: fix array-index-out-of-bounds warning
[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="-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_STACK_SIZE
96 #
97 # Ensure the stack size is at least 8k in Lustre server (all kernels)
98 #
99 AC_DEFUN([LC_SRC_STACK_SIZE], [
100         LB2_LINUX_TEST_SRC([stack_size_8k], [
101                 #include <linux/thread_info.h>
102         ], [
103                 #if THREAD_SIZE < 8192
104                 #error "stack size < 8192"
105                 #endif
106         ])
107 ])
108 AC_DEFUN([LC_STACK_SIZE], [
109         LB2_MSG_LINUX_TEST_RESULT([if stack size is at least 8k],
110         [stack_size_8k], [],[
111                 AC_MSG_ERROR(
112                 [Lustre requires that Linux is configured with at least a 8KB stack.])
113         ])
114 ]) # LC_STACK_SIZE
115
116 #
117 # LC_MDS_MAX_THREADS
118 #
119 # Allow the user to set the MDS thread upper limit
120 #
121 AC_DEFUN([LC_MDS_MAX_THREADS], [
122 AC_MSG_CHECKING([for maximum number of MDS threads])
123 AC_ARG_WITH([mds_max_threads],
124         AS_HELP_STRING([--with-mds-max-threads=count],
125                 [maximum threads available on the MDS: (default=512)]),
126         [AC_DEFINE_UNQUOTED(MDS_MAX_THREADS, $with_mds_max_threads,
127                 [maximum number of MDS threads])])
128 AC_MSG_RESULT([$with_mds_max_threads])
129 ]) # LC_MDS_MAX_THREADS
130
131 #
132 # LC_CONFIG_PINGER
133 #
134 # the pinger is temporary, until we have the recovery node in place
135 #
136 AC_DEFUN([LC_CONFIG_PINGER], [
137 AC_MSG_CHECKING([whether to enable Lustre pinger support])
138 AC_ARG_ENABLE([pinger],
139         AS_HELP_STRING([--disable-pinger],
140                 [disable recovery pinger support]),
141         [], [enable_pinger="yes"])
142 AC_MSG_RESULT([$enable_pinger])
143 AS_IF([test "x$enable_pinger" != xno], [
144         AC_DEFINE(CONFIG_LUSTRE_FS_PINGER, 1, [Use the Pinger])
145         AC_SUBST(ENABLE_PINGER, yes)
146 ], [
147         AC_SUBST(ENABLE_PINGER, no)
148 ])
149 ]) # LC_CONFIG_PINGER
150
151 #
152 # LC_CONFIG_CHECKSUM
153 #
154 # do checksum of bulk data between client and OST
155 #
156 AC_DEFUN([LC_CONFIG_CHECKSUM], [
157 AC_MSG_CHECKING([whether to enable data checksum support])
158 AC_ARG_ENABLE([checksum],
159         AS_HELP_STRING([--disable-checksum],
160                 [disable data checksum support]),
161         [], [enable_checksum="yes"])
162 AC_MSG_RESULT([$enable_checksum])
163 AS_IF([test "x$enable_checksum" != xno], [
164         AC_DEFINE(CONFIG_ENABLE_CHECKSUM, 1, [do data checksums])
165         AC_SUBST(ENABLE_CHECKSUM, yes)
166 ], [
167         AC_SUBST(ENABLE_CHECKSUM, no)
168 ])
169 ]) # LC_CONFIG_CHECKSUM
170
171 #
172 # LC_CONFIG_FLOCK
173 #
174 # enable distributed flock by default
175 #
176 AC_DEFUN([LC_CONFIG_FLOCK], [
177 AC_MSG_CHECKING([whether to enable flock by default])
178 AC_ARG_ENABLE([flock],
179         AS_HELP_STRING([--disable-flock],
180                 [disable flock by default]),
181         [], [enable_flock="yes"])
182 AC_MSG_RESULT([$enable_flock])
183 AS_IF([test "x$enable_flock" != xno], [
184         AC_DEFINE(CONFIG_ENABLE_FLOCK, 1, [enable flock by default])
185         AC_SUBST(ENABLE_FLOCK, yes)
186 ], [
187         AC_SUBST(ENABLE_FLOCK, no)
188 ])
189 ]) # LC_CONFIG_FLOCK
190
191 #
192 # LC_CONFIG_LRU_RESIZE
193 #
194 AC_DEFUN([LC_CONFIG_LRU_RESIZE], [
195 AC_MSG_CHECKING([whether to enable lru self-adjusting])
196 AC_ARG_ENABLE([lru_resize],
197         AS_HELP_STRING([--enable-lru-resize],
198                 [enable lru resize support]),
199         [], [enable_lru_resize="yes"])
200 AC_MSG_RESULT([$enable_lru_resize])
201 AS_IF([test "x$enable_lru_resize" != xno], [
202         AC_DEFINE(HAVE_LRU_RESIZE_SUPPORT, 1, [Enable lru resize support])
203         AC_SUBST(ENABLE_LRU_RESIZE, yes)
204 ], [
205         AC_SUBST(ENABLE_LRU_RESIZE, no)
206 ])
207 ]) # LC_CONFIG_LRU_RESIZE
208
209 #
210 # LC_CONFIG_QUOTA
211 #
212 # Quota support. The kernel must support CONFIG_QUOTA.
213 #
214 AC_DEFUN([LC_SRC_CONFIG_QUOTA], [
215         LB2_SRC_CHECK_CONFIG_IM([QUOTA])
216 ])
217 AC_DEFUN([LC_CONFIG_QUOTA], [
218         LB2_TEST_CHECK_CONFIG_IM([QUOTA],[],[AC_MSG_ERROR(
219 [Lustre quota requires that CONFIG_QUOTA is enabled in your kernel.])])
220 ]) # LC_CONFIG_QUOTA
221
222 #
223 # LC_CONFIG_FHANDLE
224 #
225 # fhandle kernel support for open_by_handle_at() and name_to_handle_at()
226 # system calls. The kernel must support CONFIG_FHANDLE.
227 #
228 AC_DEFUN([LC_SRC_CONFIG_FHANDLE], [
229         LB2_SRC_CHECK_CONFIG_IM([FHANDLE])
230 ])
231 AC_DEFUN([LC_CONFIG_FHANDLE], [
232         LB2_TEST_CHECK_CONFIG_IM([FHANDLE],[],[AC_MSG_ERROR(
233 [Lustre fid handling requires that CONFIG_FHANDLE is enabled in your kernel.])])
234 ]) # LC_CONFIG_FHANDLE
235
236 #
237 # LC_POSIX_ACL_CONFIG
238 #
239 # POSIX ACL support.
240 #
241 AC_DEFUN([LC_SRC_POSIX_ACL_CONFIG], [
242         LB2_SRC_CHECK_CONFIG_IM([FS_POSIX_ACL])
243 ])
244 AC_DEFUN([LC_POSIX_ACL_CONFIG], [
245         LB2_TEST_CHECK_CONFIG_IM([FS_POSIX_ACL],
246                 [AC_DEFINE(CONFIG_LUSTRE_FS_POSIX_ACL, 1, [Enable POSIX acl])],
247                 [])
248 ]) # LC_POSIX_ACL_CONFIG
249
250 # CRYPTO_MD5 check and warn only if GSS is not disabled.
251
252 #
253 # LC_CONFIG_GSS_KEYRING
254 #
255 # default 'auto', tests for dependencies, if found, enables;
256 # only called if gss is enabled
257 #
258 AC_DEFUN([LC_CONFIG_GSS_KEYRING], [
259 AC_MSG_CHECKING([whether to enable gss keyring backend])
260 AC_ARG_ENABLE([gss_keyring],
261         [AS_HELP_STRING([--disable-gss-keyring],
262                 [disable gss keyring backend])],
263         [], [AS_IF([test "x$enable_gss" != xno], [
264                         enable_gss_keyring="yes"], [
265                         enable_gss_keyring="auto"])])
266 AC_MSG_RESULT([$enable_gss_keyring])
267 AS_IF([test "x$enable_gss_keyring" != xno], [
268         LB_CHECK_CONFIG_IM([KEYS], [], [
269                 gss_keyring_conf_test="fail"
270                 AC_MSG_WARN([GSS keyring backend requires that CONFIG_KEYS be enabled in your kernel.])])
271
272         AC_CHECK_LIB([keyutils], [keyctl_search], [], [
273                 gss_keyring_conf_test="fail"
274                 AC_MSG_WARN([GSS keyring backend requires libkeyutils])])
275
276         AS_IF([test "x$gss_keyring_conf_test" != xfail], [
277                 AC_DEFINE([HAVE_GSS_KEYRING], [1],
278                         [Define this if you enable gss keyring backend])
279                 enable_gss_keyring="yes"
280         ], [
281                 AS_IF([test "x$enable_gss_keyring" = xyes], [
282                         AC_MSG_ERROR([Cannot enable gss_keyring. See above for details.])
283                 ])
284                 enable_ssk="no"
285         ])
286 ], [
287         enable_ssk="no"
288 ])
289 ]) # LC_CONFIG_GSS_KEYRING
290
291 #
292 # LC_KEY_TYPE_INSTANTIATE_2ARGS
293 #
294 # rhel7 key_type->instantiate takes 2 args (struct key, struct key_preparsed_payload)
295 #
296 AC_DEFUN([LC_SRC_KEY_TYPE_INSTANTIATE_2ARGS], [
297         LB2_LINUX_TEST_SRC([key_type_instantiate_2args], [
298                 #include <linux/key-type.h>
299         ],[
300                 ((struct key_type *)0)->instantiate(0, NULL);
301         ])
302 ])
303 AC_DEFUN([LC_KEY_TYPE_INSTANTIATE_2ARGS], [
304         LB2_MSG_LINUX_TEST_RESULT([if 'key_type->instantiate' has two args],
305         [key_type_instantiate_2args], [
306                 AC_DEFINE(HAVE_KEY_TYPE_INSTANTIATE_2ARGS, 1,
307                         [key_type->instantiate has two args])
308         ])
309 ]) # LC_KEY_TYPE_INSTANTIATE_2ARGS
310
311 #
312 # LC_CONFIG_SUNRPC
313 #
314 AC_DEFUN([LC_CONFIG_SUNRPC], [
315 LB_CHECK_CONFIG_IM([SUNRPC], [], [
316         AS_IF([test "x$sunrpc_required" = xyes], [
317                 AC_MSG_ERROR([
318
319 kernel SUNRPC support is required by using GSS.
320 ])
321         ])])
322 ]) # LC_CONFIG_SUNRPC
323
324 #
325 # LC_CONFIG_GSS (default 'auto' (tests for dependencies, if found, enables))
326 #
327 # Build gss and related tools of Lustre. Currently both kernel and user space
328 # parts are depend on linux platform.
329 #
330 AC_DEFUN([LC_CONFIG_GSS], [
331 AC_MSG_CHECKING([whether to enable gss support])
332 AC_ARG_ENABLE([gss],
333         [AS_HELP_STRING([--enable-gss], [enable gss support])],
334         [], [enable_gss="auto"])
335 AC_MSG_RESULT([$enable_gss])
336
337 AC_ARG_VAR([TEST_JOBS],
338     [simultaneous jobs during configure (defaults to $(nproc))])
339 if test "x$ac_cv_env_TEST_JOBS_set" != "xset"; then
340         TEST_JOBS=${TEST_JOBS:-$(nproc)}
341 fi
342 AC_SUBST(TEST_JOBS)
343
344 AC_ARG_VAR([TEST_DIR],
345     [location of temporary parallel configure tests (defaults to $PWD/lb2)])
346         TEST_DIR=${TEST_DIR:-${ac_pwd}/_lpb}
347 AC_SUBST(TEST_DIR)
348
349 AS_IF([test "x$enable_gss" != xno], [
350         LC_CONFIG_GSS_KEYRING
351
352         sunrpc_required=$enable_gss
353         LC_CONFIG_SUNRPC
354         sunrpc_required="no"
355
356         require_krb5=$enable_gss
357         AC_KERBEROS_V5
358         require_krb5="no"
359
360         AS_IF([test -n "$KRBDIR"], [
361                 gss_conf_test="success"
362         ], [
363                 gss_conf_test="failure"
364         ])
365
366         AS_IF([test "x$gss_conf_test" = xsuccess && test "x$enable_gss" != xno], [
367                 AC_DEFINE([HAVE_GSS], [1], [Define this is if you enable gss])
368                 enable_gss="yes"
369         ], [
370                 enable_gss_keyring="no"
371                 enable_gss="no"
372         ])
373
374         AS_IF([test "x$enable_ssk" != xno], [
375                 enable_ssk=$enable_gss
376         ])
377 ], [
378         enable_gss_keyring="no"
379 ])
380 ]) # LC_CONFIG_GSS
381
382 # LC_OPENSSL_HMAC
383 #
384 # OpenSSL 1.0+ return int for HMAC functions but older SLES11 versions do not
385 AC_DEFUN([LC_OPENSSL_HMAC], [
386 has_hmac_functions="no"
387 saved_flags="$CFLAGS"
388 CFLAGS="-Werror"
389 AC_MSG_CHECKING([whether OpenSSL has HMAC_Init_ex])
390 AS_IF([test "x$enable_ssk" != xno], [
391 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
392         #include <openssl/hmac.h>
393         #include <openssl/evp.h>
394
395         int main(void) {
396                 int rc;
397                 rc = HMAC_Init_ex(NULL, "test", 4, EVP_md_null(), NULL);
398                 return rc;
399         }
400 ])],[
401         has_hmac_functions="yes"
402 ])
403 ])
404 AC_MSG_RESULT([$has_hmac_functions])
405 CFLAGS="$saved_flags"
406 ]) # LC_OPENSSL_HMAC
407
408 # LC_OPENSSL_FIPS
409 #
410 # OpenSSL 1.0+ can be built with or without FIPS support
411 AC_DEFUN([LC_OPENSSL_FIPS], [
412 has_fips_support="no"
413 saved_flags="$CFLAGS"
414 CFLAGS="-Werror"
415 AC_MSG_CHECKING([whether OpenSSL has FIPS_mode])
416 AS_IF([test "x$enable_ssk" != xno], [
417 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
418         #include <openssl/dh.h>
419         #include <openssl/dsa.h>
420         #include <openssl/evp.h>
421         #include <openssl/hmac.h>
422         #include <openssl/fips.h>
423
424         int main(void) {
425                 int rc;
426                 rc = FIPS_mode();
427                 return rc;
428         }
429 ])],[
430         AC_DEFINE(HAVE_OPENSSL_FIPS, 1, [OpenSSL FIPS_mode])
431         has_fips_support="yes"
432 ])
433 ])
434 AC_MSG_RESULT([$has_fips_support])
435 CFLAGS="$saved_flags"
436 ]) # LC_OPENSSL_FIPS
437
438 # LC_OPENSSL_EVP_PKEY
439 #
440 # OpenSSL 3.0 introduces EVP_PKEY_get_params
441 AC_DEFUN([LC_OPENSSL_EVP_PKEY], [
442 has_evp_pkey="no"
443 saved_flags="$CFLAGS"
444 CFLAGS="-Werror"
445 AC_MSG_CHECKING([whether OpenSSL has EVP_PKEY_get_params])
446 AS_IF([test "x$enable_ssk" != xno], [
447 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
448         #include <openssl/evp.h>
449
450         int main(void) {
451                 OSSL_PARAM *params;
452
453                 int rc = EVP_PKEY_get_params(NULL, params);
454                 return rc;
455         }
456 ])],[
457         AC_DEFINE(HAVE_OPENSSL_EVP_PKEY, 1, [OpenSSL EVP_PKEY_get_params])
458         has_evp_pkey="yes"
459 ])
460 ])
461 CFLAGS="$saved_flags"
462 AC_MSG_RESULT([$has_evp_pkey])
463 ]) # LC_OPENSSL_EVP_PKEY
464
465 #
466 # LC_OPENSSL_SSK
467 #
468 # Check whether to enable Lustre client crypto
469 #
470 AC_DEFUN([LC_OPENSSL_SSK], [
471 AS_IF([test "x$enable_ssk" != xno], [
472         LC_OPENSSL_HMAC
473         LC_OPENSSL_FIPS
474         LC_OPENSSL_EVP_PKEY
475 ])
476 AS_IF([test "x$has_hmac_functions" = xyes -o "x$has_evp_pkey" = xyes], [
477         AC_DEFINE(HAVE_OPENSSL_SSK, 1, [OpenSSL HMAC functions needed for SSK])
478 ], [
479         enable_ssk="no"
480 ])
481 AC_MSG_CHECKING([whether OpenSSL has functions needed for SSK])
482 AC_MSG_RESULT([$enable_ssk])
483 ]) # LC_OPENSSL_SSK
484
485 # LC_OPENSSL_GETSEPOL
486 #
487 # OpenSSL is needed for l_getsepol
488 AC_DEFUN([LC_OPENSSL_GETSEPOL], [
489 saved_flags="$CFLAGS"
490 CFLAGS="-Werror"
491 AC_MSG_CHECKING([whether openssl-devel is present])
492 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
493         #include <openssl/evp.h>
494
495         int main(void) {
496                 EVP_MD_CTX *mdctx = EVP_MD_CTX_create();
497                 (void) mdctx;
498         }
499 ])],[
500         AC_DEFINE(HAVE_OPENSSL_GETSEPOL, 1, [openssl-devel is present])
501         enable_getsepol="yes"
502
503 ],[
504         enable_getsepol="no"
505         AC_MSG_WARN([
506
507 No openssl-devel headers found, unable to build l_getsepol and SELinux status checking
508 ])
509 ])
510 AC_MSG_RESULT([$enable_getsepol])
511 CFLAGS="$saved_flags"
512 ]) # LC_OPENSSL_GETSEPOL
513
514 # LC_GCONFIG_GETSEPOL
515 AC_DEFUN([LC_CONFIG_GETSEPOL], [
516 AC_ARG_ENABLE([l_getsepol], [AS_HELP_STRING([--disable-l_getsepol],
517     [build the l_getsepol utility])], [config_getsepol="no"],
518     [config_getsepol="yes"])
519 AC_MSG_CHECKING([whether to build l_getsepol])
520 AC_MSG_RESULT([$config_getsepol])
521 ]) # LC_GETSEPOL
522
523 # LC_HAVE_LIBAIO
524 AC_DEFUN([LC_HAVE_LIBAIO], [
525         AC_CHECK_HEADER([libaio.h],
526                 enable_libaio="yes",
527                 AC_MSG_WARN([libaio is not installed on the system]))
528 ]) # LC_HAVE_LIBAIO
529
530 #
531 # LC_INVALIDATE_RANGE
532 #
533 # 3.11 invalidatepage requires the length of the range to invalidate
534 #
535 AC_DEFUN([LC_SRC_INVALIDATE_RANGE], [
536         LB2_LINUX_TEST_SRC([address_space_ops_invalidatepage_3args], [
537                 #include <linux/fs.h>
538         ],[
539                 struct address_space_operations a_ops;
540                 a_ops.invalidatepage(NULL, 0, 0);
541         ])
542 ])
543 AC_DEFUN([LC_INVALIDATE_RANGE], [
544         LB2_MSG_LINUX_TEST_RESULT(
545         [if 'address_space_operations.invalidatepage' requires 3 arguments],
546         [address_space_ops_invalidatepage_3args], [
547                 AC_DEFINE(HAVE_INVALIDATE_RANGE, 1,
548                         [address_space_operations.invalidatepage needs 3 arguments])
549         ])
550 ]) # LC_INVALIDATE_RANGE
551
552 #
553 # LC_HAVE_DIR_CONTEXT
554 #
555 # 3.11 readdir now takes the new struct dir_context
556 #
557 AC_DEFUN([LC_SRC_HAVE_DIR_CONTEXT], [
558         LB2_LINUX_TEST_SRC([dir_context], [
559                 #include <linux/fs.h>
560         ],[
561         #ifdef FMODE_KABI_ITERATE
562         #error "back to use readdir in kabi_extand mode"
563         #else
564                 struct dir_context ctx;
565
566                 ctx.pos = 0;
567         #endif
568         ])
569 ])
570 AC_DEFUN([LC_HAVE_DIR_CONTEXT], [
571         LB2_MSG_LINUX_TEST_RESULT([if 'dir_context' exist],
572         [dir_context], [
573                 AC_DEFINE(HAVE_DIR_CONTEXT, 1, [dir_context exist])
574         ])
575 ]) # LC_HAVE_DIR_CONTEXT
576
577 #
578 # LC_D_COMPARE_5ARGS
579 #
580 # 3.11 dentry_operations.d_compare() taken 5 arguments.
581 #
582 AC_DEFUN([LC_SRC_D_COMPARE_5ARGS], [
583         LB2_LINUX_TEST_SRC([d_compare_5args], [
584                 #include <linux/dcache.h>
585         ],[
586                 ((struct dentry_operations*)0)->d_compare(NULL,NULL,0,NULL,NULL);
587         ])
588 ])
589 AC_DEFUN([LC_D_COMPARE_5ARGS], [
590         LB2_MSG_LINUX_TEST_RESULT([if 'd_compare' taken 5 arguments],
591         [d_compare_5args], [
592                 AC_DEFINE(HAVE_D_COMPARE_5ARGS, 1,
593                         [d_compare need 5 arguments])
594         ])
595 ]) # LC_D_COMPARE_5ARGS
596
597 #
598 # LC_HAVE_DCOUNT
599 #
600 # 3.11 need to access d_count to get dentry reference count
601 #
602 AC_DEFUN([LC_SRC_HAVE_DCOUNT], [
603         LB2_LINUX_TEST_SRC([d_count], [
604                 #include <linux/dcache.h>
605         ],[
606                 struct dentry de = { };
607                 int count;
608
609                 count = d_count(&de);
610         ])
611 ])
612 AC_DEFUN([LC_HAVE_DCOUNT], [
613         LB2_MSG_LINUX_TEST_RESULT([if 'd_count' exists],
614         [d_count], [
615                 AC_DEFINE(HAVE_D_COUNT, 1, [d_count exist])
616         ])
617 ]) # LC_HAVE_DCOUNT
618
619 #
620 # LC_PID_NS_FOR_CHILDREN
621 #
622 # 3.11 replaces pid_ns by pid_ns_for_children in struct nsproxy
623 #
624 AC_DEFUN([LC_SRC_PID_NS_FOR_CHILDREN], [
625         LB2_LINUX_TEST_SRC([pid_ns_for_children], [
626                 #include <linux/nsproxy.h>
627         ],[
628                 struct nsproxy ns;
629                 ns.pid_ns_for_children = NULL;
630         ])
631 ])
632 AC_DEFUN([LC_PID_NS_FOR_CHILDREN], [
633         LB2_MSG_LINUX_TEST_RESULT([if 'struct nsproxy' has 'pid_ns_for_children'],
634         [pid_ns_for_children], [
635                 AC_DEFINE(HAVE_PID_NS_FOR_CHILDREN, 1,
636                           ['struct nsproxy' has 'pid_ns_for_children'])
637         ])
638 ]) # LC_PID_NS_FOR_CHILDREN
639
640 #
641 # LC_OLDSIZE_TRUNCATE_PAGECACHE
642 #
643 # 3.12 truncate_pagecache without oldsize parameter
644 #
645 AC_DEFUN([LC_SRC_OLDSIZE_TRUNCATE_PAGECACHE], [
646         LB2_LINUX_TEST_SRC([truncate_pagecache_old_size], [
647                 #include <linux/mm.h>
648         ],[
649                 truncate_pagecache(NULL, 0, 0);
650         ])
651 ])
652 AC_DEFUN([LC_OLDSIZE_TRUNCATE_PAGECACHE], [
653         LB2_MSG_LINUX_TEST_RESULT([if 'truncate_pagecache' with 'old_size' parameter],
654         [truncate_pagecache_old_size], [
655                 AC_DEFINE(HAVE_OLDSIZE_TRUNCATE_PAGECACHE, 1,
656                         [with oldsize])
657         ])
658 ]) # LC_OLDSIZE_TRUNCATE_PAGECACHE
659
660 #
661 # LC_PTR_ERR_OR_ZERO
662 #
663 # For some reason SLES11SP4 is missing the PTR_ERR_OR_ZERO macro
664 # It was added to linux kernel 3.12
665 #
666 AC_DEFUN([LC_SRC_PTR_ERR_OR_ZERO_MISSING], [
667         LB2_LINUX_TEST_SRC([is_err_or_null], [
668                 #include <linux/err.h>
669         ],[
670                 if (PTR_ERR_OR_ZERO(NULL)) return 0;
671         ])
672 ])
673 AC_DEFUN([LC_PTR_ERR_OR_ZERO_MISSING], [
674         LB2_MSG_LINUX_TEST_RESULT([if 'PTR_ERR_OR_ZERO' is missing],
675         [is_err_or_null], [
676                 AC_DEFINE(HAVE_PTR_ERR_OR_ZERO, 1,
677                         ['PTR_ERR_OR_ZERO' exist])
678         ])
679 ]) # LC_PTR_ERR_OR_ZERO_MISSING
680
681 #
682 # LC_HAVE_DENTRY_D_U_D_ALIAS
683 #
684 # 3.11 kernel moved d_alias to the union d_u in struct dentry
685 #
686 # Some distros move d_alias to d_u but it is still a struct list
687 #
688 AC_DEFUN([LC_SRC_HAVE_DENTRY_D_U_D_ALIAS_LIST], [
689         LB2_LINUX_TEST_SRC([d_alias_list], [
690                 #include <linux/list.h>
691                 #include <linux/dcache.h>
692         ],[
693                 struct dentry de;
694                 INIT_LIST_HEAD(&de.d_u.d_alias);
695         ])
696 ])
697 AC_DEFUN([LC_HAVE_DENTRY_D_U_D_ALIAS_LIST], [
698         LB2_MSG_LINUX_TEST_RESULT([if list 'dentry.d_u.d_alias' exist],
699         [d_alias_list], [
700                 AC_DEFINE(HAVE_DENTRY_D_U_D_ALIAS, 1,
701                         [list dentry.d_u.d_alias exist])
702         ])
703 ]) # LC_HAVE_DENTRY_D_U_D_ALIAS_LIST
704
705 #
706 # LC_HAVE_DENTRY_D_U_D_ALIAS_HLIST
707 #
708 # Some distros move d_alias to d_u and it is an hlist
709 #
710 AC_DEFUN([LC_SRC_HAVE_DENTRY_D_U_D_ALIAS_HLIST], [
711         LB2_LINUX_TEST_SRC([d_alias_hlist], [
712                 #include <linux/list.h>
713                 #include <linux/dcache.h>
714         ],[
715                 struct dentry de;
716                 INIT_HLIST_NODE(&de.d_u.d_alias);
717         ])
718 ])
719 AC_DEFUN([LC_HAVE_DENTRY_D_U_D_ALIAS_HLIST], [
720         LB2_MSG_LINUX_TEST_RESULT([if hlist 'dentry.d_u.d_alias' exist],
721         [d_alias_hlist], [
722                 AC_DEFINE(HAVE_DENTRY_D_U_D_ALIAS, 1,
723                         [list dentry.d_u.d_alias exist])
724         ])
725 ]) # LC_HAVE_DENTRY_D_U_D_ALIAS_HLIST
726
727
728 #
729 # LC_HAVE_DENTRY_D_CHILD
730 #
731 # 3.11 kernel d_child has been moved out of the union d_u
732 # in struct dentry
733 #
734 AC_DEFUN([LC_SRC_HAVE_DENTRY_D_CHILD], [
735         LB2_LINUX_TEST_SRC([d_child], [
736                 #include <linux/list.h>
737                 #include <linux/dcache.h>
738         ],[
739                 struct dentry de;
740                 INIT_LIST_HEAD(&de.d_child);
741         ])
742 ])
743 AC_DEFUN([LC_HAVE_DENTRY_D_CHILD], [
744         LB2_MSG_LINUX_TEST_RESULT([if 'dentry.d_child' exist],
745         [d_child], [
746                 AC_DEFINE(HAVE_DENTRY_D_CHILD, 1, [dentry.d_child exist])
747         ])
748 ]) # LC_HAVE_DENTRY_D_CHILD
749
750 #
751 # LC_KIOCB_KI_LEFT
752 #
753 # 3.12 ki_left removed from struct kiocb
754 #
755 AC_DEFUN([LC_SRC_KIOCB_KI_LEFT], [
756         LB2_LINUX_TEST_SRC([kiocb_ki_left], [
757                 #include <linux/aio.h>
758         ],[
759                 ((struct kiocb*)0)->ki_left = 0;
760         ])
761 ])
762 AC_DEFUN([LC_KIOCB_KI_LEFT], [
763         LB2_MSG_LINUX_TEST_RESULT([if 'struct kiocb' with 'ki_left' member],
764         [kiocb_ki_left], [
765                 AC_DEFINE(HAVE_KIOCB_KI_LEFT, 1,
766                         [ki_left exist])
767         ])
768 ]) # LC_KIOCB_KI_LEFT
769
770 #
771 # LC_REGISTER_SHRINKER_RET
772 #
773 # v3.11-8748-g1d3d4437eae1 register_shrinker returns a status
774 #
775 AC_DEFUN([LC_SRC_REGISTER_SHRINKER_RET], [
776         LB2_LINUX_TEST_SRC([register_shrinker_ret], [
777                 #include <linux/mm.h>
778         ],[
779                 if (register_shrinker(NULL))
780                         unregister_shrinker(NULL);
781         ],[])
782 ])
783 AC_DEFUN([LC_REGISTER_SHRINKER_RET], [
784         LB2_MSG_LINUX_TEST_RESULT([if register_shrinker() returns status],
785         [register_shrinker_ret], [
786                 AC_DEFINE(HAVE_REGISTER_SHRINKER_RET, 1,
787                         [register_shrinker() returns status])
788         ])
789 ]) # LC_REGISTER_SHRINKER_RET
790
791 #
792 # LC_VFS_RENAME_5ARGS
793 #
794 # 3.13 has vfs_rename with 5 args
795 #
796 AC_DEFUN([LC_SRC_VFS_RENAME_5ARGS], [
797         LB2_LINUX_TEST_SRC([vfs_rename_5args], [
798                 #include <linux/fs.h>
799         ],[
800                 vfs_rename(NULL, NULL, NULL, NULL, NULL);
801         ])
802 ])
803 AC_DEFUN([LC_VFS_RENAME_5ARGS], [
804         LB2_MSG_LINUX_TEST_RESULT([if Linux kernel has 'vfs_rename' with 5 args],
805         [vfs_rename_5args], [
806                 AC_DEFINE(HAVE_VFS_RENAME_5ARGS, 1,
807                         [kernel has vfs_rename with 5 args])
808         ])
809 ]) # LC_VFS_RENAME_5ARGS
810
811 #
812 # LC_VFS_UNLINK_3ARGS
813 #
814 # 3.13 has vfs_unlink with 3 args
815 #
816 AC_DEFUN([LC_SRC_VFS_UNLINK_3ARGS], [
817         LB2_LINUX_TEST_SRC([vfs_unlink_3args], [
818                 #include <linux/fs.h>
819         ],[
820                 vfs_unlink(NULL, NULL, NULL);
821         ])
822 ])
823 AC_DEFUN([LC_VFS_UNLINK_3ARGS], [
824         LB2_MSG_LINUX_TEST_RESULT([if Linux kernel has 'vfs_unlink' with 3 args],
825         [vfs_unlink_3args], [
826                 AC_DEFINE(HAVE_VFS_UNLINK_3ARGS, 1,
827                         [kernel has vfs_unlink with 3 args])
828         ])
829 ]) # LC_VFS_UNLINK_3ARGS
830
831 # LC_HAVE_D_IS_POSITIVE
832 #
833 # Kernel version 3.13 b18825a7c8e37a7cf6abb97a12a6ad71af160de7
834 # d_is_positive is added
835 #
836 AC_DEFUN([LC_SRC_HAVE_D_IS_POSITIVE], [
837         LB2_LINUX_TEST_SRC([d_is_positive], [
838                 #include <linux/dcache.h>
839         ],[
840                 d_is_positive(NULL);
841         ])
842 ])
843 AC_DEFUN([LC_HAVE_D_IS_POSITIVE], [
844         LB2_MSG_LINUX_TEST_RESULT([if 'd_is_positive' exist],
845         [d_is_positive], [
846                 AC_DEFINE(HAVE_D_IS_POSITIVE, 1,
847                         ['d_is_positive' is available])
848         ])
849 ]) # LC_HAVE_D_IS_POSITIVE
850
851 #
852 # LC_HAVE_BVEC_ITER
853 #
854 # 3.14 move some of its data in struct bio into the new
855 # struct bvec_iter
856 #
857 AC_DEFUN([LC_SRC_HAVE_BVEC_ITER], [
858         LB2_LINUX_TEST_SRC([have_bvec_iter], [
859                 #include <linux/bio.h>
860         ],[
861                 struct bvec_iter iter;
862
863                 iter.bi_bvec_done = 0;
864         ])
865 ])
866 AC_DEFUN([LC_HAVE_BVEC_ITER], [
867         LB2_MSG_LINUX_TEST_RESULT([if Linux kernel has struct bvec_iter],
868         [have_bvec_iter], [
869                 AC_DEFINE(HAVE_BVEC_ITER, 1,
870                         [kernel has struct bvec_iter])
871         ])
872 ]) # LC_HAVE_BVEC_ITER
873
874 #
875 # LC_IOP_SET_ACL
876 #
877 # 3.14 adds set_acl method to inode_operations
878 # see kernel commit 893d46e443346370cd4ea81d9d35f72952c62a37
879 #
880 AC_DEFUN([LC_SRC_IOP_SET_ACL], [
881         LB2_LINUX_TEST_SRC([inode_ops_set_acl], [
882                 #include <linux/fs.h>
883         ],[
884                 struct inode_operations iop;
885                 iop.set_acl = NULL;
886         ])
887 ])
888 AC_DEFUN([LC_IOP_SET_ACL], [
889         LB2_MSG_LINUX_TEST_RESULT([if 'inode_operations' has '.set_acl' member function],
890         [inode_ops_set_acl], [
891                 AC_DEFINE(HAVE_IOP_SET_ACL, 1,
892                         [inode_operations has .set_acl member function])
893         ])
894 ]) # LC_IOP_SET_ACL
895
896 #
897 # LC_HAVE_TRUNCATE_IPAGE_FINAL
898 #
899 # 3.14 bring truncate_inode_pages_final for evict_inode
900 #
901 AC_DEFUN([LC_SRC_HAVE_TRUNCATE_IPAGES_FINAL], [
902         LB2_LINUX_TEST_SRC([truncate_ipages_final], [
903                 #include <linux/mm.h>
904         ],[
905                 truncate_inode_pages_final(NULL);
906         ])
907 ])
908 AC_DEFUN([LC_HAVE_TRUNCATE_IPAGES_FINAL], [
909         LB2_MSG_LINUX_TEST_RESULT([if Linux kernel has truncate_inode_pages_final],
910         [truncate_ipages_final], [
911                 AC_DEFINE(HAVE_TRUNCATE_INODE_PAGES_FINAL, 1,
912                         [kernel has truncate_inode_pages_final])
913         ])
914 ]) # LC_HAVE_TRUNCATE_IPAGES_FINAL
915
916 #
917 # LC_IOPS_RENAME_WITH_FLAGS
918 #
919 # 3.14 has inode_operations->rename with 5 args
920 # commit 520c8b16505236fc82daa352e6c5e73cd9870cff
921 #
922 AC_DEFUN([LC_SRC_IOPS_RENAME_WITH_FLAGS], [
923         LB2_LINUX_TEST_SRC([iops_rename_with_flags], [
924                 #include <linux/fs.h>
925         ],[
926                 struct inode *i1 = NULL, *i2 = NULL;
927                 struct dentry *d1 = NULL, *d2 = NULL;
928                 int rc;
929                 rc = ((struct inode_operations *)0)->rename(i1, d1, i2, d2, 0);
930         ])
931 ]) # LC_IOPS_RENAME_WITH_FLAGS
932 AC_DEFUN([LC_IOPS_RENAME_WITH_FLAGS], [
933         LB2_MSG_LINUX_TEST_RESULT([if 'inode_operations->rename' taken flags as argument],
934         [iops_rename_with_flags], [
935                 AC_DEFINE(HAVE_IOPS_RENAME_WITH_FLAGS, 1,
936                         [inode_operations->rename need flags as argument])
937         ])
938 ]) # LC_IOPS_RENAME_WITH_FLAGS
939
940 #
941 # LC_VFS_RENAME_6ARGS
942 #
943 # 3.15 has vfs_rename with 6 args
944 #
945 AC_DEFUN([LC_SRC_VFS_RENAME_6ARGS], [
946         LB2_LINUX_TEST_SRC([vfs_rename_6args], [
947                 #include <linux/fs.h>
948         ],[
949                 vfs_rename(NULL, NULL, NULL, NULL, NULL, NULL);
950         ])
951 ])
952 AC_DEFUN([LC_VFS_RENAME_6ARGS], [
953         LB2_MSG_LINUX_TEST_RESULT([if Linux kernel has 'vfs_rename' with 6 args],
954         [vfs_rename_6args], [
955                 AC_DEFINE(HAVE_VFS_RENAME_6ARGS, 1,
956                         [kernel has vfs_rename with 6 args])
957         ])
958 ]) # LC_VFS_RENAME_6ARGS
959
960 #
961 # LC_DIRECTIO_USE_ITER
962 #
963 # 3.16 kernel changes direct IO to use iov_iter
964 #
965 AC_DEFUN([LC_SRC_DIRECTIO_USE_ITER], [
966         LB2_LINUX_TEST_SRC([direct_io_iter], [
967                 #include <linux/fs.h>
968         ],[
969                 struct address_space_operations ops = { };
970                 struct iov_iter *iter = NULL;
971                 loff_t offset = 0;
972
973                 ops.direct_IO(0, NULL, iter, offset);
974         ])
975 ])
976 AC_DEFUN([LC_DIRECTIO_USE_ITER], [
977         LB2_MSG_LINUX_TEST_RESULT([if direct IO uses iov_iter],
978         [direct_io_iter], [
979                 AC_DEFINE(HAVE_DIRECTIO_ITER, 1, [direct IO uses iov_iter])
980         ])
981 ]) # LC_DIRECTIO_USE_ITER
982
983 #
984 # LC_HAVE_IOV_ITER_INIT_DIRECTION
985 #
986 #
987 # 3.16 linux commit 71d8e532b1549a478e6a6a8a44f309d050294d00
988 #      changed iov_iter_init api to start accepting a tag
989 #      that defines if its a read or write operation
990 #
991 AC_DEFUN([LC_SRC_HAVE_IOV_ITER_INIT_DIRECTION], [
992         LB2_LINUX_TEST_SRC([iter_init], [
993                 #include <linux/uio.h>
994                 #include <linux/fs.h>
995         ],[
996                 const struct iovec *iov = NULL;
997
998                 iov_iter_init(NULL, READ, iov, 1, 0);
999         ],[-Werror])
1000 ])
1001 AC_DEFUN([LC_HAVE_IOV_ITER_INIT_DIRECTION], [
1002         LB2_MSG_LINUX_TEST_RESULT([if 'iov_iter_init' takes a tag],
1003         [iter_init], [
1004                 AC_DEFINE(HAVE_IOV_ITER_INIT_DIRECTION, 1,
1005                         [iov_iter_init handles directional tag])
1006         ])
1007 ]) # LC_HAVE_IOV_ITER_INIT_DIRECTION
1008
1009 #
1010 # LC_HAVE_IOV_ITER_TRUNCATE
1011 #
1012 #
1013 # 3.16 introduces a new API iov_iter_truncate()
1014 #
1015 AC_DEFUN([LC_SRC_HAVE_IOV_ITER_TRUNCATE], [
1016         LB2_LINUX_TEST_SRC([iter_truncate], [
1017                 #include <linux/uio.h>
1018                 #include <linux/fs.h>
1019         ],[
1020                 struct iov_iter *i = NULL;
1021
1022                 iov_iter_truncate(i, 0);
1023         ],[-Werror])
1024 ])
1025 AC_DEFUN([LC_HAVE_IOV_ITER_TRUNCATE], [
1026         LB2_MSG_LINUX_TEST_RESULT([if 'iov_iter_truncate' exists],
1027         [iter_truncate], [
1028                 AC_DEFINE(HAVE_IOV_ITER_TRUNCATE, 1, [iov_iter_truncate exists])
1029         ])
1030 ]) # LC_HAVE_IOV_ITER_TRUNCATE
1031
1032 #
1033 # LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
1034 #
1035 # 3.16 introduces [read|write]_iter to struct file_operations
1036 #
1037 AC_DEFUN([LC_SRC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER], [
1038         LB2_LINUX_TEST_SRC([file_function_iter], [
1039                 #include <linux/fs.h>
1040         ],[
1041                 ((struct file_operations *)NULL)->read_iter(NULL, NULL);
1042                 ((struct file_operations *)NULL)->write_iter(NULL, NULL);
1043         ])
1044 ])
1045 AC_DEFUN([LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER], [
1046         LB2_MSG_LINUX_TEST_RESULT([if 'file_operations.[read|write]_iter' exist],
1047         [file_function_iter], [
1048                 AC_DEFINE(HAVE_FILE_OPERATIONS_READ_WRITE_ITER, 1,
1049                         [file_operations.[read|write]_iter functions exist])
1050         ])
1051 ]) # LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
1052
1053 #
1054 # LC_PAGECACHE_GET_PAGE
1055 #
1056 # Kernel version 3.16 commit 2457aec63745e235bcafb7ef312b182d8682f0fc
1057 # @pagecache_get_page was introduced since Linux 3.16
1058 #
1059 AC_DEFUN([LC_SRC_PAGECACHE_GET_PAGE], [
1060         LB2_LINUX_TEST_SRC([pagecache_get_page], [
1061                 #include <linux/pagemap.h>
1062         ],[
1063                 pagecache_get_page(NULL, 0, 0, 0);
1064         ])
1065 ])
1066 AC_DEFUN([LC_PAGECACHE_GET_PAGE], [
1067         LB2_MSG_LINUX_TEST_RESULT([if 'pagecache_get_page' exists],
1068         [pagecache_get_page], [
1069                 AC_DEFINE(HAVE_PAGECACHE_GET_PAGE, 1,
1070                         ['pagecache_get_page' is available])
1071         ])
1072 ]) # LC_PAGECACHE_GET_PAGE
1073
1074 #
1075 # LC_HAVE_INTERVAL_BLK_INTEGRITY
1076 #
1077 # 3.17 replace sector_size with interval in struct blk_integrity
1078 #
1079 AC_DEFUN([LC_SRC_HAVE_INTERVAL_BLK_INTEGRITY], [
1080         LB2_LINUX_TEST_SRC([interval_blk_integrity], [
1081                 #include <linux/blkdev.h>
1082         ],[
1083                 ((struct blk_integrity *)0)->interval = 0;
1084         ])
1085 ])
1086 AC_DEFUN([LC_HAVE_INTERVAL_BLK_INTEGRITY], [
1087         LB2_MSG_LINUX_TEST_RESULT([if 'blk_integrity.interval' exist],
1088         [interval_blk_integrity], [
1089                 AC_DEFINE(HAVE_INTERVAL_BLK_INTEGRITY, 1,
1090                         [blk_integrity.interval exist])
1091         ])
1092 ]) # LC_HAVE_INTERVAL_BLK_INTEGRITY
1093
1094 #
1095 # LC_KEY_MATCH_DATA
1096 #
1097 # 3.17  replaces key_type::match with match_preparse
1098 #       and has new struct key_match_data
1099 #
1100 AC_DEFUN([LC_SRC_KEY_MATCH_DATA], [
1101         LB2_LINUX_TEST_SRC([key_match], [
1102                 #include <linux/key-type.h>
1103         ],[
1104                 struct key_match_data data;
1105
1106                 data.raw_data = NULL;
1107         ])
1108 ])
1109 AC_DEFUN([LC_KEY_MATCH_DATA], [
1110         LB2_MSG_LINUX_TEST_RESULT([if struct key_match field exist],
1111         [key_match], [
1112                 AC_DEFINE(HAVE_KEY_MATCH_DATA, 1, [struct key_match_data exist])
1113         ])
1114 ]) # LC_KEY_MATCH_DATA
1115
1116 #
1117 # LC_HAVE_BLK_INTEGRITY_ITER
1118 #
1119 # Linux commit v3.17-rc5-69-g1859308853b1 replaces
1120 # struct blk_integrity_exchg with struct blk_integrity_iter
1121 #
1122 # LB_CHECK_LINUX_HEADER has already run so we can rely on
1123 # HAVE_LINUX_BLK_INTEGRITY_HEADER being set correctly before
1124 # this test is run.
1125 #
1126 AC_DEFUN([LC_SRC_HAVE_BLK_INTEGRITY_ITER], [
1127         LB2_LINUX_TEST_SRC([blk_integrity_iter], [
1128                 #ifdef HAVE_LINUX_BLK_INTEGRITY_HEADER
1129                 # include <linux/blk-integrity.h>
1130                 #else
1131                 # include <linux/blkdev.h>
1132                 #endif
1133         ],[
1134                 struct blk_integrity_iter iter;
1135
1136                 iter.prot_buf = NULL;
1137         ])
1138 ])
1139 AC_DEFUN([LC_HAVE_BLK_INTEGRITY_ITER], [
1140         LB2_MSG_LINUX_TEST_RESULT([if struct blk_integrity_iter exist],
1141         [blk_integrity_iter], [
1142                 AC_DEFINE(HAVE_BLK_INTEGRITY_ITER, 1,
1143                         [kernel has struct blk_integrity_iter])
1144         ])
1145 ]) # LC_HAVE_BLK_INTEGRITY_ITER
1146
1147 #
1148 # LC_NFS_FILLDIR_USE_CTX
1149 #
1150 # 3.18 kernel moved from void cookie to struct dir_context
1151 #
1152 AC_DEFUN([LC_SRC_NFS_FILLDIR_USE_CTX], [
1153         LB2_LINUX_TEST_SRC([filldir_ctx], [
1154                 #include <linux/fs.h>
1155         ],[
1156                 int filldir(struct dir_context *ctx, const char* name,
1157                             int i, loff_t off, u64 tmp, unsigned temp)
1158                 {
1159                         return 0;
1160                 }
1161
1162                 struct dir_context ctx = {
1163                         .actor = filldir,
1164                 };
1165
1166                 ctx.actor(NULL, "test", 0, (loff_t) 0, 0, 0);
1167         ],[-Werror])
1168 ])
1169 AC_DEFUN([LC_NFS_FILLDIR_USE_CTX], [
1170         LB2_MSG_LINUX_TEST_RESULT([if filldir_t uses struct dir_context],
1171         [filldir_ctx], [
1172                 AC_DEFINE(HAVE_FILLDIR_USE_CTX, 1,
1173                         [filldir_t needs struct dir_context as argument])
1174         ])
1175 ]) # LC_NFS_FILLDIR_USE_CTX
1176
1177 #
1178 # LC_PERCPU_COUNTER_INIT
1179 #
1180 # 3.18  For kernels 3.18 and after percpu_counter_init starts
1181 #       to pass a GFP_* memory allocation flag for internal
1182 #       memory allocation purposes.
1183 #
1184 AC_DEFUN([LC_SRC_PERCPU_COUNTER_INIT], [
1185         LB2_LINUX_TEST_SRC([percpu_counter_init], [
1186                 #include <linux/percpu_counter.h>
1187         ],[
1188                 percpu_counter_init(NULL, 0, GFP_KERNEL);
1189         ])
1190 ])
1191 AC_DEFUN([LC_PERCPU_COUNTER_INIT], [
1192         LB2_MSG_LINUX_TEST_RESULT([if percpu_counter_init uses GFP_* flag as argument],
1193         [percpu_counter_init], [
1194                 AC_DEFINE(HAVE_PERCPU_COUNTER_INIT_GFP_FLAG, 1,
1195                         [percpu_counter_init uses GFP_* flag])
1196         ])
1197 ]) # LC_PERCPU_COUNTER_INIT
1198
1199 #
1200 # LC_KIOCB_HAS_NBYTES
1201 #
1202 # 3.19 kernel removed ki_nbytes from struct kiocb
1203 #
1204 AC_DEFUN([LC_SRC_KIOCB_HAS_NBYTES], [
1205         LB2_LINUX_TEST_SRC([ki_nbytes], [
1206                 #include <linux/fs.h>
1207         ],[
1208                 struct kiocb iocb = { };
1209
1210                 iocb.ki_nbytes = 0;
1211         ])
1212 ])
1213 AC_DEFUN([LC_KIOCB_HAS_NBYTES], [
1214         LB2_MSG_LINUX_TEST_RESULT([if struct kiocb has ki_nbytes field],
1215         [ki_nbytes], [
1216                 AC_DEFINE(HAVE_KI_NBYTES, 1, [ki_nbytes field exist])
1217         ])
1218 ]) # LC_KIOCB_HAS_NBYTES
1219
1220 #
1221 # LC_HAVE_DQUOT_QC_DQBLK
1222 #
1223 # 3.19 has quotactl_ops->[sg]et_dqblk that take struct kqid and qc_dqblk
1224 # Added in commit 14bf61ffe
1225 #
1226 AC_DEFUN([LC_SRC_HAVE_DQUOT_QC_DQBLK], [
1227         LB2_LINUX_TEST_SRC([qc_dqblk], [
1228                 #include <linux/fs.h>
1229                 #include <linux/quota.h>
1230         ],[
1231                 ((struct quotactl_ops *)0)->set_dqblk(NULL, *((struct kqid*)0), (struct qc_dqblk*)0);
1232         ],[-Werror])
1233 ])
1234 AC_DEFUN([LC_HAVE_DQUOT_QC_DQBLK], [
1235         LB2_MSG_LINUX_TEST_RESULT([if 'quotactl_ops.set_dqblk' takes struct qc_dqblk],
1236         [qc_dqblk], [
1237                 AC_DEFINE(HAVE_DQUOT_QC_DQBLK, 1,
1238                         [quotactl_ops.set_dqblk takes struct qc_dqblk])
1239                 AC_DEFINE(HAVE_DQUOT_KQID, 1,
1240                         [quotactl_ops.set_dqblk takes struct kqid])
1241         ])
1242 ]) # LC_HAVE_DQUOT_QC_DQBLK
1243
1244 #
1245 # LC_HAVE_AIO_COMPLETE
1246 #
1247 # 3.19 kernel makes aio_complete() static
1248 #
1249 AC_DEFUN([LC_SRC_HAVE_AIO_COMPLETE], [
1250         LB2_LINUX_TEST_SRC([aio_complete], [
1251                 #include <linux/aio.h>
1252         ],[
1253                 aio_complete(NULL, 0, 0);
1254         ])
1255 ])
1256 AC_DEFUN([LC_HAVE_AIO_COMPLETE], [
1257         LB2_MSG_LINUX_TEST_RESULT([if kernel has exported aio_complete()],
1258         [aio_complete], [
1259                 AC_DEFINE(HAVE_AIO_COMPLETE, 1, [aio_complete defined])
1260         ])
1261 ]) # LC_HAVE_AIO_COMPLETE
1262
1263 #
1264 # LC_HAVE_IS_ROOT_INODE
1265 #
1266 # 3.19 kernel adds is_root_inode()
1267 # Commit a7400222e3eb ("new helper: is_root_inode()")
1268 #
1269 AC_DEFUN([LC_SRC_HAVE_IS_ROOT_INODE], [
1270         LB2_LINUX_TEST_SRC([is_root_inode], [
1271                 #include <linux/fs.h>
1272         ],[
1273                 is_root_inode(NULL);
1274         ],[])
1275 ])
1276 AC_DEFUN([LC_HAVE_IS_ROOT_INODE], [
1277         LB2_MSG_LINUX_TEST_RESULT([if kernel has is_root_inode()],
1278         [is_root_inode], [
1279                 AC_DEFINE(HAVE_IS_ROOT_INODE, 1, [is_root_inode defined])
1280         ])
1281 ]) # LC_HAVE_IS_ROOT_INODE
1282
1283 #
1284 # LC_BACKING_DEV_INFO_REMOVAL
1285 #
1286 # 3.20 kernel removed backing_dev_info from address_space
1287 #
1288 AC_DEFUN([LC_SRC_BACKING_DEV_INFO_REMOVAL], [
1289         LB2_LINUX_TEST_SRC([backing_dev_info], [
1290                 #include <linux/fs.h>
1291         ],[
1292                 struct address_space mapping;
1293
1294                 mapping.backing_dev_info = NULL;
1295         ])
1296 ])
1297 AC_DEFUN([LC_BACKING_DEV_INFO_REMOVAL], [
1298         LB2_MSG_LINUX_TEST_RESULT([if struct address_space has backing_dev_info],
1299         [backing_dev_info], [
1300                 AC_DEFINE(HAVE_BACKING_DEV_INFO, 1, [backing_dev_info exist])
1301         ])
1302 ]) # LC_BACKING_DEV_INFO_REMOVAL
1303
1304 #
1305 # LC_HAVE_PROJECT_QUOTA
1306 #
1307 # Kernel version v4.0-rc1-197-g847aac644e92
1308 #
1309 AC_DEFUN([LC_SRC_HAVE_PROJECT_QUOTA], [
1310         LB2_LINUX_TEST_SRC([get_projid], [
1311                 struct inode;
1312                 #include <linux/quota.h>
1313         ],[
1314                 struct dquot_operations ops = { };
1315
1316                 ops.get_projid(NULL, NULL);
1317         ])
1318 ])
1319 AC_DEFUN([LC_HAVE_PROJECT_QUOTA], [
1320         LB2_MSG_LINUX_TEST_RESULT([if get_projid exists],
1321         [get_projid], [
1322                 AC_DEFINE(HAVE_PROJECT_QUOTA, 1,
1323                         [get_projid function exists])
1324         ])
1325 ]) # LC_HAVE_PROJECT_QUOTA
1326
1327 #
1328 # LC_IOV_ITER_RW
1329 #
1330 # 4.1 kernel has iov_iter_rw
1331 #
1332 AC_DEFUN([LC_SRC_IOV_ITER_RW], [
1333         LB2_LINUX_TEST_SRC([iov_iter_rw], [
1334                 #include <linux/fs.h>
1335                 #include <linux/uio.h>
1336         ],[
1337                 struct iov_iter *iter = NULL;
1338
1339                 iov_iter_rw(iter);
1340         ])
1341 ])
1342 AC_DEFUN([LC_IOV_ITER_RW], [
1343         LB2_MSG_LINUX_TEST_RESULT([if iov_iter_rw exist],
1344         [iov_iter_rw], [
1345                 AC_DEFINE(HAVE_IOV_ITER_RW, 1, [iov_iter_rw exist])
1346         ])
1347 ]) # LC_IOV_ITER_RW
1348
1349 #
1350 # LC_HAVE_SYNC_READ_WRITE
1351 #
1352 # 4.1 new_sync_[read|write] no longer exported
1353 #
1354 AC_DEFUN([LC_HAVE_SYNC_READ_WRITE], [
1355 LB_CHECK_EXPORT([new_sync_read], [fs/read_write.c],
1356         [AC_DEFINE(HAVE_SYNC_READ_WRITE, 1,
1357                         [new_sync_[read|write] is exported by the kernel])])
1358 ]) # LC_HAVE_SYNC_READ_WRITE
1359
1360 #
1361 # LC_HAVE___BI_CNT
1362 #
1363 # 4.1 redefined bi_cnt as __bi_cnt in commit dac56212e8127dbc0
1364 #
1365 AC_DEFUN([LC_SRC_HAVE___BI_CNT], [
1366         LB2_LINUX_TEST_SRC([have___bi_cnt], [
1367                 #include <asm/atomic.h>
1368                 #include <linux/bio.h>
1369                 #include <linux/blk_types.h>
1370         ],[
1371                 struct bio bio = { };
1372                 int cnt;
1373                 cnt = atomic_read(&bio.__bi_cnt);
1374         ])
1375 ])
1376 AC_DEFUN([LC_HAVE___BI_CNT], [
1377         LB2_MSG_LINUX_TEST_RESULT([if Linux kernel has __bi_cnt in struct bio],
1378         [have___bi_cnt], [
1379                 AC_DEFINE(HAVE___BI_CNT, 1, [struct bio has __bi_cnt])
1380         ])
1381 ]) # LC_HAVE___BI_CNT
1382
1383 #
1384 # LC_SYMLINK_OPS_USE_NAMEIDATA
1385 #
1386 # For the 4.2+ kernels the file system internal symlink api no
1387 # longer uses struct nameidata as a argument
1388 #
1389 AC_DEFUN([LC_SRC_SYMLINK_OPS_USE_NAMEIDATA], [
1390         LB2_LINUX_TEST_SRC([symlink_use_nameidata], [
1391                 #include <linux/namei.h>
1392                 #include <linux/fs.h>
1393         ],[
1394                 struct nameidata *nd = NULL;
1395
1396                 ((struct inode_operations *)0)->follow_link(NULL, nd);
1397                 ((struct inode_operations *)0)->put_link(NULL, nd, NULL);
1398         ])
1399 ])
1400 AC_DEFUN([LC_SYMLINK_OPS_USE_NAMEIDATA], [
1401         LB2_MSG_LINUX_TEST_RESULT([if symlink inode operations have struct nameidata argument],
1402         [symlink_use_nameidata], [
1403                 AC_DEFINE(HAVE_SYMLINK_OPS_USE_NAMEIDATA, 1,
1404                         [symlink inode operations need struct nameidata argument])
1405         ])
1406 ]) # LC_SYMLINK_OPS_USE_NAMEIDATA
1407
1408 #
1409 # LC_BIO_ENDIO_USES_ONE_ARG
1410 #
1411 # 4.2 kernel bio_endio now only takes one argument
1412 #
1413 AC_DEFUN([LC_SRC_BIO_ENDIO_USES_ONE_ARG], [
1414         LB2_LINUX_TEST_SRC([bio_endio], [
1415                 #include <linux/bio.h>
1416         ],[
1417                 bio_endio(NULL);
1418         ])
1419 ])
1420 AC_DEFUN([LC_BIO_ENDIO_USES_ONE_ARG], [
1421         LB2_MSG_LINUX_TEST_RESULT([if 'bio_endio' with one argument exist],
1422         [bio_endio], [
1423                 AC_DEFINE(HAVE_BIO_ENDIO_USES_ONE_ARG, 1,
1424                         [bio_endio takes only one argument])
1425         ])
1426 ]) # LC_BIO_ENDIO_USES_ONE_ARG
1427
1428 #
1429 # LC_ACCOUNT_PAGE_DIRTIED_3ARGS
1430 #
1431 # 4.2 [to 4.5] kernel page dirtied takes 3 arguments
1432 #
1433 AC_DEFUN([LC_SRC_ACCOUNT_PAGE_DIRTIED_3ARGS], [
1434         LB2_LINUX_TEST_SRC([account_page_dirtied_3a], [
1435                 #include <linux/mm.h>
1436         ],[
1437                 account_page_dirtied(NULL, NULL, NULL);
1438         ])
1439 ])
1440 AC_DEFUN([LC_ACCOUNT_PAGE_DIRTIED_3ARGS], [
1441         LB2_MSG_LINUX_TEST_RESULT([if 'account_page_dirtied' with 3 args exists],
1442         [account_page_dirtied_3a], [
1443                 AC_DEFINE(HAVE_ACCOUNT_PAGE_DIRTIED_3ARGS, 1,
1444                         [account_page_dirtied takes three arguments])
1445         ])
1446 ]) # LC_ACCOUNT_PAGE_DIRTIED_3ARGS
1447
1448 #
1449 # LC_HAVE_CRYPTO_ALLOC_SKCIPHER
1450 #
1451 # Kernel version 4.12 commit 7a7ffe65c8c5
1452 # introduced crypto_alloc_skcipher().
1453 #
1454 AC_DEFUN([LC_SRC_HAVE_CRYPTO_ALLOC_SKCIPHER], [
1455         LB2_LINUX_TEST_SRC([crypto_alloc_skcipher], [
1456                 #include <crypto/skcipher.h>
1457         ],[
1458                 crypto_alloc_skcipher(NULL, 0, 0);
1459         ])
1460 ])
1461 AC_DEFUN([LC_HAVE_CRYPTO_ALLOC_SKCIPHER], [
1462         LB2_MSG_LINUX_TEST_RESULT([if crypto_alloc_skcipher is defined],
1463         [crypto_alloc_skcipher], [
1464                 AC_DEFINE(HAVE_CRYPTO_ALLOC_SKCIPHER, 1,
1465                         [crypto_alloc_skcipher is defined])
1466         ])
1467 ]) # LC_HAVE_CRYPTO_ALLOC_SKCIPHER
1468
1469 #
1470 # LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
1471 #
1472 # 4.3 replace interval with interval_exp in 'struct blk_integrity'
1473 # 'struct blk_integrity_profile' is also added in this version,
1474 # thus use this to determine whether 'struct blk_integrity' has profile
1475 #
1476 AC_DEFUN([LC_SRC_HAVE_INTERVAL_EXP_BLK_INTEGRITY], [
1477         LB2_LINUX_TEST_SRC([blk_integrity_interval_exp], [
1478                 #include <linux/blkdev.h>
1479         ],[
1480                 ((struct blk_integrity *)0)->interval_exp = 0;
1481         ])
1482 ])
1483 AC_DEFUN([LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY], [
1484         LB2_MSG_LINUX_TEST_RESULT([if 'blk_integrity.interval_exp' exist],
1485         [blk_integrity_interval_exp], [
1486                 AC_DEFINE(HAVE_INTERVAL_EXP_BLK_INTEGRITY, 1,
1487                         [blk_integrity.interval_exp exist])
1488         ])
1489 ]) # LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
1490
1491 #
1492 # LC_HAVE_CACHE_HEAD_HLIST
1493 #
1494 # 4.3 kernel swiched to hlist for cache_head
1495 #
1496 AC_DEFUN([LC_SRC_HAVE_CACHE_HEAD_HLIST], [
1497         LB2_LINUX_TEST_SRC([cache_head_has_hlist], [
1498                 #include <linux/sunrpc/cache.h>
1499         ],[
1500                 do {} while(sizeof(((struct cache_head *)0)->cache_list));
1501         ])
1502 ])
1503 AC_DEFUN([LC_HAVE_CACHE_HEAD_HLIST], [
1504         LB2_MSG_LINUX_TEST_RESULT([if 'struct cache_head' has 'cache_list' field],
1505         [cache_head_has_hlist], [
1506                 AC_DEFINE(HAVE_CACHE_HEAD_HLIST, 1,
1507                         [cache_head has hlist cache_list])
1508         ])
1509 ]) # LC_HAVE_CACHE_HEAD_HLIST
1510
1511 #
1512 # LC_HAVE_XATTR_HANDLER_SIMPLIFIED
1513 #
1514 # Kernel version 4.3 commit e409de992e3ea3674393465f07cc71c948edd87a
1515 # simplified xattr_handler handling by passing in the handler pointer
1516 #
1517 AC_DEFUN([LC_SRC_HAVE_XATTR_HANDLER_SIMPLIFIED], [
1518         LB2_LINUX_TEST_SRC([xattr_handler_simplified], [
1519                 #include <linux/xattr.h>
1520         ],[
1521                 struct xattr_handler handler;
1522
1523                 ((struct xattr_handler *)0)->get(&handler, NULL, NULL, NULL, 0);
1524                 ((struct xattr_handler *)0)->set(&handler, NULL, NULL, NULL, 0, 0);
1525         ],[-Werror])
1526 ])
1527 AC_DEFUN([LC_HAVE_XATTR_HANDLER_SIMPLIFIED], [
1528         LB2_MSG_LINUX_TEST_RESULT([if 'struct xattr_handler' functions pass in handler pointer],
1529         [xattr_handler_simplified], [
1530                 AC_DEFINE(HAVE_XATTR_HANDLER_SIMPLIFIED, 1,
1531                         [handler pointer is parameter])
1532         ])
1533 ]) # LC_HAVE_XATTR_HANDLER_SIMPLIFIED
1534
1535 #
1536 # LC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD
1537 #
1538 # 4.3 replace interval with interval_exp in 'struct blk_integrity'.
1539 #
1540 AC_DEFUN([LC_SRC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD], [
1541         LB2_LINUX_TEST_SRC([bio_integrity_payload_bip_iter], [
1542                 #include <linux/bio.h>
1543         ],[
1544                 ((struct bio_integrity_payload *)0)->bip_iter.bi_size = 0;
1545         ])
1546 ])
1547 AC_DEFUN([LC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD], [
1548         LB2_MSG_LINUX_TEST_RESULT([if 'bio_integrity_payload.bip_iter' exist],
1549         [bio_integrity_payload_bip_iter], [
1550                 AC_DEFINE(HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD, 1,
1551                         [bio_integrity_payload.bip_iter exist])
1552         ])
1553 ]) # LC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD
1554
1555 #
1556 # LC_BIO_INTEGRITY_PREP_FN
1557 #
1558 # Lustre kernel patch extents bio_integrity_prep to accept optional
1559 # generate/verify_fn as extra args.
1560 #
1561 AC_DEFUN([LC_SRC_BIO_INTEGRITY_PREP_FN], [
1562         LB2_LINUX_TEST_SRC([bio_integrity_prep_fn], [
1563                 #include <linux/bio.h>
1564         ],[
1565                 bio_integrity_prep_fn(NULL, NULL, NULL);
1566         ])
1567 ])
1568 AC_DEFUN([LC_BIO_INTEGRITY_PREP_FN], [
1569         LB2_MSG_LINUX_TEST_RESULT([if 'bio_integrity_prep_fn' exists],
1570         [bio_integrity_prep_fn], [
1571                 AC_DEFINE(HAVE_BIO_INTEGRITY_PREP_FN, 1,
1572                         [kernel has bio_integrity_prep_fn])
1573                 AC_SUBST(PATCHED_INTEGRITY_INTF)
1574         ],[
1575                 AC_SUBST(PATCHED_INTEGRITY_INTF, [#])
1576         ])
1577 ]) # LC_BIO_INTEGRITY_PREP_FN
1578
1579 # LC_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL
1580 #
1581 # 13 kernel integrity API has changed and in 4.13+
1582 # (as well as in rhel 8.4) bio_integrity_prep() returns boolean true
1583 # on success.
1584 #
1585 AC_DEFUN([LC_SRC_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL], [
1586         LB2_LINUX_TEST_SRC([bio_integrity_prep_ret_bool], [
1587                 #include <linux/bio.h>
1588                 #include <linux/typecheck.h>
1589         ],[
1590                 #pragma GCC diagnostic warning "-Werror"
1591                 typedef bool (*bio_integrity_prep_type)(struct bio *bio) ;
1592
1593                 typecheck_fn(bio_integrity_prep_type, bio_integrity_prep);
1594         ])
1595 ])
1596 AC_DEFUN([LC_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL], [
1597         LB2_MSG_LINUX_TEST_RESULT([if 'bio_integrity_prep_fn' returns bool],
1598         [bio_integrity_prep_ret_bool], [
1599                 AC_DEFINE(HAVE_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL, 1,
1600                         [bio_integrity_prep_fn returns bool])
1601         ])
1602 ]) # LC_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL
1603
1604 #
1605 # LC_HAVE_BI_OPF
1606 #
1607 # 4.4/4.8 redefined bi_rw as bi_opf (SLES12/kernel commit 4382e33ad37486)
1608 #
1609 AC_DEFUN([LC_SRC_HAVE_BI_OPF], [
1610         LB2_LINUX_TEST_SRC([have_bi_opf], [
1611                 #include <linux/bio.h>
1612         ],[
1613                 struct bio bio;
1614
1615                 bio.bi_opf = 0;
1616         ])
1617 ])
1618 AC_DEFUN([LC_HAVE_BI_OPF], [
1619         LB2_MSG_LINUX_TEST_RESULT([if Linux kernel has bi_opf in struct bio],
1620         [have_bi_opf], [
1621                 AC_DEFINE(HAVE_BI_OPF, 1, [struct bio has bi_opf])
1622         ])
1623 ]) # LC_HAVE_BI_OPF
1624
1625 #
1626 # LC_HAVE_SUBMIT_BIO_2ARGS
1627 #
1628 # 4.4 removed an argument from submit_bio
1629 #
1630 AC_DEFUN([LC_SRC_HAVE_SUBMIT_BIO_2ARGS], [
1631         LB2_LINUX_TEST_SRC([have_submit_bio_2args], [
1632                 #include <linux/bio.h>
1633         ],[
1634                 struct bio bio;
1635                 submit_bio(READ, &bio);
1636         ])
1637 ])
1638 AC_DEFUN([LC_HAVE_SUBMIT_BIO_2ARGS], [
1639         LB2_MSG_LINUX_TEST_RESULT([if submit_bio takes two arguments],
1640         [have_submit_bio_2args], [
1641                 AC_DEFINE(HAVE_SUBMIT_BIO_2ARGS, 1,
1642                         [submit_bio takes two arguments])
1643         ])
1644 ]) # LC_HAVE_SUBMIT_BIO_2_ARGS
1645
1646 #
1647 # LC_HAVE_CLEAN_BDEV_ALIASES
1648 #
1649 # 4.4/4.9 unmap_underlying_metadata was replaced by clean_bdev_aliases
1650 # (SLES12/kernel commit 29f3ad7d8380364c)
1651 #
1652 AC_DEFUN([LC_SRC_HAVE_CLEAN_BDEV_ALIASES], [
1653         LB2_LINUX_TEST_SRC([have_clean_bdev_aliases], [
1654                 #include <linux/buffer_head.h>
1655         ],[
1656                 clean_bdev_aliases(NULL,1,1);
1657         ])
1658 ])
1659 AC_DEFUN([LC_HAVE_CLEAN_BDEV_ALIASES], [
1660         LB2_MSG_LINUX_TEST_RESULT([if kernel has clean_bdev_aliases],
1661         [have_clean_bdev_aliases], [
1662                 AC_DEFINE(HAVE_CLEAN_BDEV_ALIASES, 1,
1663                         [kernel has clean_bdev_aliases])
1664         ])
1665 ]) # LC_HAVE_CLEAN_BDEV_ALIASES
1666
1667 #
1668 # LC_HAVE_LOCKS_LOCK_FILE_WAIT
1669 #
1670 # 4.4 kernel have moved locks API users to
1671 # locks_lock_inode_wait()
1672 #
1673 AC_DEFUN([LC_SRC_HAVE_LOCKS_LOCK_FILE_WAIT], [
1674         LB2_LINUX_TEST_SRC([locks_lock_file_wait], [
1675                 #include <linux/fs.h>
1676         ],[
1677                 locks_lock_file_wait(NULL, NULL);
1678         ])
1679 ])
1680 AC_DEFUN([LC_HAVE_LOCKS_LOCK_FILE_WAIT], [
1681         LB2_MSG_LINUX_TEST_RESULT([if 'locks_lock_file_wait' exists],
1682         [locks_lock_file_wait], [
1683                 AC_DEFINE(HAVE_LOCKS_LOCK_FILE_WAIT, 1,
1684                         [kernel has locks_lock_file_wait])
1685         ])
1686 ]) # LC_HAVE_LOCKS_LOCK_FILE_WAIT
1687
1688 #
1689 # LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
1690 #
1691 # 4.4 kernel merged type-specific data with the payload data for keys
1692 #
1693 AC_DEFUN([LC_SRC_HAVE_KEY_PAYLOAD_DATA_ARRAY], [
1694         LB2_LINUX_TEST_SRC([key_payload_data_array], [
1695                 #include <linux/key.h>
1696         ],[
1697                 struct key key = { };
1698
1699                 key.payload.data[0] = NULL;
1700         ])
1701 ])
1702 AC_DEFUN([LC_HAVE_KEY_PAYLOAD_DATA_ARRAY], [
1703         LB2_MSG_LINUX_TEST_RESULT([if 'struct key' has 'payload.data' as an array],
1704         [key_payload_data_array], [
1705                 AC_DEFINE(HAVE_KEY_PAYLOAD_DATA_ARRAY, 1, [payload.data is an array])
1706         ])
1707 ]) # LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
1708
1709 #
1710 # LC_HAVE_XATTR_HANDLER_NAME
1711 #
1712 # Kernel version 4.4 commit 98e9cb5711c68223f0e4d5201b9a6add255ec550
1713 # add a name member to struct xattr_handler
1714 #
1715 AC_DEFUN([LC_SRC_HAVE_XATTR_HANDLER_NAME], [
1716         LB2_LINUX_TEST_SRC([xattr_handler_name], [
1717                 #include <linux/xattr.h>
1718         ],[
1719                 ((struct xattr_handler *)NULL)->name = NULL;
1720         ],[-Werror])
1721 ])
1722 AC_DEFUN([LC_HAVE_XATTR_HANDLER_NAME], [
1723         LB2_MSG_LINUX_TEST_RESULT([if 'struct xattr_handler' has a name member],
1724         [xattr_handler_name], [
1725                 AC_DEFINE(HAVE_XATTR_HANDLER_NAME, 1,
1726                         [xattr_handler has a name member])
1727         ])
1728 ]) # LC_HAVE_XATTR_HANDLER_NAME
1729
1730 #
1731 # LC_HAVE_FILE_DENTRY
1732 #
1733 # 4.5 adds wrapper file_dentry
1734 #
1735 AC_DEFUN([LC_SRC_HAVE_FILE_DENTRY], [
1736         LB2_LINUX_TEST_SRC([file_dentry], [
1737                 #include <linux/fs.h>
1738         ],[
1739                 file_dentry(NULL);
1740         ])
1741 ])
1742 AC_DEFUN([LC_HAVE_FILE_DENTRY], [
1743         LB2_MSG_LINUX_TEST_RESULT([if Linux kernel has 'file_dentry'],
1744         [file_dentry], [
1745                 AC_DEFINE(HAVE_FILE_DENTRY, 1, [kernel has file_dentry])
1746         ])
1747 ]) # LC_HAVE_FILE_DENTRY
1748
1749 #
1750 # LC_HAVE_INODE_LOCK
1751 #
1752 # 4.5 introduced inode_lock
1753 #
1754 AC_DEFUN([LC_SRC_HAVE_INODE_LOCK], [
1755         LB2_LINUX_TEST_SRC([inode_lock], [
1756                 #include <linux/fs.h>
1757         ],[
1758                 inode_lock(NULL);
1759         ])
1760 ])
1761 AC_DEFUN([LC_HAVE_INODE_LOCK], [
1762         LB2_MSG_LINUX_TEST_RESULT([if 'inode_lock' is defined],
1763         [inode_lock], [
1764                 AC_DEFINE(HAVE_INODE_LOCK, 1, [inode_lock is defined])
1765         ])
1766 ]) # LC_HAVE_INODE_LOCK
1767
1768 #
1769 # LC_HAVE_IOP_GET_LINK
1770 #
1771 # 4.5 vfs replaced iop->follow_link with
1772 # iop->get_link
1773 #
1774 AC_DEFUN([LC_SRC_HAVE_IOP_GET_LINK], [
1775         LB2_LINUX_TEST_SRC([inode_ops_get_link], [
1776                 #include <linux/fs.h>
1777         ],[
1778                 struct inode_operations iop;
1779                 iop.get_link = NULL;
1780         ])
1781 ])
1782 AC_DEFUN([LC_HAVE_IOP_GET_LINK], [
1783         LB2_MSG_LINUX_TEST_RESULT([if 'iop' has 'get_link'],
1784         [inode_ops_get_link], [
1785                 AC_DEFINE(HAVE_IOP_GET_LINK, 1, [have iop get_link])
1786         ])
1787 ]) # LC_HAVE_IOP_GET_LINK
1788
1789 #
1790 # LC_HAVE_IN_COMPAT_SYSCALL
1791 #
1792 # 4.6 renamed is_compat_task to in_compat_syscall
1793 #
1794 AC_DEFUN([LC_SRC_HAVE_IN_COMPAT_SYSCALL], [
1795         LB2_LINUX_TEST_SRC([in_compat_syscall], [
1796                 #include <linux/compat.h>
1797         ],[
1798                 in_compat_syscall();
1799         ])
1800 ])
1801 AC_DEFUN([LC_HAVE_IN_COMPAT_SYSCALL], [
1802         LB2_MSG_LINUX_TEST_RESULT([if 'in_compat_syscall' is defined],
1803         [in_compat_syscall], [
1804                 AC_DEFINE(HAVE_IN_COMPAT_SYSCALL, 1, [have in_compat_syscall])
1805         ])
1806 ]) # LC_HAVE_IN_COMPAT_SYSCALL
1807
1808 #
1809 # LC_HAVE_XATTR_HANDLER_INODE_PARAM
1810 #
1811 # Kernel version 4.6 commit b296821a7c42fa58baa17513b2b7b30ae66f3336
1812 # and commit 5930122683dff58f0846b0f0405b4bd598a3ba6a added inode parameter
1813 # to xattr_handler functions
1814 #
1815 AC_DEFUN([LC_SRC_HAVE_XATTR_HANDLER_INODE_PARAM], [
1816         LB2_LINUX_TEST_SRC([xattr_handler_inode_param], [
1817                 #include <linux/xattr.h>
1818         ],[
1819                 const struct xattr_handler handler;
1820
1821                 ((struct xattr_handler *)0)->get(&handler, NULL, NULL, NULL, NULL, 0);
1822                 ((struct xattr_handler *)0)->set(&handler, NULL, NULL, NULL, NULL, 0, 0);
1823         ],[-Werror])
1824 ])
1825 AC_DEFUN([LC_HAVE_XATTR_HANDLER_INODE_PARAM], [
1826         LB2_MSG_LINUX_TEST_RESULT([if 'struct xattr_handler' functions have inode parameter],
1827         [xattr_handler_inode_param], [
1828                 AC_DEFINE(HAVE_XATTR_HANDLER_INODE_PARAM, 1, [needs inode parameter])
1829         ])
1830 ]) # LC_HAVE_XATTR_HANDLER_INODE_PARAM
1831
1832 #
1833 # LC_D_IN_LOOKUP
1834 #
1835 # Kernel version 4.6 commit 85c7f81041d57cfe9dc97f4680d5586b54534a39
1836 # introduced parallel lookups in the VFS layer. The inline function
1837 # d_in_lookup was added to notify when the same item was being queried
1838 # at the same time.
1839 #
1840 AC_DEFUN([LC_SRC_D_IN_LOOKUP], [
1841         LB2_LINUX_TEST_SRC([d_in_lookup], [
1842                 #include <linux/dcache.h>
1843         ],[
1844                 d_in_lookup(NULL);
1845         ],[-Werror])
1846 ])
1847 AC_DEFUN([LC_D_IN_LOOKUP], [
1848         LB2_MSG_LINUX_TEST_RESULT([if 'd_in_lookup' is defined],
1849         [d_in_lookup], [
1850                 AC_DEFINE(HAVE_D_IN_LOOKUP, 1, [d_in_lookup is defined])
1851         ])
1852 ]) # LC_D_IN_LOOKUP
1853
1854 #
1855 # LC_LOCK_PAGE_MEMCG
1856 #
1857 # Kernel version 4.6 adds lock_page_memcg(page)
1858 # Linux commit v5.15-12273-gab2f9d2d3626
1859 #   mm: unexport {,un}lock_page_memcg
1860 #
1861 AC_DEFUN([LC_SRC_LOCK_PAGE_MEMCG], [
1862         LB2_LINUX_TEST_SRC([lock_page_memcg], [
1863                 #include <linux/memcontrol.h>
1864         ],[
1865                 lock_page_memcg(NULL);
1866         ],[-Werror])
1867 ])
1868 AC_DEFUN([LC_LOCK_PAGE_MEMCG], [
1869         LB2_MSG_LINUX_TEST_RESULT([if 'lock_page_memcg' is defined],
1870         [lock_page_memcg], [
1871                 AC_DEFINE(HAVE_LOCK_PAGE_MEMCG, 1, [lock_page_memcg is defined])
1872         ])
1873 ]) # LC_LOCK_PAGE_MEMCG
1874
1875 #
1876 # LC_HAVE_DOWN_WRITE_KILLABLE
1877 #
1878 # Kernel version v4.6-rc3-28-g916633a40370
1879 #
1880 AC_DEFUN([LC_SRC_HAVE_DOWN_WRITE_KILLABLE], [
1881         LB2_LINUX_TEST_SRC([down_write_killable], [
1882                 #include <linux/rwsem.h>
1883
1884                 struct rw_semaphore sem;
1885         ],[
1886                 int rc;
1887
1888                 rc = down_write_killable(&sem);
1889                 (void)rc;
1890         ])
1891 ])
1892 AC_DEFUN([LC_HAVE_DOWN_WRITE_KILLABLE], [
1893         LB2_MSG_LINUX_TEST_RESULT([if down_write_killable exists],
1894         [down_write_killable], [
1895                 AC_DEFINE(HAVE_DOWN_WRITE_KILLABLE, 1,
1896                         [down_write_killable function exists])
1897         ])
1898 ]) # LC_HAVE_DOWN_WRITE_KILLABLE
1899
1900 #
1901 # LC_D_INIT
1902 #
1903 # Kernel version 4.7-rc5 commit 285b102d3b745f3c2c110c9c327741d87e64aacc
1904 # add new d_init to initialize dentry at allocation time
1905 #
1906 AC_DEFUN([LC_SRC_D_INIT], [
1907         LB2_LINUX_TEST_SRC([d_init], [
1908                 #include <linux/dcache.h>
1909         ],[
1910                 struct dentry_operations ops = { };
1911                 int rc;
1912
1913                 rc = ops.d_init(NULL);
1914         ])
1915 ])
1916 AC_DEFUN([LC_D_INIT], [
1917         LB2_MSG_LINUX_TEST_RESULT([if dentry operations supports 'd_init'],
1918         [d_init], [
1919                 AC_DEFINE(HAVE_D_INIT, 1, ['d_init' exists])
1920         ])
1921 ]) # LC_D_INIT
1922
1923 #
1924 # LC_DIRECTIO_2ARGS
1925 #
1926 # Kernel version 4.7 commit c8b8e32d700fe943a935e435ae251364d016c497
1927 # direct-io: eliminate the offset argument to ->direct_IO
1928 #
1929 AC_DEFUN([LC_SRC_DIRECTIO_2ARGS], [
1930         LB2_LINUX_TEST_SRC([direct_io_2args], [
1931                 #include <linux/fs.h>
1932         ],[
1933                 struct address_space_operations ops = { };
1934                 struct iov_iter *iter = NULL;
1935                 struct kiocb *iocb = NULL;
1936                 int rc;
1937
1938                 rc = ops.direct_IO(iocb, iter);
1939         ])
1940 ])
1941 AC_DEFUN([LC_DIRECTIO_2ARGS], [
1942         LB2_MSG_LINUX_TEST_RESULT([if '->direct_IO()' takes 2 arguments],
1943         [direct_io_2args], [
1944                 AC_DEFINE(HAVE_DIRECTIO_2ARGS, 1, [direct_IO has 2 arguments])
1945         ])
1946 ]) # LC_DIRECTIO_2ARGS
1947
1948 #
1949 # LC_GENERIC_WRITE_SYNC_2ARGS
1950 #
1951 # Kernel version 4.7 commit dde0c2e79848298cc25621ad080d47f94dbd7cce
1952 # fs: add IOCB_SYNC and IOCB_DSYNC
1953 #
1954 AC_DEFUN([LC_SRC_GENERIC_WRITE_SYNC_2ARGS], [
1955         LB2_LINUX_TEST_SRC([generic_write_sync_2args], [
1956                 #include <linux/fs.h>
1957         ],[
1958                 struct kiocb *iocb = NULL;
1959                 ssize_t rc;
1960
1961                 rc = generic_write_sync(iocb, 0);
1962         ])
1963 ])
1964 AC_DEFUN([LC_GENERIC_WRITE_SYNC_2ARGS], [
1965         LB2_MSG_LINUX_TEST_RESULT([if 'generic_write_sync()' takes 2 arguments],
1966         [generic_write_sync_2args], [
1967                 AC_DEFINE(HAVE_GENERIC_WRITE_SYNC_2ARGS, 1,
1968                         [generic_write_sync has 2 arguments])
1969         ])
1970 ]) # LC_GENERIC_WRITE_SYNC_2ARGS
1971
1972 #
1973 # LC_FOP_ITERATE_SHARED
1974 #
1975 # Kernel v4.6-rc3-29-g6192269 adds iterate_shared method to file_operations
1976 #
1977 AC_DEFUN([LC_SRC_FOP_ITERATE_SHARED], [
1978         LB2_LINUX_TEST_SRC([fop_iterate_shared], [
1979                 #include <linux/fs.h>
1980         ],[
1981                 struct file_operations fop;
1982                 fop.iterate_shared = NULL;
1983         ])
1984 ])
1985 AC_DEFUN([LC_FOP_ITERATE_SHARED], [
1986         LB2_MSG_LINUX_TEST_RESULT([if 'file_operations' has 'iterate_shared'],
1987         [fop_iterate_shared], [
1988                 AC_DEFINE(HAVE_FOP_ITERATE_SHARED, 1,
1989                         [file_operations has iterate_shared])
1990         ])
1991 ]) # LC_FOP_ITERATE_SHARED
1992
1993 #
1994 # LC_EXPORT_DEFAULT_FILE_SPLICE_READ
1995 #
1996 # 4.8-rc8 commit 82c156f853840645604acd7c2cebcb75ed1b6652 switched
1997 # generic_file_splice_read() to using ->read_iter. We can test this
1998 # change since default_file_splice_read() is no longer exported.
1999 #
2000 AC_DEFUN([LC_EXPORT_DEFAULT_FILE_SPLICE_READ], [
2001 LB_CHECK_EXPORT([default_file_splice_read], [fs/splice.c],
2002         [AC_DEFINE(HAVE_DEFAULT_FILE_SPLICE_READ_EXPORT, 1,
2003                         [default_file_splice_read is exported])])
2004 ]) # LC_EXPORT_DEFAULT_FILE_SPLCE_READ
2005
2006 #
2007 # LC_HAVE_POSIX_ACL_VALID_USER_NS
2008 #
2009 # 4.8 posix_acl_valid takes struct user_namespace
2010 #
2011 AC_DEFUN([LC_SRC_HAVE_POSIX_ACL_VALID_USER_NS], [
2012         LB2_LINUX_TEST_SRC([posix_acl_valid], [
2013                 #include <linux/fs.h>
2014                 #include <linux/posix_acl.h>
2015         ],[
2016                 posix_acl_valid((struct user_namespace*)NULL, (const struct posix_acl*)NULL);
2017         ])
2018 ])
2019 AC_DEFUN([LC_HAVE_POSIX_ACL_VALID_USER_NS], [
2020         LB2_MSG_LINUX_TEST_RESULT([if 'posix_acl_valid' takes 'struct user_namespace'],
2021         [posix_acl_valid], [
2022                 AC_DEFINE(HAVE_POSIX_ACL_VALID_USER_NS, 1,
2023                         [posix_acl_valid takes struct user_namespace])
2024         ])
2025 ]) # LC_HAVE_POSIX_ACL_VALID_USER_NS
2026
2027 #
2028 # LC_D_COMPARE_4ARGS
2029 #
2030 # Kernel version 4.8 commit 6fa67e707559303e086303aeecc9e8b91ef497d5
2031 # get rid of 'parent' argument of ->d_compare()
2032 #
2033 AC_DEFUN([LC_SRC_D_COMPARE_4ARGS], [
2034         LB2_LINUX_TEST_SRC([d_compare_4args], [
2035                 #include <linux/dcache.h>
2036         ],[
2037                 ((struct dentry_operations*)0)->d_compare(NULL,0,NULL,NULL);
2038         ])
2039 ])
2040 AC_DEFUN([LC_D_COMPARE_4ARGS], [
2041         LB2_MSG_LINUX_TEST_RESULT([if 'd_compare' taken 4 arguments],
2042         [d_compare_4args], [
2043                 AC_DEFINE(HAVE_D_COMPARE_4ARGS, 1,
2044                         [d_compare need 4 arguments])
2045         ])
2046 ]) # LC_D_COMPARE_4ARGS
2047
2048 #
2049 # LC_FULL_NAME_HASH_3ARGS
2050 #
2051 # Kernel version 4.8 commit 8387ff2577eb9ed245df9a39947f66976c6bcd02
2052 # vfs: make the string hashes salt the hash
2053 #
2054 AC_DEFUN([LC_SRC_FULL_NAME_HASH_3ARGS], [
2055         LB2_LINUX_TEST_SRC([full_name_hash_3args], [
2056                 #include <linux/stringhash.h>
2057         ],[
2058                 unsigned int hash;
2059                 hash = full_name_hash(NULL,NULL,0);
2060         ])
2061 ])
2062 AC_DEFUN([LC_FULL_NAME_HASH_3ARGS], [
2063         LB2_MSG_LINUX_TEST_RESULT([if 'full_name_hash' taken 3 arguments],
2064         [full_name_hash_3args], [
2065                 AC_DEFINE(HAVE_FULL_NAME_HASH_3ARGS, 1,
2066                         [full_name_hash need 3 arguments])
2067         ])
2068 ]) # LC_FULL_NAME_HASH_3ARGS
2069
2070 #
2071 # LC_STRUCT_POSIX_ACL_XATTR
2072 #
2073 # Kernel version 4.8 commit 2211d5ba5c6c4e972ba6dbc912b2897425ea6621
2074 # posix_acl: xattr representation cleanups
2075 #
2076 AC_DEFUN([LC_SRC_STRUCT_POSIX_ACL_XATTR], [
2077         LB2_LINUX_TEST_SRC([struct_posix_acl_xattr], [
2078                 #include <linux/fs.h>
2079                 #include <linux/posix_acl_xattr.h>
2080         ],[
2081                 struct posix_acl_xattr_header *h = NULL;
2082                 struct posix_acl_xattr_entry  *e;
2083                 e = (void *)(h + 1);
2084         ])
2085 ])
2086 AC_DEFUN([LC_STRUCT_POSIX_ACL_XATTR], [
2087         LB2_MSG_LINUX_TEST_RESULT([if 'struct posix_acl_xattr_{header,entry}' defined],
2088         [struct_posix_acl_xattr], [
2089                 AC_DEFINE(HAVE_STRUCT_POSIX_ACL_XATTR, 1,
2090                         [struct posix_acl_xattr_{header,entry} defined])
2091         ])
2092 ]) # LC_STRUCT_POSIX_ACL_XATTR
2093
2094 #
2095 # LC_IOP_XATTR
2096 #
2097 # Kernel version 4.8 commit fd50ecaddf8372a1d96e0daeaac0f93cf04e4d42
2098 # removed {get,set,remove}xattr inode operations
2099 #
2100 AC_DEFUN([LC_SRC_IOP_XATTR], [
2101         LB2_LINUX_TEST_SRC([inode_ops_xattr], [
2102                 #include <linux/fs.h>
2103         ],[
2104                 struct inode_operations iop;
2105                 iop.setxattr = NULL;
2106                 iop.getxattr = NULL;
2107                 iop.removexattr = NULL;
2108         ])
2109 ])
2110 AC_DEFUN([LC_IOP_XATTR], [
2111         LB2_MSG_LINUX_TEST_RESULT([if 'inode_operations' has {get,set,remove}xattr members],
2112         [inode_ops_xattr], [
2113                 AC_DEFINE(HAVE_IOP_XATTR, 1,
2114                         [inode_operations has {get,set,remove}xattr members])
2115         ])
2116 ]) # LC_IOP_XATTR
2117
2118 #
2119 # LC_GROUP_INFO_GID
2120 #
2121 # Kernel version 4.9 commit 81243eacfa400f5f7b89f4c2323d0de9982bb0fb
2122 # cred: simpler, 1D supplementary groups
2123 #
2124 AC_DEFUN([LC_SRC_GROUP_INFO_GID], [
2125         LB2_LINUX_TEST_SRC([group_info_gid], [
2126                 #include <linux/cred.h>
2127         ],[
2128                 kgid_t *p;
2129                 p = ((struct group_info *)0)->gid;
2130         ])
2131 ])
2132 AC_DEFUN([LC_GROUP_INFO_GID], [
2133         LB2_MSG_LINUX_TEST_RESULT([if 'struct group_info' has member 'gid'],
2134         [group_info_gid], [
2135                 AC_DEFINE(HAVE_GROUP_INFO_GID, 1,
2136                         [struct group_info has member gid])
2137         ])
2138 ]) # LC_GROUP_INFO_GID
2139
2140 #
2141 # LC_VFS_SETXATTR
2142 #
2143 # Kernel version 4.9 commit 5d6c31910bc0713e37628dc0ce677dcb13c8ccf4
2144 # added __vfs_{get,set,remove}xattr helpers
2145 #
2146 AC_DEFUN([LC_SRC_VFS_SETXATTR], [
2147         LB2_LINUX_TEST_SRC([vfs_setxattr], [
2148                 #include <linux/xattr.h>
2149         ],[
2150                 __vfs_setxattr(NULL, NULL, NULL, NULL, 0, 0);
2151         ])
2152 ])
2153 AC_DEFUN([LC_VFS_SETXATTR], [
2154         LB2_MSG_LINUX_TEST_RESULT([if '__vfs_setxattr' helper is available],
2155         [vfs_setxattr], [
2156                 AC_DEFINE(HAVE_VFS_SETXATTR, 1, ['__vfs_setxattr' is available])
2157         ])
2158 ]) # LC_VFS_SETXATTR
2159
2160 #
2161 # LC_POSIX_ACL_UPDATE_MODE
2162 #
2163 # Kernel version 4.9 commit 073931017b49d9458aa351605b43a7e34598caef
2164 # posix_acl: Clear SGID bit when setting file permissions
2165 #
2166 AC_DEFUN([LC_SRC_POSIX_ACL_UPDATE_MODE], [
2167         LB2_LINUX_TEST_SRC([posix_acl_update_mode], [
2168                 #include <linux/fs.h>
2169                 #include <linux/posix_acl.h>
2170         ],[
2171                 posix_acl_update_mode(NULL, NULL, NULL);
2172         ])
2173 ])
2174 AC_DEFUN([LC_POSIX_ACL_UPDATE_MODE], [
2175         LB2_MSG_LINUX_TEST_RESULT([if 'posix_acl_update_mode' exists],
2176         [posix_acl_update_mode], [
2177                 AC_DEFINE(HAVE_POSIX_ACL_UPDATE_MODE, 1,
2178                         ['posix_acl_update_mode' is available])
2179         ])
2180 ]) # LC_POSIX_ACL_UPDATE_MODE
2181
2182 #
2183 # LC_HAVE_BDI_IO_PAGES
2184 #
2185 # Kernel version 4.9 commit 9491ae4aade6814afcfa67f4eb3e3342c2b39750
2186 # mm: don't cap request size based on read-ahead setting
2187 # This patch introduces a bdi hint, io_pages.
2188 #
2189 AC_DEFUN([LC_SRC_HAVE_BDI_IO_PAGES], [
2190         LB2_LINUX_TEST_SRC([bdi_has_io_pages], [
2191                 #include <linux/backing-dev.h>
2192         ],[
2193                 struct backing_dev_info info;
2194
2195                 info.io_pages = 0;
2196         ])
2197 ])
2198 AC_DEFUN([LC_HAVE_BDI_IO_PAGES], [
2199         LB2_MSG_LINUX_TEST_RESULT([if 'struct backing_dev_info' has 'io_pages' field],
2200         [bdi_has_io_pages], [
2201                 AC_DEFINE(HAVE_BDI_IO_PAGES, 1,
2202                         [backing_dev_info has io_pages])
2203         ])
2204 ]) # LC_HAVE_BDI_IO_PAGES
2205
2206 #
2207 # LC_IOP_GENERIC_READLINK
2208 #
2209 # Kernel version 4.10 commit dfeef68862edd7d4bafe68ef7aeb5f658ef24bb5
2210 # removed generic_readlink from individual file systems
2211 #
2212 AC_DEFUN([LC_SRC_IOP_GENERIC_READLINK], [
2213         LB2_LINUX_TEST_SRC([inode_ops_readlink], [
2214                 #include <linux/fs.h>
2215         ],[
2216                 struct inode_operations iop;
2217                 iop.readlink = generic_readlink;
2218         ])
2219 ])
2220 AC_DEFUN([LC_IOP_GENERIC_READLINK], [
2221         LB2_MSG_LINUX_TEST_RESULT([if 'generic_readlink' still exist],
2222         [inode_ops_readlink], [
2223                 AC_DEFINE(HAVE_IOP_GENERIC_READLINK, 1,
2224                         [generic_readlink has been removed])
2225         ])
2226 ]) # LC_IOP_GENERIC_READLINK
2227
2228 #
2229 # LC_HAVE_VM_FAULT_ADDRESS
2230 #
2231 # Kernel version 4.10 commit 1a29d85eb0f19b7d8271923d8917d7b4f5540b3e
2232 # removed virtual_address field. Need to use address field instead
2233 #
2234 AC_DEFUN([LC_SRC_HAVE_VM_FAULT_ADDRESS], [
2235         LB2_LINUX_TEST_SRC([vm_fault_address], [
2236                 #include <linux/mm.h>
2237         ],[
2238                 struct vm_fault vmf = { 0 };
2239                 unsigned long addr = (unsigned long)vmf.address;
2240                 (void)addr;
2241         ])
2242 ])
2243 AC_DEFUN([LC_HAVE_VM_FAULT_ADDRESS], [
2244         LB2_MSG_LINUX_TEST_RESULT([if 'struct vm_fault' replaced virtual_address with address field],
2245         [vm_fault_address], [
2246                 AC_DEFINE(HAVE_VM_FAULT_ADDRESS, 1,
2247                         [virtual_address has been replaced by address field])
2248         ])
2249 ]) # LC_HAVE_VM_FAULT_ADDRESS
2250
2251 #
2252 # LC_INODEOPS_ENHANCED_GETATTR
2253 #
2254 # Kernel version 4.11 commit a528d35e8bfcc521d7cb70aaf03e1bd296c8493f
2255 # expanded getattr to be able to get more stat information.
2256 #
2257 AC_DEFUN([LC_SRC_INODEOPS_ENHANCED_GETATTR], [
2258         LB2_LINUX_TEST_SRC([getattr_path], [
2259                 #include <linux/fs.h>
2260         ],[
2261                 struct path path;
2262
2263                 ((struct inode_operations *)1)->getattr(&path, NULL, 0, 0);
2264         ])
2265 ])
2266 AC_DEFUN([LC_INODEOPS_ENHANCED_GETATTR], [
2267         LB2_MSG_LINUX_TEST_RESULT([if 'inode_operations' getattr member can gather advance stats],
2268         [getattr_path], [
2269                 AC_DEFINE(HAVE_INODEOPS_ENHANCED_GETATTR, 1,
2270                         [inode_operations .getattr member function can gather advance stats])
2271         ])
2272 ]) # LC_INODEOPS_ENHANCED_GETATTR
2273
2274 #
2275 # LC_VM_OPERATIONS_REMOVE_VMF_ARG
2276 #
2277 # Kernel version 4.11 commit 11bac80004499ea59f361ef2a5516c84b6eab675
2278 # removed struct vm_area_struct as an argument for vm_operations since
2279 # in the same kernel version struct vma_area_struct was folded into
2280 # struct vm_fault.
2281 #
2282 AC_DEFUN([LC_SRC_VM_OPERATIONS_REMOVE_VMF_ARG], [
2283         LB2_LINUX_TEST_SRC([vm_operations_no_vm_area_struct], [
2284                 #include <linux/mm.h>
2285         ],[
2286                 struct vm_fault vmf;
2287
2288                 ((struct vm_operations_struct *)0)->fault(&vmf);
2289                 ((struct vm_operations_struct *)0)->page_mkwrite(&vmf);
2290         ])
2291 ])
2292 AC_DEFUN([LC_VM_OPERATIONS_REMOVE_VMF_ARG], [
2293         LB2_MSG_LINUX_TEST_RESULT([if 'struct vm_operations' removed struct vm_area_struct],
2294         [vm_operations_no_vm_area_struct], [
2295                 AC_DEFINE(HAVE_VM_OPS_USE_VM_FAULT_ONLY, 1,
2296                         ['struct vm_operations' remove struct vm_area_struct argument])
2297         ])
2298 ]) # LC_VM_OPERATIONS_REMOVE_VMF_ARG
2299
2300 #
2301 # LC_HAVE_KEY_USAGE_REFCOUNT
2302 #
2303 # Kernel version 4.11 commit fff292914d3a2f1efd05ca71c2ba72a3c663201e
2304 # converted key.usage from atomic_t to refcount_t.
2305 #
2306 AC_DEFUN([LC_SRC_HAVE_KEY_USAGE_REFCOUNT], [
2307         LB2_LINUX_TEST_SRC([key_usage_refcount], [
2308                 #include <linux/key.h>
2309         ],[
2310                 struct key key = { };
2311
2312                 refcount_read(&key.usage);
2313         ])
2314 ])
2315 AC_DEFUN([LC_HAVE_KEY_USAGE_REFCOUNT], [
2316         LB2_MSG_LINUX_TEST_RESULT([if 'key.usage' is refcount_t],
2317         [key_usage_refcount], [
2318                 AC_DEFINE(HAVE_KEY_USAGE_REFCOUNT, 1,
2319                         [key.usage is of type refcount_t])
2320         ])
2321 ]) #LC_HAVE_KEY_USAGE_REFCOUNT
2322
2323 #
2324 # LC_HAVE_CRYPTO_MAX_ALG_NAME_128
2325 #
2326 # Kernel version 4.11 commit f437a3f477cce402dbec6537b29e9e33962c9f73
2327 # switched CRYPTO_MAX_ALG_NAME from 64 to 128.
2328 #
2329 AC_DEFUN([LC_SRC_HAVE_CRYPTO_MAX_ALG_NAME_128], [
2330         LB2_LINUX_TEST_SRC([crypto_max_alg_name], [
2331                 #include <linux/crypto.h>
2332         ],[
2333                 #if CRYPTO_MAX_ALG_NAME != 128
2334                 exit(1);
2335                 #endif
2336         ])
2337 ])
2338 AC_DEFUN([LC_HAVE_CRYPTO_MAX_ALG_NAME_128], [
2339         LB2_MSG_LINUX_TEST_RESULT([if 'CRYPTO_MAX_ALG_NAME' is 128],
2340         [crypto_max_alg_name], [
2341                 AC_DEFINE(HAVE_CRYPTO_MAX_ALG_NAME_128, 1,
2342                         ['CRYPTO_MAX_ALG_NAME' is 128])
2343         ])
2344 ]) # LC_HAVE_CRYPTO_MAX_ALG_NAME_128
2345
2346 #
2347 # LC_HAVE_FSMAP_HEADER
2348 #
2349 # Kernel version 4.11-rc4 commit 80c9f490f344be7999f57fc31a8ed956f8c65f3b
2350 # vfs: add common GETFSMAP ioctl definitions
2351 #
2352 AC_DEFUN([LC_SRC_HAVE_FSMAP_HEADER], [
2353         LB2_CHECK_LINUX_HEADER_SRC([linux/fsmap.h], [-Werror])
2354 ])
2355 AC_DEFUN([LC_HAVE_FSMAP_HEADER], [
2356         LB2_CHECK_LINUX_HEADER_RESULT([linux/fsmap.h], [
2357                 AC_DEFINE(HAVE_FSMAP_H, 1,
2358                         [fsmap.h is present])
2359         ])
2360 ]) # LC_HAVE_FSMAP_HEADER
2361
2362 #
2363 # LC_HAVE_PERCPU_COUNTER_ADD_BATCH
2364 #
2365 # Linux commit v4.11-12447-g104b4e5139fe
2366 #   percpu_counter: Rename __percpu_counter_add to percpu_counter_add_batch
2367 #
2368 AC_DEFUN([LC_SRC_HAVE_PERCPU_COUNTER_ADD_BATCH], [
2369         LB2_LINUX_TEST_SRC([percpu_counter_add_batch_exists], [
2370                 #include <linux/percpu_counter.h>
2371         ],[
2372                 (void)percpu_counter_add_batch(NULL, 0, 0);
2373         ],[-Werror])
2374 ])
2375 AC_DEFUN([LC_HAVE_PERCPU_COUNTER_ADD_BATCH], [
2376         LB2_MSG_LINUX_TEST_RESULT([if 'percpu_counter_add_batch()' exists],
2377         [percpu_counter_add_batch_exists], [
2378                 AC_DEFINE(HAVE_PERCPU_COUNTER_ADD_BATCH, 1,
2379                         ['percpu_counter_add_batch()' exists])
2380         ])
2381 ]) # LC_HAVE_PERCPU_COUNTER_ADD_BATCH
2382
2383 #
2384 # Kernel version 4.12 commit 47f38c539e9a42344ff5a664942075bd4df93876
2385 # CURRENT_TIME is not 64 bit time safe so it was replaced with
2386 # current_time()
2387 #
2388 AC_DEFUN([LC_SRC_CURRENT_TIME], [
2389         LB2_LINUX_TEST_SRC([current_time], [
2390                 #include <linux/fs.h>
2391         ],[
2392                 struct iattr attr;
2393
2394                 attr.ia_atime = current_time(NULL);
2395         ])
2396 ])
2397 AC_DEFUN([LC_CURRENT_TIME], [
2398         LB2_MSG_LINUX_TEST_RESULT([if CURRENT_TIME has been replaced with current_time],
2399         [current_time], [
2400                 AC_DEFINE(HAVE_CURRENT_TIME, 1,
2401                         [current_time() has replaced CURRENT_TIME])
2402         ])
2403 ]) # LC_CURRENT_TIME
2404
2405 #
2406 # LC_HAVE_GET_INODE_USAGE
2407 #
2408 # Kernel version v4.12-rc2-43-g7a9ca53aea10
2409 #
2410 AC_DEFUN([LC_SRC_HAVE_GET_INODE_USAGE], [
2411         LB2_LINUX_TEST_SRC([get_inode_usage], [
2412                 struct inode;
2413                 #include <linux/quota.h>
2414         ],[
2415                 struct dquot_operations ops = { };
2416
2417                 ops.get_inode_usage(NULL, NULL);
2418         ])
2419 ])
2420 AC_DEFUN([LC_HAVE_GET_INODE_USAGE], [
2421         LB2_MSG_LINUX_TEST_RESULT([if get_inode_usage exists],
2422         [get_inode_usage], [
2423                 AC_DEFINE(HAVE_GET_INODE_USAGE, 1,
2424                         [get_inode_usage function exists])
2425         ])
2426 ]) # LC_HAVE_GET_INODE_USAGE
2427
2428 #
2429 # LC_SUPER_SETUP_BDI_NAME
2430 #
2431 # Kernel version 4.12 commit 9594caf216dc0fe3e318b34af0127276db661241
2432 # unified bdi handling
2433 #
2434 AC_DEFUN([LC_SRC_SUPER_SETUP_BDI_NAME], [
2435         LB2_LINUX_TEST_SRC([super_setup_bdi_name], [
2436                 #include <linux/fs.h>
2437         ],[
2438                 super_setup_bdi_name(NULL, "lustre");
2439         ])
2440 ])
2441 AC_DEFUN([LC_SUPER_SETUP_BDI_NAME], [
2442         LB2_MSG_LINUX_TEST_RESULT([if 'super_setup_bdi_name' exist],
2443         [super_setup_bdi_name], [
2444                 AC_DEFINE(HAVE_SUPER_SETUP_BDI_NAME, 1,
2445                         ['super_setup_bdi_name' is available])
2446         ])
2447 ]) # LC_SUPER_SETUP_BDI_NAME
2448
2449 #
2450 # LC_BI_STATUS
2451 #
2452 # 4.12 replace bi_error to bi_status
2453 #
2454 AC_DEFUN([LC_SRC_BI_STATUS], [
2455         LB2_LINUX_TEST_SRC([bi_status], [
2456                 #include <linux/blk_types.h>
2457         ],[
2458                 ((struct bio *)0)->bi_status = 0;
2459         ])
2460 ])
2461 AC_DEFUN([LC_BI_STATUS], [
2462         LB2_MSG_LINUX_TEST_RESULT([if 'bi_status' exist],
2463         [bi_status], [
2464                 AC_DEFINE(HAVE_BI_STATUS, 1, ['bi_status' is available])
2465         ])
2466 ]) # LC_BI_STATUS
2467
2468 #
2469 # LC_PAGEVEC_INIT_ONE_PARAM
2470 #
2471 # 4.14 pagevec_init takes one parameter
2472 #
2473 AC_DEFUN([LC_SRC_PAGEVEC_INIT_ONE_PARAM], [
2474         LB2_LINUX_TEST_SRC([pagevec_init], [
2475                 #include <linux/pagevec.h>
2476         ],[
2477                 pagevec_init(NULL);
2478         ])
2479 ])
2480 AC_DEFUN([LC_PAGEVEC_INIT_ONE_PARAM], [
2481         LB2_MSG_LINUX_TEST_RESULT([if 'pagevec_init' takes one parameter],
2482         [pagevec_init], [
2483                 AC_DEFINE(HAVE_PAGEVEC_INIT_ONE_PARAM, 1,
2484                         ['pagevec_init' takes one parameter])
2485         ])
2486 ]) # LC_PAGEVEC_INIT_ONE_PARAM
2487
2488 #
2489 # LC_BI_BDEV
2490 #
2491 # 4.14 replaced bi_bdev to bi_disk
2492 #
2493 AC_DEFUN([LC_SRC_BI_BDEV], [
2494         LB2_LINUX_TEST_SRC([bi_bdev], [
2495                 #include <linux/bio.h>
2496         ],[
2497                 ((struct bio *)0)->bi_bdev = NULL;
2498         ])
2499 ])
2500 AC_DEFUN([LC_BI_BDEV], [
2501         LB2_MSG_LINUX_TEST_RESULT([if 'bi_bdev' exist],
2502         [bi_bdev], [
2503                 AC_DEFINE(HAVE_BI_BDEV, 1, ['bi_bdev' is available])
2504         ])
2505 ]) # LC_BI_BDEV
2506
2507 #
2508 # LC_INTERVAL_TREE_CACHED
2509 #
2510 # 4.14 f808c13fd3738948e10196496959871130612b61
2511 # switched INTERVAL_TREE_DEFINE to use cached RB_Trees.
2512 #
2513 AC_DEFUN([LC_SRC_INTERVAL_TREE_CACHED], [
2514         LB2_LINUX_TEST_SRC([itree_cached], [
2515                 #include <linux/interval_tree_generic.h>
2516                 struct foo { struct rb_node rb; int last; int a,b;};
2517                 #define START(n) ((n)->a)
2518                 #define LAST(n) ((n)->b)
2519                 struct rb_root_cached tree;
2520                 INTERVAL_TREE_DEFINE(struct foo, rb, int, last,
2521                         START, LAST, , foo);
2522         ],[
2523                 foo_insert(NULL, &tree);
2524         ],[-Werror])
2525 ])
2526 AC_DEFUN([LC_INTERVAL_TREE_CACHED], [
2527         LB2_MSG_LINUX_TEST_RESULT([if interval_trees use rb_tree_cached],
2528         [itree_cached], [
2529                 AC_DEFINE(HAVE_INTERVAL_TREE_CACHED, 1,
2530                         [interval trees use rb_tree_cached])
2531         ])
2532 ]) # LC_INTERVAL_TREE_CACHED
2533
2534 #
2535 # LC_IS_ENCRYPTED
2536 #
2537 # 4.14 introduced IS_ENCRYPTED and S_ENCRYPTED
2538 #
2539 AC_DEFUN([LC_IS_ENCRYPTED], [
2540 LB_CHECK_COMPILE([if IS_ENCRYPTED is defined],
2541 is_encrypted, [
2542         #include <linux/fs.h>
2543 ],[
2544         (void)IS_ENCRYPTED((struct inode *)1);
2545 ],[
2546         has_is_encrypted="yes"
2547 ])
2548 ]) # LC_IS_ENCRYPTED used by LC_CONFIG_CRYPTO
2549
2550 #
2551 # LC_I_PAGES
2552 #
2553 # kernel 4.17 commit b93b016313b3ba8003c3b8bb71f569af91f19fc7
2554 #
2555 AC_DEFUN([LC_SRC_I_PAGES], [
2556         LB2_LINUX_TEST_SRC([i_pages], [
2557                 #include <linux/fs.h>
2558         ],[
2559                 struct address_space mapping = {};
2560                 void *i_pages;
2561
2562                 i_pages = &mapping.i_pages;
2563         ])
2564 ])
2565 AC_DEFUN([LC_I_PAGES], [
2566         LB2_MSG_LINUX_TEST_RESULT([if struct address_space has i_pages],
2567         [i_pages], [
2568                 AC_DEFINE(HAVE_I_PAGES, 1, [struct address_space has i_pages])
2569         ])
2570 ]) # LC_I_PAGES
2571
2572 #
2573 # LC_VM_FAULT_T
2574 #
2575 # kernel 4.17 commit 3d3539018d2cbd12e5af4a132636ee7fd8d43ef0
2576 # mm: create the new vm_fault_t type
2577 #
2578 AC_DEFUN([LC_SRC_VM_FAULT_T], [
2579         LB2_LINUX_TEST_SRC([vm_fault_t], [
2580                 #include <linux/mm_types.h>
2581         ],[
2582                 vm_fault_t x = VM_FAULT_SIGBUS;
2583                 (void)x
2584         ])
2585 ])
2586 AC_DEFUN([LC_VM_FAULT_T], [
2587         LB2_MSG_LINUX_TEST_RESULT([if vm_fault_t type exists],
2588         [vm_fault_t], [
2589                 AC_DEFINE(HAVE_VM_FAULT_T, 1, [if vm_fault_t type exists])
2590         ])
2591 ]) # LC_VM_FAULT_T
2592
2593 #
2594 # LC_VM_FAULT_RETRY
2595 #
2596 # kernel 4.17 commit 3d3539018d2cbd12e5af4a132636ee7fd8d43ef0
2597 # mm: VM_FAULT_RETRY is defined in enum vm_fault_reason
2598 #
2599 AC_DEFUN([LC_SRC_VM_FAULT_RETRY], [
2600         LB2_LINUX_TEST_SRC([VM_FAULT_RETRY], [
2601                 #include <linux/mm.h>
2602         ],[
2603                 #ifndef VM_FAULT_RETRY
2604                         vm_fault_t x;
2605                         x = VM_FAULT_RETRY;
2606                 #endif
2607         ])
2608 ])
2609 AC_DEFUN([LC_VM_FAULT_RETRY], [
2610         LB2_MSG_LINUX_TEST_RESULT([if VM_FAULT_RETRY is defined],
2611         [VM_FAULT_RETRY], [
2612                 AC_DEFINE(HAVE_VM_FAULT_RETRY, 1,
2613                         [if VM_FAULT_RETRY is defined])
2614         ])
2615 ]) # LC_VM_FAULT_RETRY
2616
2617 #
2618 # LC_ALLOC_FILE_PSEUDO
2619 #
2620 # kernel 4.18-rc1 commit d93aa9d82aea80b80f225dbf9c7986df444d8106
2621 # new wrapper: alloc_file_pseudo()
2622 #
2623 AC_DEFUN([LC_SRC_ALLOC_FILE_PSEUDO], [
2624         LB2_LINUX_TEST_SRC([alloc_file_pseudo], [
2625                 #include <linux/file.h>
2626         ],[
2627                 struct file *file;
2628                 file = alloc_file_pseudo(NULL, NULL, "[test]",
2629                                          00000002, NULL);
2630         ])
2631 ])
2632 AC_DEFUN([LC_ALLOC_FILE_PSEUDO], [
2633         LB2_MSG_LINUX_TEST_RESULT([if 'alloc_file_pseudo' is defined],
2634         [alloc_file_pseudo], [
2635                 AC_DEFINE(HAVE_ALLOC_FILE_PSEUDO, 1,
2636                         ['alloc_file_pseudo' exist])
2637         ])
2638 ]) # LC_ALLOC_FILE_PSEUDO
2639
2640 #
2641 # LC_INODE_TIMESPEC64
2642 #
2643 # kernel 4.17-rc7 commit 8efd6894ff089adeeac7cb9f32125b85d963d1bc
2644 # fs: add timespec64_truncate()
2645 # kernel 4.18 commit 95582b00838837fc07e042979320caf917ce3fe6
2646 # inode timestamps switched to timespec64
2647 # kernel 4.19-rc2 commit 976516404ff3fab2a8caa8bd6f5efc1437fed0b8
2648 # y2038: remove unused time interfaces
2649 # ...
2650 #  timespec_trunc
2651 # ...
2652 # When inode times are timespec64 stop using the deprecated
2653 # time interfaces.
2654 #
2655 # kernel v5.5-rc1-6-gba70609d5ec6 ba70609d5ec664a8f36ba1c857fcd97a478adf79
2656 # fs: Delete timespec64_trunc()
2657 #
2658 AC_DEFUN([LC_SRC_INODE_TIMESPEC64], [
2659         LB2_LINUX_TEST_SRC([inode_timespec64], [
2660                 #include <linux/fs.h>
2661         ],[
2662                 struct inode *inode = NULL;
2663                 struct timespec64 ts = {0, 1};
2664
2665                 inode->i_atime = ts;
2666                 (void)inode;
2667         ],[-Werror])
2668 ])
2669 AC_DEFUN([LC_INODE_TIMESPEC64], [
2670         LB2_MSG_LINUX_TEST_RESULT([if inode timestamps are struct timespec64],
2671         [inode_timespec64], [
2672                 AC_DEFINE(HAVE_INODE_TIMESPEC64, 1,
2673                         [inode times are using timespec64])
2674         ])
2675 ]) # LC_INODE_TIMESPEC64
2676
2677 #
2678 # LC_RADIX_TREE_TAG_SET
2679 #
2680 # kernel 4.20 commit v4.19-rc5-248-g9b89a0355144
2681 # xarray: Add XArray marks - replaced radix_tree_tag_set
2682 #
2683 AC_DEFUN([LC_SRC_RADIX_TREE_TAG_SET], [
2684         LB2_LINUX_TEST_SRC([radix_tree_tag_set], [
2685                 #include <linux/fs.h>
2686                 #include <linux/radix-tree.h>
2687         ],[
2688                 radix_tree_tag_set(NULL, 0, PAGECACHE_TAG_DIRTY);
2689         ],[-Werror])
2690 ])
2691 AC_DEFUN([LC_RADIX_TREE_TAG_SET], [
2692         LB2_MSG_LINUX_TEST_RESULT([if 'radix_tree_tag_set' exists],
2693         [radix_tree_tag_set], [
2694                 AC_DEFINE(HAVE_RADIX_TREE_TAG_SET, 1,
2695                         [radix_tree_tag_set exists])
2696         ])
2697 ]) # LC_RADIX_TREE_TAG_SET
2698
2699 #
2700 # LC_UAPI_LINUX_MOUNT_H
2701 #
2702 # kernel 4.20 commit e262e32d6bde0f77fb0c95d977482fc872c51996
2703 # vfs: Suppress MS_* flag defs within the kernel ...
2704 #
2705 AC_DEFUN([LC_SRC_UAPI_LINUX_MOUNT_H], [
2706         LB2_LINUX_TEST_SRC([uapi_linux_mount], [
2707                 #include <uapi/linux/mount.h>
2708         ],[
2709                 int x = MS_RDONLY;
2710                 (void)x;
2711         ],[-Werror])
2712 ])
2713 AC_DEFUN([LC_UAPI_LINUX_MOUNT_H], [
2714         LB2_MSG_LINUX_TEST_RESULT([if MS_RDONLY was moved to uapi/linux/mount.h],
2715         [uapi_linux_mount], [
2716                 AC_DEFINE(HAVE_UAPI_LINUX_MOUNT_H, 1,
2717                         [if MS_RDONLY was moved to uapi/linux/mount.h])
2718         ])
2719 ]) # LC_UAPI_LINUX_MOUNT_H
2720
2721 #
2722 # LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
2723 #
2724 # kernel 4.20 commit 1863d77f15da0addcd293a1719fa5d3ef8cde3ca
2725 # SUNRPC: Replace the cache_detail->hash_lock with a regular spinlock
2726 #
2727 # Now that the reader functions are all RCU protected, use a regular
2728 # spinlock rather than a reader/writer lock.
2729 #
2730 AC_DEFUN([LC_SRC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK], [
2731         LB2_LINUX_TEST_SRC([hash_lock_isa_spinlock_t], [
2732                 #include <linux/sunrpc/cache.h>
2733         ],[
2734                 spinlock_t *lock = &(((struct cache_detail *)0)->hash_lock);
2735                 spin_lock(lock);
2736         ],[-Werror])
2737 ])
2738 AC_DEFUN([LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK], [
2739         LB2_MSG_LINUX_TEST_RESULT([if cache_detail->hash_lock is a spinlock],
2740         [hash_lock_isa_spinlock_t], [
2741                 AC_DEFINE(HAVE_CACHE_HASH_SPINLOCK, 1,
2742                         [if cache_detail->hash_lock is a spinlock])
2743         ])
2744 ]) # LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
2745
2746 #
2747 # LC_GENL_FAMILY_HAS_RESV_START_OP
2748 #
2749 # Linux v5.0-11693-g3b0f31f2b8c9
2750 #   genetlink: make policy common to family
2751 #
2752 AC_DEFUN([LC_SRC_GENL_FAMILY_HAS_RESV_START_OP], [
2753         LB2_LINUX_TEST_SRC([genl_family_has_resv_start_op], [
2754                 #include <net/genetlink.h>
2755         ],[
2756                 static const struct genl_family family = {
2757                         .resv_start_op = 42,
2758                 };
2759                 (void)family;
2760         ],[-Werror])
2761 ])
2762 AC_DEFUN([LC_GENL_FAMILY_HAS_RESV_START_OP], [
2763         LB2_MSG_LINUX_TEST_RESULT([if struct genl_family has resv_start_op member],
2764         [genl_family_has_resv_start_op], [
2765                 AC_DEFINE(GENL_FAMILY_HAS_RESV_START_OP, 1,
2766                         [struct genl_family has resv_start_op member])
2767         ])
2768 ]) # LC_GENL_FAMILY_HAS_RESV_START_OP
2769
2770 #
2771 # LC_HAVE_BVEC_ITER_ALL
2772 #
2773 # kernel 5.1 commit 6dc4f100c175dd0511ae8674786e7c9006cdfbfa
2774 # block: allow bio_for_each_segment_all() to iterate over multi-page bvec
2775 #
2776 AC_DEFUN([LC_SRC_HAVE_BVEC_ITER_ALL], [
2777         LB2_LINUX_TEST_SRC([struct_bvec_iter_all], [
2778                 #include <linux/bvec.h>
2779         ],[
2780                 struct bvec_iter_all iter;
2781                 (void)iter;
2782         ],[-Werror])
2783 ])
2784 AC_DEFUN([LC_HAVE_BVEC_ITER_ALL], [
2785         LB2_MSG_LINUX_TEST_RESULT([if bvec_iter_all exists for multi-page bvec iternation],
2786         [struct_bvec_iter_all], [
2787                 AC_DEFINE(HAVE_BVEC_ITER_ALL, 1,
2788                         [if bvec_iter_all exists for multi-page bvec iternation])
2789         ])
2790 ]) # LC_HAVE_BVEC_ITER_ALL
2791
2792 #
2793 # LC_ACCOUNT_PAGE_DIRTIED
2794 #
2795 # After 5.2 kernel page dirtied is not exported
2796 #
2797 AC_DEFUN([LC_ACCOUNT_PAGE_DIRTIED], [
2798 LB_CHECK_EXPORT([account_page_dirtied], [mm/page-writeback.c],
2799         [AC_DEFINE(HAVE_ACCOUNT_PAGE_DIRTIED_EXPORT, 1,
2800                         [account_page_dirtied is exported])])
2801 ]) # LC_ACCOUNT_PAGE_DIRTIED
2802
2803 #
2804 # LC_KEYRING_SEARCH_4ARGS
2805 #
2806 # Kernel 5.2 commit dcf49dbc8077
2807 # keys: Add a 'recurse' flag for keyring searches
2808 #
2809 AC_DEFUN([LC_SRC_KEYRING_SEARCH_4ARGS], [
2810         LB2_LINUX_TEST_SRC([keyring_search_4args], [
2811                 #include <linux/key.h>
2812         ],[
2813                 key_ref_t keyring;
2814                 keyring_search(keyring, NULL, NULL, false);
2815         ])
2816 ])
2817 AC_DEFUN([LC_KEYRING_SEARCH_4ARGS], [
2818         LB2_MSG_LINUX_TEST_RESULT([if 'keyring_search' has 4 args],
2819         [keyring_search_4args], [
2820                 AC_DEFINE(HAVE_KEYRING_SEARCH_4ARGS, 1,
2821                         [keyring_search has 4 args])
2822         ])
2823 ]) # LC_KEYRING_SEARCH_4ARGS
2824
2825 #
2826 # LC_BIO_BI_PHYS_SEGMENTS
2827 #
2828 # kernel 5.3-rc1 commit 14ccb66b3f585b2bc21e7256c96090abed5a512c
2829 # block: remove the bi_phys_segments field in struct bio
2830 #
2831 AC_DEFUN([LC_SRC_BIO_BI_PHYS_SEGMENTS], [
2832         LB2_LINUX_TEST_SRC([bye_bio_bi_phys_segments], [
2833                 #include <linux/bio.h>
2834         ],[
2835                 struct bio *bio = NULL;
2836                 bio->bi_phys_segments++;
2837         ],[-Werror])
2838 ])
2839 AC_DEFUN([LC_BIO_BI_PHYS_SEGMENTS], [
2840         LB2_MSG_LINUX_TEST_RESULT([if struct bio has bi_phys_segments member],
2841         [bye_bio_bi_phys_segments], [
2842                 AC_DEFINE(HAVE_BIO_BI_PHYS_SEGMENTS, 1,
2843                         [struct bio has bi_phys_segments member])
2844         ])
2845 ]) # LC_BIO_BI_PHYS_SEGMENTS
2846
2847 #
2848 # LC_HAVE_FLUSH_DELAYED_FPUT
2849 #
2850 # kernel commit v3.5-rc6-284-g4a9d4b024a31 adds flush_delayed_fput()
2851 # kernel commit v5.3-rc2-13-g7239a40ca8bf exports flush_delayed_fput()
2852 #
2853 AC_DEFUN([LC_HAVE_FLUSH_DELAYED_FPUT], [
2854 LB_CHECK_EXPORT([flush_delayed_fput], [fs/file_table.c],
2855         [AC_DEFINE(HAVE_FLUSH_DELAYED_FPUT, 1,
2856                         [flush_delayed_fput() is exported by the kernel])])
2857 ]) # LC_FLUSH_DELAYED_FPUT
2858
2859 #
2860 # LC_LM_COMPARE_OWNER_EXISTS
2861 #
2862 # kernel 5.3-rc3 commit f85d93385e9fe6886a751f647f6812a89bf6bee3
2863 # locks: Cleanup lm_compare_owner and lm_owner_key
2864 # removed lm_compare_owner
2865 #
2866 AC_DEFUN([LC_SRC_LM_COMPARE_OWNER_EXISTS], [
2867         LB2_LINUX_TEST_SRC([lock_manager_ops_lm_compare_owner], [
2868                 #include <linux/fs.h>
2869         ],[
2870                 struct lock_manager_operations lm_ops;
2871                 lm_ops.lm_compare_owner = NULL;
2872         ],[-Werror])
2873 ])
2874 AC_DEFUN([LC_LM_COMPARE_OWNER_EXISTS], [
2875         LB2_MSG_LINUX_TEST_RESULT([if lock_manager_operations has lm_compare_owner],
2876         [lock_manager_ops_lm_compare_owner], [
2877                 AC_DEFINE(HAVE_LM_COMPARE_OWNER, 1,
2878                         [lock_manager_operations has lm_compare_owner])
2879         ])
2880 ]) # LC_LM_COMPARE_OWNER_EXISTS
2881
2882 #
2883 # LC_FSCRYPT_SUPPORT
2884 #
2885 # 5.4 introduced fscrypt encryption policies v2
2886 #
2887 AC_DEFUN([LC_FSCRYPT_SUPPORT], [
2888 LB_CHECK_COMPILE([for fscrypt in-kernel support],
2889 fscrypt_support, [
2890         #define __FS_HAS_ENCRYPTION 0
2891         #include <linux/fscrypt.h>
2892 ],[
2893         fscrypt_ioctl_get_policy_ex(NULL, NULL);
2894 ],[
2895         has_fscrypt_support="yes"
2896 ])
2897 ]) # LC_FSCRYPT_SUPPORT used by LC_CONFIG_CRYPTO
2898
2899 #
2900 # LC_FSCRYPT_DIGESTED_NAME
2901 #
2902 # Kernel 5.5-rc4 edc440e3d27fb31e6f9663cf413fad97d714c060
2903 # improved the format of no-key names. This results in the
2904 # removal of FSCRYPT_FNAME_DIGEST and FSCRYPT_FNAME_DIGEST_SIZE.
2905 #
2906 AC_DEFUN([LC_SRC_FSCRYPT_DIGESTED_NAME], [
2907         LB2_LINUX_TEST_SRC([fscrypt_digested_name], [
2908                 #include <linux/fscrypt.h>
2909         ],[
2910                 struct fscrypt_digested_name fname;
2911
2912                 fname.hash = 0;
2913         ],[-Werror])
2914 ])
2915 AC_DEFUN([LC_FSCRYPT_DIGESTED_NAME], [
2916         LB2_MSG_LINUX_TEST_RESULT([if fscrypt has 'struct fscrypt_digested_name'],
2917         [fscrypt_digested_name], [
2918                 AC_DEFINE(HAVE_FSCRYPT_DIGESTED_NAME, 1,
2919                         ['struct fscrypt_digested_name' exists])
2920         ])
2921 ]) # LC_FSCRYPT_DIGESTED_NAME
2922
2923 #
2924 # LC_FSCRYPT_DUMMY_CONTEXT_ENABLED
2925 #
2926 # Kernel 5.7-rc7 ed318a6cc0b620440e65f48eb527dc3df7269ce4
2927 # replaces fscrypt_dummy_context_enabled() with
2928 # fscrypt_get_dummy_context(). Later kernels rename
2929 # fscrypt_get_dummy_context() to fscrypt_get_dummy_policy()
2930 # which is why we test fscrypt_dummy_context_enabled().
2931 #
2932 AC_DEFUN([LC_SRC_FSCRYPT_DUMMY_CONTEXT_ENABLED], [
2933         LB2_LINUX_TEST_SRC([fscrypt_dummy_context_enabled], [
2934                 #include <linux/fscrypt.h>
2935         ],[
2936                 fscrypt_dummy_context_enabled(NULL);
2937         ],[-Werror])
2938 ])
2939 AC_DEFUN([LC_FSCRYPT_DUMMY_CONTEXT_ENABLED], [
2940         LB2_MSG_LINUX_TEST_RESULT([if fscrypt_dummy_context_enabled() exists],
2941         [fscrypt_dummy_context_enabled], [
2942                 AC_DEFINE(HAVE_FSCRYPT_DUMMY_CONTEXT_ENABLED, 1,
2943                         [fscrypt_dummy_context_enabled() exists])
2944         ])
2945 ]) # LC_FSCRYPT_DUMMY_CONTEXT_ENABLED
2946
2947 #
2948 # LC_HAVE_KTHREAD_USE_MM
2949 #
2950 # kernel 5.8 commit f5678e7f2ac31c270334b936352f0ef2fe7dd2b3
2951 # kernel: better document the use_mm/unuse_mm API contract
2952 #
2953 AC_DEFUN([LC_SRC_HAVE_KTHREAD_USE_MM], [
2954         LB2_LINUX_TEST_SRC([kthread_use_mm], [
2955                 #include <linux/kthread.h>
2956         ],[
2957                 kthread_use_mm(NULL);
2958         ])
2959 ])
2960 AC_DEFUN([LC_HAVE_KTHREAD_USE_MM], [
2961         LB2_MSG_LINUX_TEST_RESULT([if have kthread_use_mm], [kthread_use_mm], [
2962                 AC_DEFINE(HAVE_KTHREAD_USE_MM, 1, ['kthread_use_mm' exists])
2963         ])
2964 ]) # LC_HAVE_KTHREAD_USE_MM
2965
2966 #
2967 # LC_FSCRYPT_FNAME_ALLOC_BUFFER
2968 #
2969 # Kernel 5.9-rc4 8b10fe68985278de4926daa56ad6af701839e40a
2970 # removed the inode parameter for the fscrypt function
2971 # fscrypt_fname_alloc_buffer()
2972 #
2973 AC_DEFUN([LC_SRC_FSCRYPT_FNAME_ALLOC_BUFFER], [
2974         LB2_LINUX_TEST_SRC([fscrypt_fname_alloc_buffer], [
2975                 #include <linux/fscrypt.h>
2976         ],[
2977                 fscrypt_fname_alloc_buffer(0, NULL);
2978         ],[-Werror])
2979 ])
2980 AC_DEFUN([LC_FSCRYPT_FNAME_ALLOC_BUFFER], [
2981         LB2_MSG_LINUX_TEST_RESULT([if fscrypt_fname_alloc_buffer() removed inode parameter],
2982         [fscrypt_fname_alloc_buffer], [
2983         AC_DEFINE(HAVE_FSCRYPT_FNAME_ALLOC_BUFFER_NO_INODE, 1,
2984                 [fscrypt_fname_alloc_buffer() does not have inode parameter])
2985         ])
2986 ]) # LC_FSCRYPT_FNAME_ALLOC_BUFFER
2987
2988 #
2989 # LC_FSCRYPT_SET_CONTEXT
2990 #
2991 # Kernel 5.9-rc4 a992b20cd4ee360dbbe6f69339cb07146e4304d6
2992 # fscrypt_get_encryption_info() is not GFP_NOFS safe which
2993 # is used by fscrypt_inherit_context. Replace fscrypt_inherit_context,
2994 # with two new functions, fscrypt_prepare_new_inode() and
2995 # fscrypt_set_context()
2996 #
2997 AC_DEFUN([LC_SRC_FSCRYPT_SET_CONTEXT], [
2998         LB2_LINUX_TEST_SRC([fscrypt_set_context], [
2999                 #include <linux/fscrypt.h>
3000         ],[
3001                 fscrypt_set_context(NULL, NULL);
3002                 fscrypt_prepare_new_inode(NULL, NULL, NULL);
3003         ])
3004 ])
3005 AC_DEFUN([LC_FSCRYPT_SET_CONTEXT], [
3006         LB2_MSG_LINUX_TEST_RESULT([if 'fscrypt_set_context()' exists],
3007         [fscrypt_set_context], [
3008                 AC_DEFINE(HAVE_FSCRYPT_SET_CONTEXT, 1,
3009                         [fscrypt_set_context() does exist])
3010         ])
3011 ]) # LC_FSCRYPT_SET_CONTEXT
3012
3013 #
3014 # LC_FSCRYPT_D_REVALIDATE
3015 #
3016 # kernel 5.9-rc4 5b2a828b98ec1872799b1b4d82113c76a12d594f
3017 # exported fscrypt_d_revalidate()
3018 #
3019 AC_DEFUN([LC_FSCRYPT_D_REVALIDATE], [
3020 LB_CHECK_EXPORT([fscrypt_d_revalidate], [fs/crypto/fname.c],
3021         [AC_DEFINE(HAVE_FSCRYPT_D_REVALIDATE, 1,
3022                    [fscrypt_d_revalidate() is exported by the kernel])])
3023 ]) # LC_FSCRYPT_D_REVALIDATE
3024
3025 #
3026 # LC_FSCRYPT_NOKEY_NAME
3027 #
3028 # kernel 5.9-rc4 70fb2612aab62d47e03f82eaa7384a8d30ca175d
3029 # renamed is_ciphertext_name to is_nokey_name
3030 #
3031 AC_DEFUN([LC_SRC_FSCRYPT_NOKEY_NAME], [
3032         LB2_LINUX_TEST_SRC([fname_is_nokey_name], [
3033                 #include <linux/fscrypt.h>
3034         ],[
3035                 struct fscrypt_name fname;
3036
3037                 fname.is_nokey_name = true;
3038         ],[-Werror])
3039 ])
3040 AC_DEFUN([LC_FSCRYPT_NOKEY_NAME], [
3041         LB2_MSG_LINUX_TEST_RESULT([if struct fscrypt_name has is_nokey_name field],
3042         [fname_is_nokey_name], [
3043                 AC_DEFINE(HAVE_FSCRYPT_NOKEY_NAME, 1,
3044                         [struct fscrypt_name has is_nokey_name field])
3045         ])
3046 ]) # LC_FSCRYPT_NOKEY_NAME
3047
3048 #
3049 # LC_FSCRYPT_SET_TEST_DUMMY_ENC_CHAR_ARG
3050 # Kernel 5.9-rc4 c8c868abc91ff23f6f5c4444c419de7c277d77e1
3051 # changed fscrypt_set_test_dummy_encryption() take a 'const char *
3052 #
3053 AC_DEFUN([LC_SRC_FSCRYPT_SET_TEST_DUMMY_ENC_CHAR_ARG], [
3054         LB2_LINUX_TEST_SRC([fscrypt_set_test_dummy_encryption], [
3055                 #include <linux/fscrypt.h>
3056         ],[
3057                 char *arg = "arg";
3058                 fscrypt_set_test_dummy_encryption(NULL, arg, NULL);
3059         ],[-Werror])
3060 ])
3061 AC_DEFUN([LC_FSCRYPT_SET_TEST_DUMMY_ENC_CHAR_ARG], [
3062         LB2_MSG_LINUX_TEST_RESULT([if fscrypt_set_test_dummy_encryption() take 'const char' parameter],
3063         [fscrypt_set_test_dummy_encryption], [
3064                 AC_DEFINE(HAVE_FSCRYPT_SET_TEST_DUMMY_ENC_CHAR_ARG, 1,
3065                         [fscrypt_set_test_dummy_encryption() take 'const char' parameter])
3066         ])
3067 ]) # LC_FSCRYPT_SET_TEST_DUMMY_ENC_CHAR_ARG
3068
3069 #
3070 # LC_FSCRYPT_DUMMY_POLICY
3071 #
3072 # Kernel 5.9-rc4 ac4acb1f4b2b6b7e8d913537cccec8789903e164
3073 # move the test dummy context for fscrypt_policy which is
3074 # also used by the user land interface.
3075 #
3076 AC_DEFUN([LC_SRC_FSCRYPT_DUMMY_POLICY], [
3077         LB2_LINUX_TEST_SRC([fscrypt_free_dummy_policy], [
3078                 #include <linux/fscrypt.h>
3079         ],[
3080                 fscrypt_free_dummy_policy(NULL);
3081         ],[-Werror])
3082 ])
3083 AC_DEFUN([LC_FSCRYPT_DUMMY_POLICY], [
3084         LB2_MSG_LINUX_TEST_RESULT([if fscrypt_free_dummy_policy() exists],
3085         [fscrypt_free_dummy_policy], [
3086                 AC_DEFINE(HAVE_FSCRYPT_DUMMY_POLICY, 1,
3087                         [fscrypt_free_dummy_policy() exists])
3088         ])
3089 ]) # LC_FSCRYPT_DUMMY_POLICY
3090
3091 #
3092 # LC_HAVE_ITER_FILE_SPLICE_WRITE
3093 #
3094 # Linux commit v5.9-rc1-6-g36e2c7421f02
3095 #  fs: don't allow splice read/write without explicit ops
3096 #
3097 AC_DEFUN([LC_SRC_HAVE_ITER_FILE_SPLICE_WRITE], [
3098         LB2_LINUX_TEST_SRC([iter_file_splice_write], [
3099                 #include <linux/fs.h>
3100         ],[
3101                 (void)iter_file_splice_write(NULL, NULL, NULL, 1, 0);
3102         ],[-Werror])
3103 ])
3104 AC_DEFUN([LC_HAVE_ITER_FILE_SPLICE_WRITE], [
3105         LB2_MSG_LINUX_TEST_RESULT([if iter_file_splice_write() exists],
3106         [iter_file_splice_write], [
3107                 AC_DEFINE(HAVE_ITER_FILE_SPLICE_WRITE, 1,
3108                         ['iter_file_splice_write' exists])
3109         ])
3110 ]) # LC_HAVE_ITER_FILE_SPLICE_WRITE
3111
3112 #
3113 # LC_HAVE_BDI_DEBUG_STATS
3114 #
3115 # Linux kernel v5.10 commit 2d146b924ec3c0873f06308d149684dc1105d9a3
3116 # backing-dev: no need to check return value of debugfs_create functions
3117 # backing_dev_info.debug_stats was remove.
3118 #
3119 AC_DEFUN([LC_SRC_HAVE_BDI_DEBUG_STATS], [
3120         LB2_LINUX_TEST_SRC([bdi_has_debug_stats], [
3121                 #include <linux/backing-dev-defs.h>
3122         ],[
3123                 struct backing_dev_info info;
3124
3125                 info.debug_stats = NULL;
3126         ],[-Werror])
3127 ])
3128 AC_DEFUN([LC_HAVE_BDI_DEBUG_STATS], [
3129         LB2_MSG_LINUX_TEST_RESULT(
3130         [if 'struct backing_dev_info' has 'debug_stats' field],
3131         [bdi_has_debug_stats], [
3132                 AC_DEFINE(HAVE_BDI_DEBUG_STATS, 1,
3133                         [backing_dev_info has debug_stats])
3134         ])
3135 ]) # LC_HAVE_BDI_DEBUG_STATS
3136
3137 #
3138 # LC_FSCRYPT_IS_NOKEY_NAME
3139 #
3140 # Kernel 5.10-rc4 159e1de201b6fca10bfec50405a3b53a561096a8
3141 # introduced fscrypt_is_nokey_name() inline macro. While
3142 # introduced for 5.10 kernels it was backported to earlier
3143 # Ubuntu kernels. Also it hides the change introduced due
3144 # to git commit 501e43fbe for kernel 5.9 which also was
3145 # backported to earlier Ubuntu kernels.
3146 #
3147 AC_DEFUN([LC_SRC_FSCRYPT_IS_NOKEY_NAME], [
3148         LB2_LINUX_TEST_SRC([fscrypt_is_no_key_name], [
3149                 #include <linux/fscrypt.h>
3150         ],[
3151                 fscrypt_is_nokey_name(NULL);
3152         ],[-Werror])
3153 ])
3154 AC_DEFUN([LC_FSCRYPT_IS_NOKEY_NAME], [
3155         LB2_MSG_LINUX_TEST_RESULT([if fscrypt_is_no_key_name() exists],
3156         [fscrypt_is_no_key_name], [
3157                 AC_DEFINE(HAVE_FSCRYPT_IS_NOKEY_NAME, 1,
3158                         [fscrypt_is_nokey_name() exists])
3159         ])
3160 ]) # LC_FSCRYPT_IS_NOKEY_NAME
3161
3162 #
3163 # LC_FSCRYPT_PREPARE_READDIR
3164 #
3165 # Kernel 5.10-rc4 ec0caa974cd092549ab282deb8ec7ea73b36eba0
3166 # replaced fscrypt_get_encryption_info() with
3167 # fscrypt_prepare_readdir()
3168 #
3169 AC_DEFUN([LC_SRC_FSCRYPT_PREPARE_READDIR], [
3170         LB2_LINUX_TEST_SRC([fscrypt_prepare_readdir], [
3171                 #include <linux/fscrypt.h>
3172         ],[
3173                 fscrypt_prepare_readdir(NULL);
3174         ],[-Werror])
3175 ])
3176 AC_DEFUN([LC_FSCRYPT_PREPARE_READDIR], [
3177         LB2_MSG_LINUX_TEST_RESULT([if fscrypt_prepare_readdir() exists],
3178         [fscrypt_prepare_readdir], [
3179                 AC_DEFINE(HAVE_FSCRYPT_PREPARE_READDIR, 1,
3180                         [fscrypt_prepare_readdir() exists])
3181         ])
3182 ]) # LC_FSCRYPT_PREPARE_READDIR
3183
3184 #
3185 # LC_BIO_SET_DEV
3186 #
3187 # Linux: v5.11-rc5-9-g309dca309fc3
3188 #   block: store a block_device pointer in struct bio
3189 # created bio_set_dev macro
3190 # Linux: v5.15-rc6-127-gcf6d6238cdd3
3191 #   block: turn macro helpers into inline functions
3192 # created inline function(s).
3193 #
3194 # Only provide a bio_set_dev it is is not proveded by the kernel
3195 #
3196 AC_DEFUN([LC_SRC_BIO_SET_DEV], [
3197         LB2_LINUX_TEST_SRC([bio_set_dev], [
3198                 #include <linux/bio.h>
3199         ],[
3200                 struct bio *bio = NULL;
3201                 struct block_device *bdev = NULL;
3202
3203                 bio_set_dev(bio, bdev);
3204         ],[-Werror])
3205 ])
3206 AC_DEFUN([LC_BIO_SET_DEV], [
3207         LB2_MSG_LINUX_TEST_RESULT([if 'bio_set_dev' is available],
3208         [bio_set_dev], [
3209                 AC_DEFINE(HAVE_BIO_SET_DEV, 1, ['bio_set_dev' is available])
3210         ])
3211 ]) # LC_BIO_SET_DEV
3212
3213 #
3214 # LC_HAVE_USER_NAMESPACE_ARG
3215 #
3216 # kernel 5.12 commit 549c7297717c32ee53f156cd949e055e601f67bb
3217 # fs: make helpers idmap mount aware
3218 # Extend some inode methods with an additional user namespace argument.
3219 #
3220 AC_DEFUN([LC_SRC_HAVE_USER_NAMESPACE_ARG], [
3221         LB2_LINUX_TEST_SRC([inode_ops_has_user_namespace_argument], [
3222                 #include <linux/fs.h>
3223         ],[
3224                 struct inode_operations *iops = NULL;
3225                 struct user_namespace *user_ns = NULL;
3226
3227                 iops->getattr(user_ns, NULL, NULL, 0, 0);
3228         ],[-Werror])
3229 ])
3230 AC_DEFUN([LC_HAVE_USER_NAMESPACE_ARG], [
3231         LB2_MSG_LINUX_TEST_RESULT([if 'inode_operations' members have user namespace argument],
3232         [inode_ops_has_user_namespace_argument], [
3233                 AC_DEFINE(HAVE_USER_NAMESPACE_ARG, 1,
3234                         ['inode_operations' members have user namespace argument])
3235         ])
3236 ]) # LC_HAVE_USER_NAMESPACE_ARG
3237
3238 #
3239 # LC_HAVE_FILEATTR_GET
3240 #
3241 # kernel 5.13 4c5b479975212065ef39786e115fde42847e95a9
3242 # vfs: add fileattr ops
3243 # Add inode operations to replace FS_IOC_[SG]ETFLAGS ioctl
3244 # The type signature of ->fileattr_set is not stable for the
3245 # first few iterations, so don't commit to a particular signature
3246 # here.  Hopefully we will only want to support the final version.
3247 #
3248 AC_DEFUN([LC_SRC_HAVE_FILEATTR_GET], [
3249         LB2_LINUX_TEST_SRC([fileattr_set], [
3250                 #include <linux/fs.h>
3251         ],[
3252                 struct inode_operations *iops = NULL;
3253                 iops->fileattr_get(NULL, NULL);
3254         ],[-Werror])
3255 ])
3256 AC_DEFUN([LC_HAVE_FILEATTR_GET], [
3257         LB2_MSG_LINUX_TEST_RESULT(
3258         [if 'inode_operations' has fileattr_get (and fileattr_set)],
3259         [fileattr_set], [
3260                 AC_DEFINE(HAVE_FILEATTR_GET, 1,
3261                         ['inode_operations' has fileattr_get and fileattr_set])
3262         ])
3263
3264 ]) # LC_HAVE_FILEATTR_GET
3265
3266 # LC_HAVE_COPY_PAGE_FROM_ITER_ATOMIC
3267 #
3268 # Kernel 5.13 commit f0b65f39ac505e8f1dcdaa165aa7b8c0bd6fd454
3269 # iov_iter: replace iov_iter_copy_from_user_atomic() with iterator-advancing variant
3270 #
3271 AC_DEFUN([LC_SRC_HAVE_COPY_PAGE_FROM_ITER_ATOMIC], [
3272         LB2_LINUX_TEST_SRC([copy_page_from_iter_atomic], [
3273                 #include <linux/uio.h>
3274         ],[
3275                 copy_page_from_iter_atomic(NULL, 0, 0, NULL);
3276         ])
3277 ])
3278 AC_DEFUN([LC_HAVE_COPY_PAGE_FROM_ITER_ATOMIC], [
3279         LB2_MSG_LINUX_TEST_RESULT([if have copy_page_from_iter_atomic],
3280         [copy_page_from_iter_atomic], [
3281                 AC_DEFINE(HAVE_COPY_PAGE_FROM_ITER_ATOMIC, 1,
3282                         ['copy_page_from_iter_atomic' exists])
3283         ])
3284 ]) # LC_HAVE_COPY_PAGE_FROM_ITER_ATOMIC
3285
3286 #
3287 # LC_HAVE_GET_ACL_RCU_ARG
3288 #
3289 # kernel 5.15 commit 0cad6246621b5887d5b33fea84219d2a71f2f99a
3290 # vfs: add rcu argument to ->get_acl() callback
3291 # Add a rcu argument to the ->get_acl() callback to allow
3292 # get_cached_acl_rcu() to call the ->get_acl() method.
3293 #
3294 AC_DEFUN([LC_SRC_HAVE_GET_ACL_RCU_ARG], [
3295         LB2_LINUX_TEST_SRC([get_acl_rcu_argument], [
3296                 #include <linux/fs.h>
3297         ],[
3298                 ((struct inode_operations *)1)->get_acl((struct inode *)NULL, 0, false);
3299         ],[-Werror])
3300 ])
3301 AC_DEFUN([LC_HAVE_GET_ACL_RCU_ARG], [
3302         LB2_MSG_LINUX_TEST_RESULT([if 'get_acl' has a rcu argument],
3303         [get_acl_rcu_argument], [
3304                 AC_DEFINE(HAVE_GET_ACL_RCU_ARG, 1,
3305                         ['get_acl' has a rcu argument])
3306         ])
3307 ]) # LC_HAVE_GET_ACL_RCU_ARG
3308
3309 # LC_HAVE_FAULT_IN_IOV_ITER_READABLE
3310 #
3311 # Kernel 5.15 commit a6294593e8a1290091d0b078d5d33da5e0cd3dfe
3312 # iov_iter: Turn iov_iter_fault_in_readable into fault_in_iov_iter_readable
3313 #
3314 AC_DEFUN([LC_SRC_HAVE_FAULT_IN_IOV_ITER_READABLE], [
3315         LB2_LINUX_TEST_SRC([fault_in_iov_iter_readable], [
3316                 #include <linux/uio.h>
3317         ],[
3318                 fault_in_iov_iter_readable(NULL, 0);
3319         ])
3320 ])
3321 AC_DEFUN([LC_HAVE_FAULT_IN_IOV_ITER_READABLE], [
3322         LB2_MSG_LINUX_TEST_RESULT([if have fault_in_iov_iter_readable],
3323         [fault_in_iov_iter_readable], [
3324                 AC_DEFINE(HAVE_FAULT_IN_IOV_ITER_READABLE, 1,
3325                         ['fault_in_iov_iter_readable' exists])
3326         ])
3327 ]) # LC_HAVE_FAULT_IN_IOV_ITER_READABLE
3328
3329 #
3330 # LC_HAVE_INVALIDATE_LOCK
3331 #
3332 # Kernel version v5.15-rc1 commit 730633f0b7f951726e87f912a6323641f674ae34
3333 # mm: Protect operations adding pages to page cache with invalidate_lock
3334 #
3335 AC_DEFUN([LC_HAVE_INVALIDATE_LOCK], [
3336 tmp_flags="$EXTRA_KCFLAGS"
3337 EXTRA_KCFLAGS="-Werror"
3338 LB_CHECK_COMPILE([if have address_space have invalidate_lock member],
3339 address_space_invalidate_lock, [
3340                 #include <linux/fs.h>
3341         ],[
3342                 struct address_space *mapping = NULL;
3343
3344                 filemap_invalidate_lock(mapping);
3345         ],[
3346                 AC_DEFINE(HAVE_INVALIDATE_LOCK, 1,
3347                         [address_space invalidate_lock member exists])
3348         ])
3349 EXTRA_KCFLAGS="$tmp_flags"
3350 ]) # LC_HAVE_INVALIDATE_LOCK
3351
3352 #
3353 # LC_HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG
3354 #
3355 # Linux v5.15-rc1-20-g15bf32398ad4
3356 # security: Return xattr name from security_dentry_init_security()
3357 #
3358 AC_DEFUN([LC_SRC_HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG], [
3359         LB2_LINUX_TEST_SRC([security_dentry_init_security_xattr_name_arg], [
3360                 #include <linux/security.h>
3361         ],[
3362                 struct dentry *dentry = NULL;
3363                 int mode = 0;
3364                 const struct qstr *name = NULL;
3365                 const char *xattr_name = NULL;
3366                 void **ctx = NULL;
3367                 u32 *ctxlen = 0;
3368                 int rc = security_dentry_init_security(dentry, mode, name, &xattr_name,
3369                                                        ctx, ctxlen);
3370                 (void)rc;
3371
3372         ],[-Werror])
3373 ])
3374 AC_DEFUN([LC_HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG], [
3375         LB2_MSG_LINUX_TEST_RESULT([if security_dentry_init_security() returns xattr name],
3376         [security_dentry_init_security_xattr_name_arg], [
3377                 AC_DEFINE(HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG, 1,
3378                         [security_dentry_init_security() returns xattr name])
3379         ])
3380 ]) # LC_HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG
3381
3382 #
3383 # LC_HAVE_KIOCB_COMPLETE_2ARGS
3384 #
3385 # kernel v5.15-rc6-145-g6b19b766e8f0
3386 # fs: get rid of the res2 iocb->ki_complete argument
3387 #
3388 AC_DEFUN([LC_SRC_HAVE_KIOCB_COMPLETE_2ARGS], [
3389         LB2_LINUX_TEST_SRC([kiocb_ki_complete_2args], [
3390                 #include <linux/fs.h>
3391
3392                 static void complete_fn(struct kiocb *iocb, long ret)
3393                 {
3394                         (void)iocb;
3395                         (void)ret;
3396                 }
3397         ],[
3398                 struct kiocb *kio = NULL;
3399
3400                 kio->ki_complete = complete_fn;
3401         ],[-Werror])
3402 ])
3403 AC_DEFUN([LC_HAVE_KIOCB_COMPLETE_2ARGS], [
3404         LB2_MSG_LINUX_TEST_RESULT([if kiocb->ki_complete() has 2 arguments],
3405         [kiocb_ki_complete_2args], [
3406                 AC_DEFINE(HAVE_KIOCB_COMPLETE_2ARGS, 1,
3407                         [kiocb->ki_complete() has 2 arguments])
3408         ])
3409 ]) # LC_HAVE_KIOCB_COMPLETE_2ARGS
3410
3411 #
3412 # LC_EXPORTS_DELETE_FROM_PAGE_CACHE
3413 #
3414 # Linux commit v5.16-rc4-44-g452e9e6992fe
3415 # filemap: Add filemap_remove_folio and __filemap_remove_folio
3416 #
3417 # Also removes the export of delete_from_page_cache
3418 #
3419 AC_DEFUN([LC_EXPORTS_DELETE_FROM_PAGE_CACHE], [
3420 LB_CHECK_EXPORT([delete_from_page_cache], [mm/filemap.c],
3421         [AC_DEFINE(HAVE_DELETE_FROM_PAGE_CACHE, 1,
3422                         [delete_from_page_cache is exported])])
3423 ]) # LC_EXPORTS_DELETE_FROM_PAGE_CACHE
3424
3425
3426 #
3427 # LC_HAVE_WB_STAT_MOD
3428 #
3429 # Kernel 5.16-rc1 bd3488e7b4d61780eb3dfaca1cc6f4026bcffd48
3430 # mm/writeback: Rename __add_wb_stat() to wb_stat_mod()
3431 #
3432 AC_DEFUN([LC_HAVE_WB_STAT_MOD], [
3433 tmp_flags="$EXTRA_KCFLAGS"
3434 EXTRA_KCFLAGS="-Werror"
3435 LB_CHECK_COMPILE([if wb_stat_mod() exists],
3436 wb_stat_mode, [
3437         #include <linux/backing-dev.h>
3438 ],[
3439         wb_stat_mod(NULL, WB_WRITEBACK, 1);
3440 ],[
3441         AC_DEFINE(HAVE_WB_STAT_MOD, 1,
3442                 [wb_stat_mod() exists])
3443 ])
3444 EXTRA_KCFLAGS="$tmp_flags"
3445 ]) # LC_HAVE_WB_STAT_MOD
3446
3447 #
3448 # LC_HAVE_INVALIDATE_FOLIO
3449 #
3450 # linux commit v5.17-rc4-10-g128d1f8241d6
3451 # fs: Add invalidate_folio() aops method
3452 #
3453 AC_DEFUN([LC_SRC_HAVE_INVALIDATE_FOLIO], [
3454         LB2_LINUX_TEST_SRC([address_spaace_operaions_invalidate_folio], [
3455                 #include <linux/fs.h>
3456         ],[
3457                 struct address_space_operations *aops = NULL;
3458                 struct folio *folio = NULL;
3459                 aops->invalidate_folio(folio, 0, PAGE_SIZE);
3460
3461         ],[-Werror])
3462 ])
3463 AC_DEFUN([LC_HAVE_INVALIDATE_FOLIO], [
3464         LB2_MSG_LINUX_TEST_RESULT([if have address_spaace_operaions->invalidate_folio() member],
3465         [address_spaace_operaions_invalidate_folio], [
3466                 AC_DEFINE(HAVE_INVALIDATE_FOLIO, 1,
3467                         [address_spaace_operaions->invalidate_folio() member exists])
3468         ])
3469 ]) # LC_HAVE_INVALIDATE_FOLIO
3470
3471 #
3472 # LC_HAVE_DIRTY_FOLIO
3473 #
3474 # linux commit v5.17-rc4-38-g6f31a5a261db
3475 # fs: Add aops->dirty_folio
3476 # ... replaces ->set_page_dirty() with ->dirty_folio()
3477 #
3478 AC_DEFUN([LC_SRC_HAVE_DIRTY_FOLIO], [
3479         LB2_LINUX_TEST_SRC([address_spaace_operaions_dirty_folio], [
3480                 #include <linux/fs.h>
3481         ],[
3482                 struct address_space_operations *aops = NULL;
3483                 struct address_space *mapping = NULL;
3484                 struct folio *folio = NULL;
3485                 bool dirty = aops->dirty_folio(mapping, folio);
3486                 (void) dirty;
3487         ],[-Werror])
3488 ])
3489 AC_DEFUN([LC_HAVE_DIRTY_FOLIO], [
3490         LB2_MSG_LINUX_TEST_RESULT([if have address_spaace_operaions->dirty_folio() member],
3491         [address_spaace_operaions_dirty_folio], [
3492                 AC_DEFINE(HAVE_DIRTY_FOLIO, 1,
3493                         [address_spaace_operaions->dirty_folio() member exists])
3494         ])
3495 ]) # LC_HAVE_DIRTY_FOLIO
3496
3497 #
3498 # LC_HAVE_ALLOC_INODE_SB
3499 #
3500 # linux commit v5.17-49-g8b9f3ac5b01d
3501 #   fs: introduce alloc_inode_sb() to allocate filesystems specific inode
3502 #
3503 AC_DEFUN([LC_SRC_HAVE_ALLOC_INODE_SB], [
3504         LB2_LINUX_TEST_SRC([alloc_inode_sb], [
3505                 #include <linux/fs.h>
3506         ],[
3507                 struct super_block *sb = NULL;
3508                 struct kmem_cache *cache = NULL;
3509
3510                 (void)alloc_inode_sb(sb, cache, GFP_NOFS);
3511         ],[-Werror])
3512 ])
3513 AC_DEFUN([LC_HAVE_ALLOC_INODE_SB], [
3514         LB2_MSG_LINUX_TEST_RESULT([if alloc_inode_sb() exists],
3515         [alloc_inode_sb], [
3516                 AC_DEFINE(HAVE_ALLOC_INODE_SB, 1,
3517                         [alloc_inode_sb() exists])
3518         ])
3519 ]) # LC_HAVE_ALLOC_INODE_SB
3520
3521 #
3522 # LC_GRAB_CACHE_PAGE_WRITE_BEGIN_WITH_FLAGS
3523 #
3524 # Linux commit v5.18-rc5-221-gb7446e7cf15f
3525 #   fs: Remove aop flags parameter from grab_cache_page_write_begin()
3526 #
3527 AC_DEFUN([LC_SRC_GRAB_CACHE_PAGE_WRITE_BEGIN_WITH_FLAGS], [
3528         LB2_LINUX_TEST_SRC([grab_cache_page_write_begin_with_flags], [
3529                 #include <linux/pagemap.h>
3530         ],[
3531                 struct address_space *mapping = NULL;
3532                 (void)grab_cache_page_write_begin(mapping, 0, 1);
3533         ],[-Werror])
3534 ]) 
3535 AC_DEFUN([LC_GRAB_CACHE_PAGE_WRITE_BEGIN_WITH_FLAGS], [
3536         LB2_MSG_LINUX_TEST_RESULT([if grab_cache_page_write_begin() has flags argument],
3537         [grab_cache_page_write_begin_with_flags], [
3538                 AC_DEFINE(HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN_WITH_FLAGS, 1,
3539                         [grab_cache_page_write_begin() has flags argument])
3540         ])
3541 ]) # LC_GRAB_CACHE_PAGE_WRITE_BEGIN_WITH_FLAGS
3542
3543 #
3544 # LC_HAVE_ADDRESS_SPACE_OPERATIONS_READ_FOLIO
3545 #
3546 # Linux commit v5.18-rc5-241-g5efe7448a142
3547 #   fs: Introduce aops->read_folio
3548 #
3549 AC_DEFUN([LC_SRC_HAVE_ADDRESS_SPACE_OPERATIONS_READ_FOLIO], [
3550         LB2_LINUX_TEST_SRC([address_space_operations_read_folio], [
3551                 #include <linux/fs.h>
3552         ],[
3553                 struct address_space_operations *aops = NULL;
3554                 struct file *file = NULL;
3555                 struct folio *folio = NULL;
3556                 int err = aops->read_folio(file, folio);
3557                 (void)err;
3558         ],[-Werror])
3559 ])
3560 AC_DEFUN([LC_HAVE_ADDRESS_SPACE_OPERATIONS_READ_FOLIO], [
3561         LB2_MSG_LINUX_TEST_RESULT([if struct address_space_operations() has read_folio()],
3562         [address_space_operations_read_folio], [
3563                 AC_DEFINE(HAVE_AOPS_READ_FOLIO, 1,
3564                         [struct address_space_operations() has read_folio()])
3565         ])
3566 ]) # LC_HAVE_ADDRESS_SPACE_OPERATIONS_READ_FOLIO
3567
3568 #
3569 # LC_HAVE_READ_CACHE_PAGE_FILLER_WITH_FILE
3570 #
3571 # Linux commit v5.18-rc5-280-ge9b5b23e957e
3572 #   fs: Change the type of filler_t
3573 #
3574 AC_DEFUN([LC_SRC_HAVE_READ_CACHE_PAGE_FILLER_WITH_FILE], [
3575         LB2_LINUX_TEST_SRC([read_cache_page_filler_with_file], [
3576                 #include <linux/pagemap.h>
3577                 static inline int _filler(struct file *file, struct folio *f)
3578                 {
3579                         return 0;
3580                 }
3581         ],[
3582                 struct address_space *mapping = NULL;
3583                 struct file *file = NULL;
3584                 struct page *page = read_cache_page(mapping, 0, _filler, file);
3585                 (void)page;
3586         ],[-Werror])
3587 ])
3588 AC_DEFUN([LC_HAVE_READ_CACHE_PAGE_FILLER_WITH_FILE], [
3589         LB2_MSG_LINUX_TEST_RESULT([if read_cache_page() filler_t needs struct file],
3590         [read_cache_page_filler_with_file], [
3591                 AC_DEFINE(HAVE_READ_CACHE_PAGE_WANTS_FILE, 1,
3592                         [read_cache_page() filler_t needs struct file])
3593         ])
3594 ]) # LC_HAVE_READ_CACHE_PAGE_FILLER_WITH_FILE
3595
3596 #
3597 # LC_HAVE_ADDRESS_SPACE_OPERATIONS_RELEASE_FOLIO
3598 #
3599 # Linux commit v5.18-rc5-282-gfa29000b6b26
3600 #  fs: Add aops->release_folio
3601 #
3602 AC_DEFUN([LC_SRC_HAVE_ADDRESS_SPACE_OPERATIONS_RELEASE_FOLIO], [
3603         LB2_LINUX_TEST_SRC([address_space_operations_release_folio], [
3604                 #include <linux/fs.h>
3605         ],[
3606                 struct address_space_operations *aops = NULL;
3607                 struct folio *folio = NULL;
3608                 int err = aops->release_folio(folio, GFP_KERNEL);
3609                 (void)err;
3610         ],[-Werror])
3611 ])
3612 AC_DEFUN([LC_HAVE_ADDRESS_SPACE_OPERATIONS_RELEASE_FOLIO], [
3613         LB2_MSG_LINUX_TEST_RESULT([if struct address_space_operations() has release_folio()],
3614         [address_space_operations_release_folio], [
3615                 AC_DEFINE(HAVE_AOPS_RELEASE_FOLIO, 1,
3616                         [struct address_space_operations() has release_folio()])
3617         ])
3618 ]) # LC_HAVE_ADDRESS_SPACE_OPERATIONS_RELEASE_FOLIO
3619
3620 #
3621 # LC_HAVE_LSMCONTEXT_INIT
3622 #
3623 # repo: git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/jammy
3624 # kernel linux-hwe-5.19 commit fef1deb99dad87dd700afae76b35c5b5750e33a8
3625 # LSM: Removed scaffolding function lsmcontext_init
3626 #
3627 AC_DEFUN([LC_SRC_HAVE_LSMCONTEXT_INIT], [
3628         LB2_LINUX_TEST_SRC([lsmcontext_init], [
3629                 #include <linux/security.h>
3630         ],[
3631                 struct lsmcontext ctx = {};
3632
3633                 lsmcontext_init(&ctx, "", 0, 0);
3634         ],[])
3635 ])
3636 AC_DEFUN([LC_HAVE_LSMCONTEXT_INIT], [
3637         LB2_MSG_LINUX_TEST_RESULT([if lsmcontext_init is available],
3638         [lsmcontext_init], [
3639                 AC_DEFINE(HAVE_LSMCONTEXT_INIT, 1,
3640                         [lsmcontext_init is available])
3641         ])
3642 ]) # LC_HAVE_LSMCONTEXT_INIT
3643
3644 #
3645 # LC_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX
3646 #
3647 # repo: git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/jammy
3648 # kernel linux-hwe-5.19 commit 57d0004bc811254916be30f94c86d9607867deb0
3649 # LSM: Use lsmcontext in security_dentry_init_security
3650 #
3651 AC_DEFUN([LC_SRC_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX], [
3652         LB2_LINUX_TEST_SRC([security_dentry_init_security_with_ctx], [
3653                 #include <linux/security.h>
3654         ],[
3655                 struct dentry *dentry = NULL;
3656                 const struct qstr *name = NULL;
3657                 struct lsmcontext *ctx = NULL;
3658                 const char *xattr_name = "";
3659
3660                 (void)security_dentry_init_security(dentry, 0, name,
3661                                                     &xattr_name, ctx);
3662         ],[-Werror])
3663 ])
3664 AC_DEFUN([LC_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX], [
3665         LB2_MSG_LINUX_TEST_RESULT([if security_dentry_init_security needs lsmcontext],
3666         [security_dentry_init_security_with_ctx], [
3667                 AC_DEFINE(HAVE_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX, 1,
3668                         [security_dentry_init_security needs lsmcontext])
3669         ])
3670 ]) # LC_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX
3671
3672 #
3673 # LC_HAVE_NO_LLSEEK
3674 #
3675 # Linux commit v5.19-rc2-6-g868941b14441
3676 #   fs: remove no_llseek
3677 #
3678 AC_DEFUN([LC_SRC_HAVE_NO_LLSEEK], [
3679         LB2_LINUX_TEST_SRC([no_llseek], [
3680                 #include <linux/fs.h>
3681         ],[
3682                 static const struct file_operations fops = {
3683                         .llseek = &no_llseek,
3684                 };
3685                 (void)fops;
3686         ],[-Werror])
3687 ])
3688 AC_DEFUN([LC_HAVE_NO_LLSEEK], [
3689         LB2_MSG_LINUX_TEST_RESULT([if no_llseek() is available],
3690         [no_llseek], [
3691                 AC_DEFINE(HAVE_NO_LLSEEK, 1, [no_llseek() is available])
3692         ])
3693 ]) # LC_HAVE_NO_LLSEEK
3694
3695 #
3696 # LC_DQUOT_TRANSFER_WITH_USER_NS
3697 #
3698 # Linux commit v5.19-rc3-6-g71e7b535b890
3699 #  quota: port quota helpers mount ids
3700 #
3701 AC_DEFUN([LC_SRC_DQUOT_TRANSFER_WITH_USER_NS], [
3702         LB2_LINUX_TEST_SRC([dquot_transfer], [
3703                 #include <linux/quotaops.h>
3704         ],[
3705                 struct user_namespace *userns = NULL;
3706                 struct inode *inode = NULL;
3707                 struct iattr *iattr = NULL;
3708                 int err __attribute__ ((unused));
3709
3710                 err = dquot_transfer(userns, inode, iattr);
3711         ],[-Werror])
3712 ])
3713 AC_DEFUN([LC_DQUOT_TRANSFER_WITH_USER_NS], [
3714         LB2_MSG_LINUX_TEST_RESULT([if dquot_transfer() has user_ns argument],
3715         [dquot_transfer], [
3716                 AC_DEFINE(HAVE_DQUOT_TRANSFER_WITH_USER_NS, 1,
3717                         [dquot_transfer() has user_ns argument])
3718         ])
3719 ]) # LC_DQUOT_TRANSFER_WITH_USER_NS
3720
3721 #
3722 # LC_HAVE_ADDRESS_SPACE_OPERATIONS_MIGRATE_FOLIO
3723 #
3724 # Linux commit v5.19-rc3-392-g5490da4f06d1
3725 #  fs: Add aops->migrate_folio
3726 #
3727 AC_DEFUN([LC_SRC_HAVE_ADDRESS_SPACE_OPERATIONS_MIGRATE_FOLIO], [
3728         LB2_LINUX_TEST_SRC([address_space_operations_migrate_folio], [
3729                 #include <linux/fs.h>
3730         ],[
3731                 struct address_space_operations *aops = NULL;
3732                 struct address_space *m = NULL;
3733                 struct folio *src = NULL;
3734                 struct folio *dst = NULL;
3735                 int err = aops->migrate_folio(m, dst, src, MIGRATE_ASYNC);
3736                 (void)err;
3737         ],[-Werror])
3738 ])
3739 AC_DEFUN([LC_HAVE_ADDRESS_SPACE_OPERATIONS_MIGRATE_FOLIO], [
3740         LB2_MSG_LINUX_TEST_RESULT([if struct address_space_operations() has migrate_folio()],
3741         [address_space_operations_migrate_folio], [
3742                 AC_DEFINE(HAVE_AOPS_MIGRATE_FOLIO, 1,
3743                         [struct address_space_operations() has migrate_folio()])
3744         ])
3745 ]) # LC_HAVE_ADDRESS_SPACE_OPERATIONS_MIGRATE_FOLIO
3746
3747 #
3748 # LC_REGISTER_SHRINKER_FORMAT_NAMED
3749 #
3750 # Linux commit v5.19-rc4-52-ge33c267ab70d
3751 #   mm: shrinkers: provide shrinkers with names
3752 #
3753 AC_DEFUN([LC_SRC_REGISTER_SHRINKER_FORMAT_NAMED], [
3754         LB2_LINUX_TEST_SRC([register_shrinker_format], [
3755                 #include <linux/mm.h>
3756         ],[
3757                 if (register_shrinker(NULL, "lustre-%ps", __func__))
3758                         unregister_shrinker(NULL);
3759         ],[-Werror])
3760 ])
3761 AC_DEFUN([LC_REGISTER_SHRINKER_FORMAT_NAMED], [
3762         LB2_MSG_LINUX_TEST_RESULT([if register_shrinker() returns status],
3763         [register_shrinker_format], [
3764                 AC_DEFINE(HAVE_REGISTER_SHRINKER_FORMAT_NAMED, 1,
3765                         [register_shrinker() returns status])
3766         ])
3767 ]) # LC_REGISTER_SHRINKER_FORMAT_NAMED
3768
3769 #
3770 # LC_HAVE_VFS_SETXATTR_NON_CONST_VALUE
3771 #
3772 # From Linux commit v5.19-rc5-17-g0c5fd887d2bb
3773 #   acl: move idmapped mount fixup into vfs_{g,s}etxattr()
3774 # Until Linux commit v6.0-rc3-6-g6344e66970c6
3775 #   xattr: constify value argument in vfs_setxattr()
3776 #
3777 AC_DEFUN([LC_SRC_HAVE_VFS_SETXATTR_NON_CONST_VALUE], [
3778         LB2_LINUX_TEST_SRC([vfs_setxattr_non_const_value_arg], [
3779                 #include <linux/xattr.h>
3780         ],[
3781                 struct dentry *de = NULL;
3782                 const char *name = "an.xattr";
3783                 const void *value = NULL;
3784                 int err = vfs_setxattr(&init_user_ns, de, name, value, 0, 0);
3785                 (void)err;
3786         ],[-Werror])
3787 ]) # LC_HAVE_VFS_SETXATTR_NON_CONST_VALUE
3788 AC_DEFUN([LC_HAVE_VFS_SETXATTR_NON_CONST_VALUE], [
3789         LB2_MSG_LINUX_TEST_RESULT([if vfs_setxattr() value argument is non-const],
3790         [vfs_setxattr_non_const_value_arg], [
3791                 AC_DEFINE([VFS_SETXATTR_VALUE(value)],
3792                           [(value)],
3793                           [vfs_setxattr() value argument is const void *])
3794         ],[
3795                 AC_DEFINE([VFS_SETXATTR_VALUE(value)],
3796                           [((void *)(value))],
3797                           [vfs_setxattr() value argument is non-const])
3798         ])
3799 ]) # LC_HAVE_VFS_SETXATTR_NON_CONST_VALUE
3800
3801 #
3802 # LC_HAVE_IOV_ITER_GET_PAGES_ALLOC2
3803 #
3804 # Linux commit v5.19-10313-geba2d3d79829
3805 #   get rid of non-advancing variants
3806 #
3807 AC_DEFUN([LC_SRC_HAVE_IOV_ITER_GET_PAGES_ALLOC2], [
3808         LB2_LINUX_TEST_SRC([iov_iter_get_pages_alloc2], [
3809                 #include <linux/uio.h>
3810         ],[
3811                 struct iov_iter *iter = NULL;
3812                 struct page ***pages = NULL;
3813                 size_t maxsize = 1;
3814                 size_t start;
3815                 size_t result __attribute__ ((unused));
3816                 result = iov_iter_get_pages_alloc2(iter, pages, maxsize, &start);
3817         ],[-Werror])
3818 ])
3819 AC_DEFUN([LC_HAVE_IOV_ITER_GET_PAGES_ALLOC2], [
3820         LB2_MSG_LINUX_TEST_RESULT([if iov_iter_get_pages_alloc2() is available],
3821         [iov_iter_get_pages_alloc2], [
3822                 AC_DEFINE(HAVE_IOV_ITER_GET_PAGES_ALLOC2, 1,
3823                         [iov_iter_get_pages_alloc2() is available])
3824         ])
3825 ]) # LC_HAVE_IOV_ITER_GET_PAGES_ALLOC2
3826
3827 #
3828 # LC_HAVE_GET_RANDOM_U32_AND_U64
3829 #
3830 # Linux commit v4.10-rc3-6-gc440408cf690
3831 #   random: convert get_random_int/long into get_random_u32/u64
3832 # Linux commit v6.0-11338-gde492c83cae0
3833 #   prandom: remove unused functions
3834 #
3835 AC_DEFUN([LC_SRC_HAVE_GET_RANDOM_U32_AND_U64], [
3836         LB2_LINUX_TEST_SRC([get_random_u32_and_u64], [
3837                 #include <linux/random.h>
3838         ],[
3839                 u32 rand32 = get_random_u32();
3840                 u64 rand64 = get_random_u64();
3841                 (void)rand32;
3842                 (void)rand64;
3843         ],[-Werror])
3844 ])
3845 AC_DEFUN([LC_HAVE_GET_RANDOM_U32_AND_U64], [
3846         LB2_MSG_LINUX_TEST_RESULT([if get_random_u32() and get_random_u64() are available],
3847         [get_random_u32_and_u64], [
3848                 AC_DEFINE(HAVE_GET_RANDOM_U32_AND_U64, 1,
3849                         [get_random_[u32|u64] are available])
3850         ],[
3851                 AC_DEFINE([get_random_u32()], [prandom_u32()],
3852                         [get_random_u32() is not available, use prandom_u32])
3853         ])
3854 ]) # LC_HAVE_GET_RANDOM_U32_AND_U64
3855
3856 #
3857 # LC_NFS_FILLDIR_USE_CTX_RETURN_BOOL
3858 #
3859 # Linux commit v6.0-rc1-2-g25885a35a720
3860 #  Change calling conventions for filldir_t
3861 #
3862 AC_DEFUN([LC_SRC_NFS_FILLDIR_USE_CTX_RETURN_BOOL], [
3863         LB2_LINUX_TEST_SRC([filldir_ctx_return_bool], [
3864                 #include <linux/fs.h>
3865         ],[
3866                 bool filldir(struct dir_context *ctx, const char* name,
3867                              int i, loff_t off, u64 tmp, unsigned temp)
3868                 {
3869                         return 0;
3870                 }
3871
3872                 struct dir_context ctx = {
3873                         .actor = filldir,
3874                 };
3875
3876                 ctx.actor(NULL, "test", 0, (loff_t) 0, 0, 0);
3877         ],[-Werror])
3878 ])
3879 AC_DEFUN([LC_NFS_FILLDIR_USE_CTX_RETURN_BOOL], [
3880         LB2_MSG_LINUX_TEST_RESULT([if filldir_t uses struct dir_context and returns bool],
3881         [filldir_ctx_return_bool], [
3882                 AC_DEFINE(HAVE_FILLDIR_USE_CTX_RETURN_BOOL, 1,
3883                         [filldir_t needs struct dir_context and returns bool])
3884                 AC_DEFINE(HAVE_FILLDIR_USE_CTX, 1,
3885                         [filldir_t needs struct dir_context as argument])
3886                 AC_DEFINE(FILLDIR_TYPE, bool,
3887                         [filldir_t return type is bool or int])
3888         ],[
3889                 AC_DEFINE(FILLDIR_TYPE, int,
3890                         [filldir_t return type is bool or int])
3891         ])
3892 ]) # LC_NFS_FILLDIR_USE_CTX_RETURN_BOOL
3893
3894 #
3895 # LC_HAVE_FILEMAP_GET_FOLIOS_CONTIG
3896 #
3897 # Linux commit v6.0-rc3-94-g35b471467f88
3898 #   filemap: add filemap_get_folios_contig()
3899 #
3900 AC_DEFUN([LC_SRC_HAVE_FILEMAP_GET_FOLIOS_CONTIG], [
3901         LB2_LINUX_TEST_SRC([filemap_get_folios_contig], [
3902                 #include <linux/pagemap.h>
3903         ],[
3904                 struct address_space *m = NULL;
3905                 pgoff_t start = 0;
3906                 struct folio_batch *fbatch = NULL;
3907                 (void)filemap_get_folios_contig(m, &start, ULONG_MAX, fbatch);
3908         ],[-Werror])
3909 ])
3910 AC_DEFUN([LC_HAVE_FILEMAP_GET_FOLIOS_CONTIG], [
3911         LB2_MSG_LINUX_TEST_RESULT([if filemap_get_folios_contig() is available],
3912         [filemap_get_folios_contig], [
3913                 AC_DEFINE(HAVE_FILEMAP_GET_FOLIOS_CONTIG, 1,
3914                         [filemap_get_folios_contig() is available])
3915         ])
3916 ]) # LC_HAVE_FILEMAP_GET_FOLIOS_CONTIG
3917
3918 #
3919 # LC_HAVE_GET_RANDOM_U32_BELOW
3920 #
3921 # Linux commit v6.1-13825-g3c202d14a9d7
3922 #   prandom: remove prandom_u32_max()
3923 #
3924 AC_DEFUN([LC_SRC_HAVE_GET_RANDOM_U32_BELOW], [
3925         LB2_LINUX_TEST_SRC([get_random_u32_below], [
3926                 #include <linux/random.h>
3927         ],[
3928                 u32 rand32 = get_random_u32_below(99);
3929                 (void)rand32;
3930         ],[-Werror])
3931 ])
3932 AC_DEFUN([LC_HAVE_GET_RANDOM_U32_BELOW], [
3933         LB2_MSG_LINUX_TEST_RESULT([if get_random_u32_below()is available],
3934         [get_random_u32_below], [
3935                 AC_DEFINE(HAVE_GET_RANDOM_U32_BELOW, 1,
3936                         [get_random_u32_below() is available])
3937         ],[
3938                 AC_DEFINE([get_random_u32_below(v)], [prandom_u32_max(v)],
3939                         [get_random_u32_below() is not available])
3940         ])
3941 ]) # LC_HAVE_GET_RANDOM_U32_BELOW
3942
3943 #
3944 # LC_HAVE_ACL_WITH_DENTRY
3945 #
3946 # Linux commit v6.1-rc1-2-g138060ba92b3
3947 #   fs: pass dentry to set acl method
3948 # Linux commit v6.1-rc1-4-g7420332a6ff4
3949 #   fs: add new get acl method
3950 #
3951 AC_DEFUN([LC_SRC_HAVE_ACL_WITH_DENTRY], [
3952         LB2_LINUX_TEST_SRC([acl_with_dentry], [
3953                 #include <linux/fs.h>
3954         ],[
3955                 struct dentry *dentry = NULL;
3956
3957                 ((struct inode_operations *)1)->get_acl(NULL, dentry, 0);
3958                 (void)dentry;
3959         ],[-Werror])
3960 ])
3961 AC_DEFUN([LC_HAVE_ACL_WITH_DENTRY], [
3962         LB2_MSG_LINUX_TEST_RESULT([if 'get_acl' and 'set_acl' use dentry argument],
3963         [acl_with_dentry], [
3964                 AC_DEFINE(HAVE_ACL_WITH_DENTRY, 1,
3965                         ['get_acl' and 'set_acl' use dentry argument])
3966         ])
3967 ]) # LC_HAVE_ACL_WITH_DENTRY
3968
3969 #
3970 # LC_HAVE_U64_CAPABILITY
3971 #
3972 # linux kernel v6.2-13111-gf122a08b197d
3973 #   capability: just use a 'u64' instead of a 'u32[2]' array
3974 #
3975 AC_DEFUN([LC_SRC_HAVE_U64_CAPABILITY], [
3976         LB2_LINUX_TEST_SRC([kernel_cap_t_has_u64_value], [
3977                 #include <linux/cred.h>
3978                 #include <linux/capability.h>
3979         ],[
3980                 kernel_cap_t cap __attribute__ ((unused));
3981                 cap.val = 0xffffffffffffffffull;
3982         ],[-Werror])
3983 ])
3984 AC_DEFUN([LC_HAVE_U64_CAPABILITY], [
3985         LB2_MSG_LINUX_TEST_RESULT([if 'kernel_cap_t' has u64 val],
3986         [kernel_cap_t_has_u64_value], [
3987                 AC_DEFINE(HAVE_U64_CAPABILITY, 1,
3988                         ['kernel_cap_t' has u64 val])
3989         ])
3990 ]) # LC_HAVE_U64_CAPABILITY
3991
3992 #
3993 # LC_HAVE_MNT_IDMAP_ARG
3994 #
3995 # linux kernel v6.2-rc1-4-gb74d24f7a74f
3996 #   fs: port ->getattr() to pass mnt_idmap
3997 # linux kernel v6.2-rc1-3-gc1632a0f1120
3998 #   fs: port ->setattr() to pass mnt_idmap
3999 #
4000 AC_DEFUN([LC_SRC_HAVE_MNT_IDMAP_ARG], [
4001         LB2_LINUX_TEST_SRC([inode_ops_getattr_has_mnt_idmap_argument], [
4002                 #include <linux/mount.h>
4003                 #include <linux/fs.h>
4004         ],[
4005                 ((struct inode_operations *)1)->getattr((struct mnt_idmap *)NULL,
4006                                                         NULL, NULL, 0, 0);
4007         ],[-Werror])
4008 ])
4009 AC_DEFUN([LC_HAVE_MNT_IDMAP_ARG], [
4010         LB2_MSG_LINUX_TEST_RESULT([if 'inode_operations' members have mnt_idmap argument],
4011         [inode_ops_getattr_has_mnt_idmap_argument], [
4012                 AC_DEFINE(HAVE_MNT_IDMAP_ARG, 1,
4013                         ['inode_operations' members have mnt_idmap argument])
4014                 AC_DEFINE(HAVE_USER_NAMESPACE_ARG, 1,
4015                         [use mnt_idmap in place of user_namespace argument])
4016                 AC_DEFINE(HAVE_DQUOT_TRANSFER_WITH_USER_NS, 1,
4017                         [use mnt_idmap with dquot_transfer])
4018         ])
4019 ]) # LC_HAVE_MNT_IDMAP_ARG
4020
4021 #
4022 # LC_HAVE_LOCKS_LOCK_FILE_WAIT_IN_FILELOCK
4023 #
4024 # Linux commit v6.2-rc3-9-g5970e15dbcfe
4025 #   filelock: move file locking definitions to separate header file
4026 #
4027 AC_DEFUN([LC_SRC_HAVE_LOCKS_LOCK_FILE_WAIT_IN_FILELOCK], [
4028         LB2_LINUX_TEST_SRC([locks_lock_file_wait_in_filelock], [
4029                 #include <linux/filelock.h>
4030         ],[
4031                 locks_lock_file_wait(NULL, NULL);
4032         ])
4033 ])
4034 AC_DEFUN([LC_HAVE_LOCKS_LOCK_FILE_WAIT_IN_FILELOCK], [
4035         LB2_MSG_LINUX_TEST_RESULT([if 'locks_lock_file_wait' exists in filelock.h],
4036         [locks_lock_file_wait_in_filelock], [
4037                 AC_DEFINE(HAVE_LOCKS_LOCK_FILE_WAIT, 1,
4038                         [kernel has locks_lock_file_wait in filelock.h])
4039                 AC_DEFINE(HAVE_LINUX_FILELOCK_HEADER, 1,
4040                         [linux/filelock.h is present])
4041         ])
4042 ]) # LC_HAVE_LOCKS_LOCK_FILE_WAIT_IN_FILELOCK
4043
4044 #
4045 # LC_HAVE_FOLIO_BATCH_REINIT
4046 #
4047 # linux kernel v6.2-rc4-254-g811561288397
4048 #   mm: pagevec: add folio_batch_reinit()
4049 #
4050 AC_DEFUN([LC_SRC_HAVE_FOLIO_BATCH_REINIT], [
4051         LB2_LINUX_TEST_SRC([folio_batch_reinit_exists], [
4052                 #include <linux/pagevec.h>
4053         ],[
4054                 struct folio_batch fbatch __attribute__ ((unused));
4055
4056                 folio_batch_reinit(&fbatch);
4057         ],[-Werror])
4058 ])
4059 AC_DEFUN([LC_HAVE_FOLIO_BATCH_REINIT], [
4060         LB2_MSG_LINUX_TEST_RESULT([if 'folio_batch_reinit' is available],
4061         [folio_batch_reinit_exists], [
4062                 AC_DEFINE(HAVE_FOLIO_BATCH_REINIT, 1,
4063                         ['folio_batch_reinit' is available])
4064         ])
4065 ]) # LC_HAVE_FOLIO_BATCH_REINIT
4066
4067 #
4068 # LC_HAVE_IOV_ITER_IOVEC
4069 #
4070 # linux kernel v6.3-rc4-32-g6eb203e1a868
4071 #   iov_iter: remove iov_iter_iovec()
4072 #
4073 AC_DEFUN([LC_SRC_HAVE_IOV_ITER_IOVEC], [
4074         LB2_LINUX_TEST_SRC([iov_iter_iovec_exists], [
4075                 #include <linux/uio.h>
4076         ],[
4077                 struct iovec iov __attribute__ ((unused));
4078                 struct iov_iter i = { };
4079
4080                 iov = iov_iter_iovec(&i);
4081         ],[-Werror])
4082 ])
4083 AC_DEFUN([LC_HAVE_IOV_ITER_IOVEC], [
4084         LB2_MSG_LINUX_TEST_RESULT([if 'iov_iter_iovec' is available],
4085         [iov_iter_iovec_exists], [
4086                 AC_DEFINE(HAVE_IOV_ITER_IOVEC, 1,
4087                         ['iov_iter_iovec' is available])
4088         ])
4089 ]) # LC_HAVE_IOV_ITER_IOVEC
4090
4091 #
4092 # LC_HAVE_IOVEC_WITH_IOV_MEMBER
4093 #
4094 # linux kernel v6.3-rc4-34-g747b1f65d39a
4095 #   iov_iter: overlay struct iovec and ubuf/len
4096 # This renames iov_iter member iov to __iov and now __iov == __ubuf_iovec
4097 # And provides the iov_iter() accessor to return __iov or __ubuf_iovec
4098 #
4099 AC_DEFUN([LC_SRC_HAVE_IOVEC_WITH_IOV_MEMBER], [
4100         LB2_LINUX_TEST_SRC([iov_iter_has___iov_member], [
4101                 #include <linux/uio.h>
4102         ],[
4103                 struct iov_iter iter = { };
4104                 size_t len __attribute__ ((unused));
4105
4106                 len = iter.__iov->iov_len;
4107         ],[-Werror])
4108 ])
4109 AC_DEFUN([LC_HAVE_IOVEC_WITH_IOV_MEMBER], [
4110         LB2_MSG_LINUX_TEST_RESULT([if 'iov_iter_iovec' is available],
4111         [iov_iter_has___iov_member], [
4112                 AC_DEFINE(HAVE___IOV_MEMBER, __iov,
4113                         ['struct iov_iter' has '__iov' member])
4114                 AC_DEFINE(HAVE_ITER_IOV, 1,
4115                         [iter_iov() is available])
4116         ],[
4117                 AC_DEFINE(iter_iov(iter), (iter)->__iov,
4118                         ['iov_iter()' provides iov])
4119                 AC_DEFINE(__iov, iov,
4120                         ['struct iov_iter' has 'iov' member])
4121         ])
4122 ]) # LC_HAVE_IOVEC_WITH_IOV_MEMBER
4123
4124 #
4125 # LC_HAVE_CLASS_CREATE_MODULE_ARG
4126 #
4127 # linux kernel v6.3-rc1-13-g1aaba11da9aa
4128 #   driver core: class: remove module * from class_create()
4129 #
4130 AC_DEFUN([LC_SRC_HAVE_CLASS_CREATE_MODULE_ARG], [
4131         LB2_LINUX_TEST_SRC([class_create_without_module_arg], [
4132                 #include <linux/device/class.h>
4133         ],[
4134                 struct class *class __attribute__ ((unused));
4135
4136                 class = class_create("empty");
4137                 if (IS_ERR(class))
4138                         /* checked */;
4139         ],[-Werror])
4140 ])
4141 AC_DEFUN([LC_HAVE_CLASS_CREATE_MODULE_ARG], [
4142         LB2_MSG_LINUX_TEST_RESULT([if 'class_create' does not have module arg],
4143         [class_create_without_module_arg], [
4144                 AC_DEFINE([ll_class_create(name)],
4145                           [class_create((name))],
4146                           ['class_create' does not have module arg])
4147         ],[
4148                 AC_DEFINE([ll_class_create(name)],
4149                           [class_create(THIS_MODULE, (name))],
4150                           ['class_create' expects module arg])
4151         ])
4152 ]) # LC_HAVE_CLASS_CREATE_MODULE_ARG
4153
4154 #
4155 # LC_HAVE_FILEMAP_SPLICE_READ
4156 #
4157 # linux kernel v6.4-rc2-29-gc6585011bc1d
4158 #   splice: Remove generic_file_splice_read()
4159 #
4160 AC_DEFUN([LC_SRC_HAVE_FILEMAP_SPLICE_READ], [
4161         LB2_LINUX_TEST_SRC([filemap_splice_read], [
4162                 #include <linux/fs.h>
4163         ],[
4164                 struct file *in = NULL;
4165                 loff_t pos = 0;
4166                 struct pipe_inode_info *pipe = NULL;
4167                 ssize_t count __attribute__ ((unused));
4168
4169                 count = filemap_splice_read(in, &pos, pipe, 0, 0);
4170         ],[-Werror])
4171 ])
4172 AC_DEFUN([LC_HAVE_FILEMAP_SPLICE_READ], [
4173         LB2_MSG_LINUX_TEST_RESULT([if 'filemap_splice_read' is available],
4174         [filemap_splice_read], [
4175                 AC_DEFINE(HAVE_FILEMAP_SPLICE_READ, 1,
4176                         ['filemap_splice_read' is available])
4177         ])
4178 ]) # LC_HAVE_FILEMAP_SPLICE_READ
4179
4180 #
4181 # LC_HAVE_ENUM_ITER_PIPE
4182 #
4183 # linux kernel v6.4-rc2-30-g3fc40265ae2b
4184 #   iov_iter: Kill ITER_PIPE
4185 #
4186 AC_DEFUN([LC_SRC_HAVE_ENUM_ITER_PIPE], [
4187         LB2_LINUX_TEST_SRC([enum_iter_type_iter_pipe], [
4188                 #include <linux/uio.h>
4189         ],[
4190                 enum iter_type iter_type = ITER_PIPE;
4191
4192                 (void)iter_type;
4193         ],[-Werror])
4194 ])
4195 AC_DEFUN([LC_HAVE_ENUM_ITER_PIPE], [
4196         LB2_MSG_LINUX_TEST_RESULT([if enum iter_type has member 'iter_pipe'],
4197         [enum_iter_type_iter_pipe], [
4198                 AC_DEFINE(HAVE_ENUM_ITER_PIPE, 1,
4199                         [enum iter_type has member 'iter_pipe'])
4200         ])
4201 ]) # LC_HAVE_ENUM_ITER_PIPE
4202
4203 #
4204 # LC_HAVE_GET_USER_PAGES_WITHOUT_VMA
4205 #
4206 # linux kernel v6.4-rc2-30-g3fc40265ae2b
4207 #   iov_iter: Kill ITER_PIPE
4208 #
4209 AC_DEFUN([LC_SRC_HAVE_GET_USER_PAGES_WITHOUT_VMA], [
4210         LB2_LINUX_TEST_SRC([get_user_pages_without_vma], [
4211                 #include <linux/mm.h>
4212         ],[
4213                 struct page *pages __attribute__ ((unused));
4214
4215                 (void)get_user_pages(0, 0, 0, &pages);
4216         ],[-Werror])
4217 ])
4218 AC_DEFUN([LC_HAVE_GET_USER_PAGES_WITHOUT_VMA], [
4219         LB2_MSG_LINUX_TEST_RESULT([if get_user_pages removed 'vma' parameter],
4220         [get_user_pages_without_vma], [
4221                 AC_DEFINE(HAVE_GET_USER_PAGES_WITHOUT_VMA, 1,
4222                         [get_user_pages removed 'vma' parameter])
4223         ])
4224 ]) # LC_HAVE_GET_USER_PAGES_WITHOUT_VMA
4225
4226 #
4227 # LC_HAVE_FOLIO_BATCH
4228 #
4229 # linux kernel v5.16-rc4-36-g10331795fb79
4230 #   pagevec: Add folio_batch
4231 #
4232 AC_DEFUN([LC_SRC_HAVE_FOLIO_BATCH], [
4233         LB2_LINUX_TEST_SRC([struct_folio_batch_exists], [
4234                 #include <linux/pagevec.h>
4235         ],[
4236                 struct folio_batch fbatch __attribute__ ((unused));
4237
4238                 folio_batch_init(&fbatch);
4239         ],[-Werror])
4240 ])
4241 AC_DEFUN([LC_HAVE_FOLIO_BATCH], [
4242         LB2_MSG_LINUX_TEST_RESULT([if 'struct folio_batch' is available],
4243         [struct_folio_batch_exists], [
4244                 AC_DEFINE(HAVE_FOLIO_BATCH, 1,
4245                         ['struct folio_batch' is available])
4246         ])
4247 ]) # LC_HAVE_FOLIO_BATCH
4248
4249 #
4250 # LC_HAVE_STRUCT_PAGEVEC
4251 #
4252 # linux kernel v6.4-rc4-438-g1e0877d58b1e
4253 #   mm: remove struct pagevec
4254 #
4255 AC_DEFUN([LC_SRC_HAVE_STRUCT_PAGEVEC], [
4256         LB2_LINUX_TEST_SRC([struct_pagevec_exists], [
4257                 #include <linux/pagevec.h>
4258         ],[
4259                 struct pagevec *pvec = NULL;
4260                 (void)pvec;
4261         ],[-Werror])
4262 ])
4263 AC_DEFUN([LC_HAVE_STRUCT_PAGEVEC], [
4264         LB2_MSG_LINUX_TEST_RESULT([if 'struct pagevec' is available],
4265         [struct_pagevec_exists], [
4266                 AC_DEFINE(HAVE_PAGEVEC, 1,
4267                         ['struct pagevec' is available])
4268         ])
4269 ]) # LC_HAVE_STRUCT_PAGEVEC
4270
4271 #
4272 # LC_HAVE_FLUSH___WORKQUEUE
4273 #
4274 # linux kernel v6.5-rc1-7-g20bdedafd2f6
4275 #   workqueue: Warn attempt to flush system-wide workqueues.
4276 #
4277 AC_DEFUN([LC_SRC_HAVE_FLUSH___WORKQUEUE], [
4278         LB2_LINUX_TEST_SRC([flush_scheduled_work_warning], [
4279                 #include <linux/workqueue.h>
4280         ],[
4281                 __flush_workqueue(system_wq);
4282         ],[-Werror])
4283 ])
4284 AC_DEFUN([LC_HAVE_FLUSH___WORKQUEUE], [
4285         LB2_MSG_LINUX_TEST_RESULT([if 'flush_scheduled_work()' throws warning],
4286         [flush_scheduled_work_warning], [
4287                 AC_DEFINE(HAVE_FLUSH___WORKQUEUE, 1,
4288                         ['__flush_workqueue(system_wq)' is available])
4289         ])
4290 ]) # LC_HAVE_FLUSH___WORKQUEUE
4291
4292 #
4293 # LC_HAVE_INODE_GET_CTIME
4294 #
4295 # linux kernel v6.5-rc1-92-g13bc24457850
4296 #   fs: rename i_ctime field to __i_ctime
4297 #
4298 AC_DEFUN([LC_SRC_HAVE_INODE_GET_CTIME], [
4299         LB2_LINUX_TEST_SRC([inode_get_ctime_exists], [
4300                 #include <linux/fs.h>
4301         ],[
4302                 struct inode *inode = NULL;
4303                 struct timespec64 ts __attribute__ ((unused));
4304
4305                 ts = inode_get_ctime(inode);
4306         ],[-Werror])
4307 ])
4308 AC_DEFUN([LC_HAVE_INODE_GET_CTIME], [
4309         LB2_MSG_LINUX_TEST_RESULT([if 'inode_get_ctime()' exists],
4310         [inode_get_ctime_exists], [
4311                 AC_DEFINE(HAVE_INODE_GET_CTIME, 1,
4312                         ['inode_get_ctime()' exists])
4313         ])
4314 ]) # LC_HAVE_INODE_GET_CTIME
4315
4316 #
4317 # LC_HAVE_MMAP_WRITE_TRYLOCK
4318 #
4319 # linux kernel v6.5-rc4-110-gcf95e337cb63
4320 #   mm: delete mmap_write_trylock() and vma_try_start_write()
4321 #
4322 AC_DEFUN([LC_SRC_HAVE_MMAP_WRITE_TRYLOCK], [
4323         LB2_LINUX_TEST_SRC([mmap_write_trylock_removed], [
4324                 #include <linux/mmap_lock.h>
4325         ],[
4326                 struct mm_struct *mm = NULL;
4327
4328                 (void)mmap_write_trylock(mm);
4329         ],[-Werror])
4330 ])
4331 AC_DEFUN([LC_HAVE_MMAP_WRITE_TRYLOCK], [
4332         LB2_MSG_LINUX_TEST_RESULT([if 'mmap_write_trylock()' is available],
4333         [mmap_write_trylock_removed], [
4334                 AC_DEFINE(HAVE_MMAP_WRITE_TRYLOCK, 1,
4335                         ['mmap_write_trylock()' is available])
4336         ])
4337 ]) # LC_HAVE_MMAP_WRITE_TRYLOCK
4338
4339 #
4340 # LC_HAVE_GENERIC_FILEATTR_HAS_MASK_ARG
4341 #
4342 # linux kernel v6.5-rc1-95-g0d72b92883c6
4343 #   fs: pass the request_mask to generic_fillattr
4344 #
4345 AC_DEFUN([LC_SRC_HAVE_GENERIC_FILEATTR_HAS_MASK_ARG], [
4346         LB2_LINUX_TEST_SRC([generic_fillattr_has_request_mask_arg], [
4347                 #include <linux/fs.h>
4348         ],[
4349                 struct inode *inode = NULL;
4350                 struct mnt_idmap *map = NULL;
4351                 struct kstat *kstat = NULL;
4352
4353                 generic_fillattr(map, 0, inode, kstat);
4354         ],[-Werror])
4355 ])
4356 AC_DEFUN([LC_HAVE_GENERIC_FILEATTR_HAS_MASK_ARG], [
4357         LB2_MSG_LINUX_TEST_RESULT([if 'generic_fillattr()' has request_mask argument],
4358         [generic_fillattr_has_request_mask_arg], [
4359                 AC_DEFINE(HAVE_GENERIC_FILEATTR_HAS_MASK_ARG, 1,
4360                         ['generic_fillattr()' has request_mask argument])
4361                 AC_DEFINE([RQMASK_ARG], [0,], [default request_mask argument])
4362         ], [
4363                 AC_DEFINE([RQMASK_ARG], [], [no request_mask argument needed])
4364         ])
4365 ]) # LC_HAVE_GENERIC_FILEATTR_HAS_MASK_ARG
4366
4367 #
4368 # LC_HAVE_NSPROXY_COUNT_AS_REFCOUNT
4369 #
4370 # Linux commit v6.5-rc2-20-g2ddd3cac1fa9
4371 #   nsproxy: Convert nsproxy.count to refcount_t
4372 #
4373 AC_DEFUN([LC_SRC_HAVE_NSPROXY_COUNT_AS_REFCOUNT], [
4374         LB2_LINUX_TEST_SRC([struct_nsproxy_count_refcount_t], [
4375                 #include <linux/nsproxy.h>
4376         ],[
4377                 struct nsproxy *nsproxy = NULL;
4378
4379                 refcount_dec(&nsproxy->count);
4380         ],[-Werror])
4381 ])
4382 AC_DEFUN([LC_HAVE_NSPROXY_COUNT_AS_REFCOUNT], [
4383         LB2_MSG_LINUX_TEST_RESULT([if 'struct nsproxy.count' is refcount_t],
4384         [struct_nsproxy_count_refcount_t], [
4385                 AC_DEFINE(HAVE_NSPROXY_COUNT_AS_REFCOUNT, 1,
4386                         ['struct nsproxy.count' is refcount_t])
4387         ])
4388 ]) # LC_HAVE_NSPROXY_COUNT_AS_REFCOUNT
4389
4390 #
4391 # LC_HAVE_INODE_GET_MTIME_SEC
4392 #
4393 # Linux commit v6.6-rc5-1-g077c212f0344
4394 #   fs: new accessor methods for atime and mtime
4395 #
4396 # Linux commit v6.6-rc5-86-g12cd44023651
4397 #   fs: rename inode i_atime and i_mtime fields
4398 #
4399 AC_DEFUN([LC_SRC_HAVE_INODE_GET_MTIME_SEC], [
4400         LB2_LINUX_TEST_SRC([inode_get_mtime_exists], [
4401                 #include <linux/fs.h>
4402         ],[
4403                 struct inode *inode = NULL;
4404                 time64_t sec __attribute__ ((unused));
4405
4406                 sec = inode_get_mtime_sec(inode);
4407         ],[-Werror])
4408 ])
4409 AC_DEFUN([LC_HAVE_INODE_GET_MTIME_SEC], [
4410         LB2_MSG_LINUX_TEST_RESULT([if 'inode_get_mtime()' exists],
4411         [inode_get_mtime_exists], [
4412                 AC_DEFINE(HAVE_INODE_GET_MTIME_SEC, 1,
4413                         ['inode_get_mtime()' exists])
4414         ])
4415 ]) # LC_HAVE_INODE_GET_MTIME_SEC
4416
4417 #
4418 # LC_HAVE_SHRINKER_ALLOC
4419 #
4420 # Linux commit v6.6-rc4-53-gc42d50aefd17
4421 #   mm: shrinker: add infrastructure for dynamically allocating shrinker
4422 #
4423 AC_DEFUN([LC_SRC_HAVE_SHRINKER_ALLOC], [
4424         LB2_LINUX_TEST_SRC([shrinker_alloc_exists], [
4425                 #include <linux/shrinker.h>
4426         ],[
4427                 struct shrinker *shrink __attribute__ ((unused));
4428
4429                 shrink = shrinker_alloc(0, "%s", "whoami");
4430         ],[-Werror])
4431 ])
4432 AC_DEFUN([LC_HAVE_SHRINKER_ALLOC], [
4433         LB2_MSG_LINUX_TEST_RESULT([if 'shrinker_alloc()' exists],
4434         [shrinker_alloc_exists], [
4435                 AC_DEFINE(HAVE_SHRINKER_ALLOC, 1,
4436                         ['shrinker_alloc()' exists])
4437         ])
4438 ]) # LC_HAVE_SHRINKER_ALLOC
4439
4440 #
4441 # LC_HAVE_DENTRY_D_CHILDREN
4442 #
4443 # Linux commit v6.7-rc1-3-gda549bdd15c2
4444 #   dentry: switch the lists of children to hlist
4445 #
4446 AC_DEFUN([LC_SRC_HAVE_DENTRY_D_CHILDREN], [
4447         LB2_LINUX_TEST_SRC([dentry_d_children], [
4448                 #include <linux/dcache.h>
4449         ],[
4450                 struct dentry *dentry = NULL;
4451
4452                 return hlist_empty(&dentry->d_children);
4453         ],[-Werror])
4454 ])
4455 AC_DEFUN([LC_HAVE_DENTRY_D_CHILDREN], [
4456         LB2_MSG_LINUX_TEST_RESULT([if sruct dentry has d_children member],
4457         [dentry_d_children], [
4458                 AC_DEFINE(HAVE_DENTRY_D_CHILDREN, 1,
4459                         [sruct dentry has d_children member])
4460         ])
4461 ]) # LC_HAVE_DENTRY_D_CHILDREN
4462
4463 #
4464 # LC_HAVE_GENERIC_ERROR_REMOVE_FOLIO
4465 #
4466 # Linux commit v6.7-rc4-79-gaf7628d6ec19
4467 #   fs: convert error_remove_page to error_remove_folio
4468 #
4469 AC_DEFUN([LC_SRC_HAVE_GENERIC_ERROR_REMOVE_FOLIO], [
4470         LB2_LINUX_TEST_SRC([generic_error_remove_folio], [
4471                 #include <linux/mm.h>
4472         ],[
4473                 struct address_space *mapping = NULL;
4474                 struct folio *folio = NULL;
4475                 int err = generic_error_remove_folio(mapping, folio);
4476
4477                 (void) err;
4478         ],[-Werror])
4479 ])
4480 AC_DEFUN([LC_HAVE_GENERIC_ERROR_REMOVE_FOLIO], [
4481         LB2_MSG_LINUX_TEST_RESULT([if generic_error_remove_folio() exists],
4482         [generic_error_remove_folio], [
4483                 AC_DEFINE(HAVE_GENERIC_ERROR_REMOVE_FOLIO, 1,
4484                         [generic_error_remove_folio() exists])
4485         ])
4486 ]) # LC_HAVE_GENERIC_ERROR_REMOVE_FOLIO
4487
4488 #
4489 # LC_PROG_LINUX
4490 #
4491 # Lustre linux kernel checks
4492 #
4493 AC_DEFUN([LC_PROG_LINUX_SRC], [
4494         AS_IF([test "x$enable_gss" != xno], [
4495                 LC_SRC_KEY_TYPE_INSTANTIATE_2ARGS
4496                 LB2_SRC_CHECK_CONFIG_IM([CRYPTO_MD5])
4497                 LB2_SRC_CHECK_CONFIG_IM([CRYPTO_SHA1])
4498                 LB2_SRC_CHECK_CONFIG_IM([CRYPTO_SHA256])
4499                 LB2_SRC_CHECK_CONFIG_IM([CRYPTO_SHA512])
4500         ])
4501         AS_IF([test "x$enable_server" != xno], [
4502                 LC_SRC_CONFIG_QUOTA
4503                 LC_SRC_STACK_SIZE
4504         ])
4505         LC_SRC_CONFIG_FHANDLE
4506         LC_SRC_POSIX_ACL_CONFIG
4507         LC_SRC_HAVE_PROJECT_QUOTA
4508
4509         # 3.11
4510         LC_SRC_INVALIDATE_RANGE
4511         LC_SRC_HAVE_DIR_CONTEXT
4512         LC_SRC_D_COMPARE_5ARGS
4513         LC_SRC_HAVE_DCOUNT
4514         LC_SRC_PID_NS_FOR_CHILDREN
4515
4516         # 3.12
4517         LC_SRC_OLDSIZE_TRUNCATE_PAGECACHE
4518         LC_SRC_PTR_ERR_OR_ZERO_MISSING
4519         LC_SRC_HAVE_DENTRY_D_U_D_ALIAS_LIST
4520         LC_SRC_HAVE_DENTRY_D_U_D_ALIAS_HLIST
4521         LC_SRC_HAVE_DENTRY_D_CHILD
4522         LC_SRC_KIOCB_KI_LEFT
4523         LC_SRC_REGISTER_SHRINKER_RET
4524
4525         # 3.13
4526         LC_SRC_VFS_RENAME_5ARGS
4527         LC_SRC_VFS_UNLINK_3ARGS
4528         LC_SRC_HAVE_D_IS_POSITIVE
4529
4530         # 3.14
4531         LC_SRC_HAVE_BVEC_ITER
4532         LC_SRC_HAVE_TRUNCATE_IPAGES_FINAL
4533         LC_SRC_IOPS_RENAME_WITH_FLAGS
4534         LC_SRC_IOP_SET_ACL
4535
4536         # 3.15
4537         LC_SRC_VFS_RENAME_6ARGS
4538
4539         # 3.16
4540         LC_SRC_DIRECTIO_USE_ITER
4541         LC_SRC_HAVE_IOV_ITER_INIT_DIRECTION
4542         LC_SRC_HAVE_IOV_ITER_TRUNCATE
4543         LC_SRC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
4544         LC_SRC_PAGECACHE_GET_PAGE
4545
4546         # 3.17
4547         LC_SRC_HAVE_INTERVAL_BLK_INTEGRITY
4548         LC_SRC_KEY_MATCH_DATA
4549         LC_SRC_HAVE_BLK_INTEGRITY_ITER
4550
4551         # 3.18
4552         LC_SRC_NFS_FILLDIR_USE_CTX
4553         LC_SRC_PERCPU_COUNTER_INIT
4554
4555         # 3.19
4556         LC_SRC_KIOCB_HAS_NBYTES
4557         LC_SRC_HAVE_DQUOT_QC_DQBLK
4558         LC_SRC_HAVE_AIO_COMPLETE
4559         LC_SRC_HAVE_IS_ROOT_INODE
4560
4561         # 3.20
4562         LC_SRC_BACKING_DEV_INFO_REMOVAL
4563
4564         # 4.1.0
4565         LC_SRC_IOV_ITER_RW
4566         LC_SRC_HAVE___BI_CNT
4567
4568         # 4.2
4569         LC_SRC_BIO_ENDIO_USES_ONE_ARG
4570         LC_SRC_SYMLINK_OPS_USE_NAMEIDATA
4571         LC_SRC_ACCOUNT_PAGE_DIRTIED_3ARGS
4572         LC_SRC_HAVE_CRYPTO_ALLOC_SKCIPHER
4573
4574         # 4.3
4575         LC_SRC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
4576         LC_SRC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD
4577         LC_SRC_HAVE_CACHE_HEAD_HLIST
4578         LC_SRC_HAVE_XATTR_HANDLER_SIMPLIFIED
4579
4580         # 4.4
4581         LC_SRC_HAVE_LOCKS_LOCK_FILE_WAIT
4582         LC_SRC_HAVE_KEY_PAYLOAD_DATA_ARRAY
4583         LC_SRC_HAVE_XATTR_HANDLER_NAME
4584         LC_SRC_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL
4585         LC_SRC_HAVE_BI_OPF
4586         LC_SRC_HAVE_SUBMIT_BIO_2ARGS
4587         LC_SRC_HAVE_CLEAN_BDEV_ALIASES
4588
4589         # 4.5
4590         LC_SRC_HAVE_FILE_DENTRY
4591
4592         # 4.6
4593         LC_SRC_HAVE_INODE_LOCK
4594         LC_SRC_HAVE_IOP_GET_LINK
4595         LC_SRC_HAVE_IN_COMPAT_SYSCALL
4596         LC_SRC_HAVE_XATTR_HANDLER_INODE_PARAM
4597         LC_SRC_LOCK_PAGE_MEMCG
4598         LC_SRC_HAVE_DOWN_WRITE_KILLABLE
4599
4600         # 4.7
4601         LC_SRC_D_IN_LOOKUP
4602         LC_SRC_D_INIT
4603         LC_SRC_DIRECTIO_2ARGS
4604         LC_SRC_GENERIC_WRITE_SYNC_2ARGS
4605         LC_SRC_FOP_ITERATE_SHARED
4606
4607         # 4.8
4608         LC_SRC_HAVE_POSIX_ACL_VALID_USER_NS
4609         LC_SRC_D_COMPARE_4ARGS
4610         LC_SRC_FULL_NAME_HASH_3ARGS
4611         LC_SRC_STRUCT_POSIX_ACL_XATTR
4612         LC_SRC_IOP_XATTR
4613
4614         # 4.9
4615         LC_SRC_GROUP_INFO_GID
4616         LC_SRC_VFS_SETXATTR
4617         LC_SRC_POSIX_ACL_UPDATE_MODE
4618         LC_SRC_HAVE_BDI_IO_PAGES
4619
4620         # 4.10
4621         LC_SRC_IOP_GENERIC_READLINK
4622         LC_SRC_HAVE_VM_FAULT_ADDRESS
4623
4624         # 4.11
4625         LC_SRC_INODEOPS_ENHANCED_GETATTR
4626         LC_SRC_VM_OPERATIONS_REMOVE_VMF_ARG
4627         LC_SRC_HAVE_KEY_USAGE_REFCOUNT
4628         LC_SRC_HAVE_CRYPTO_MAX_ALG_NAME_128
4629         LC_SRC_HAVE_FSMAP_HEADER
4630         LC_SRC_HAVE_PERCPU_COUNTER_ADD_BATCH
4631
4632         # 4.12
4633         LC_SRC_CURRENT_TIME
4634         LC_SRC_SUPER_SETUP_BDI_NAME
4635         LC_SRC_BI_STATUS
4636
4637         # 4.13
4638         LC_SRC_HAVE_GET_INODE_USAGE
4639
4640         # 4.14
4641         LC_SRC_PAGEVEC_INIT_ONE_PARAM
4642         LC_SRC_BI_BDEV
4643         LC_SRC_INTERVAL_TREE_CACHED
4644
4645         # 4.17
4646         LC_SRC_VM_FAULT_T
4647         LC_SRC_VM_FAULT_RETRY
4648         LC_SRC_I_PAGES
4649
4650         # 4.18
4651         LC_SRC_INODE_TIMESPEC64
4652         LC_SRC_ALLOC_FILE_PSEUDO
4653
4654         # 4.20
4655         LC_SRC_RADIX_TREE_TAG_SET
4656         LC_SRC_UAPI_LINUX_MOUNT_H
4657         LC_SRC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
4658
4659         # 5.0
4660         LC_SRC_GENL_FAMILY_HAS_RESV_START_OP
4661
4662         # 5.1
4663         LC_SRC_HAVE_BVEC_ITER_ALL
4664
4665         # 5.2
4666         LC_SRC_KEYRING_SEARCH_4ARGS
4667
4668         # 5.3
4669         LC_SRC_BIO_BI_PHYS_SEGMENTS
4670         LC_SRC_LM_COMPARE_OWNER_EXISTS
4671
4672         # 5.5
4673         LC_SRC_FSCRYPT_DIGESTED_NAME
4674
4675         # 5.7
4676         LC_SRC_FSCRYPT_DUMMY_CONTEXT_ENABLED
4677
4678         # 5.8
4679         LC_SRC_HAVE_KTHREAD_USE_MM
4680
4681         # 5.9
4682         LC_SRC_FSCRYPT_FNAME_ALLOC_BUFFER
4683         LC_SRC_FSCRYPT_SET_CONTEXT
4684         LC_SRC_FSCRYPT_NOKEY_NAME
4685         LC_SRC_FSCRYPT_SET_TEST_DUMMY_ENC_CHAR_ARG
4686         LC_SRC_FSCRYPT_DUMMY_POLICY
4687         LC_SRC_HAVE_ITER_FILE_SPLICE_WRITE
4688
4689         # 5.10
4690         LC_SRC_HAVE_BDI_DEBUG_STATS
4691         LC_SRC_FSCRYPT_IS_NOKEY_NAME
4692         LC_SRC_FSCRYPT_PREPARE_READDIR
4693
4694         # 5.11
4695         LC_SRC_BIO_SET_DEV
4696
4697         # 5.12
4698         LC_SRC_HAVE_USER_NAMESPACE_ARG
4699
4700         # 5.13
4701         LC_SRC_HAVE_COPY_PAGE_FROM_ITER_ATOMIC
4702         LC_SRC_HAVE_FILEATTR_GET
4703
4704         # 5.15
4705         LC_SRC_HAVE_GET_ACL_RCU_ARG
4706         LC_SRC_HAVE_FAULT_IN_IOV_ITER_READABLE
4707
4708         # 5.16
4709         LC_SRC_HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG
4710         LC_SRC_HAVE_KIOCB_COMPLETE_2ARGS
4711
4712         # 5.17
4713         LC_SRC_HAVE_INVALIDATE_FOLIO
4714         LC_SRC_HAVE_DIRTY_FOLIO
4715
4716         # 5.18
4717         LC_SRC_HAVE_ALLOC_INODE_SB
4718
4719         # 5.19
4720         LC_SRC_GRAB_CACHE_PAGE_WRITE_BEGIN_WITH_FLAGS
4721         LC_SRC_HAVE_ADDRESS_SPACE_OPERATIONS_READ_FOLIO
4722         LC_SRC_HAVE_READ_CACHE_PAGE_FILLER_WITH_FILE
4723         LC_SRC_HAVE_ADDRESS_SPACE_OPERATIONS_RELEASE_FOLIO
4724         LC_SRC_HAVE_LSMCONTEXT_INIT
4725         LC_SRC_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX
4726
4727         # 6.0
4728         LC_SRC_HAVE_NO_LLSEEK
4729         LC_SRC_DQUOT_TRANSFER_WITH_USER_NS
4730         LC_SRC_HAVE_ADDRESS_SPACE_OPERATIONS_MIGRATE_FOLIO
4731         LC_SRC_REGISTER_SHRINKER_FORMAT_NAMED
4732         LC_SRC_HAVE_VFS_SETXATTR_NON_CONST_VALUE
4733         LC_SRC_HAVE_IOV_ITER_GET_PAGES_ALLOC2
4734
4735         # 6.1
4736         LC_SRC_HAVE_GET_RANDOM_U32_AND_U64
4737         LC_SRC_NFS_FILLDIR_USE_CTX_RETURN_BOOL
4738         LC_SRC_HAVE_FILEMAP_GET_FOLIOS_CONTIG
4739
4740         # 6.2
4741         LC_SRC_HAVE_GET_RANDOM_U32_BELOW
4742         LC_SRC_HAVE_ACL_WITH_DENTRY
4743
4744         # 6.3
4745         LC_SRC_HAVE_MNT_IDMAP_ARG
4746         LC_SRC_HAVE_LOCKS_LOCK_FILE_WAIT_IN_FILELOCK
4747         LC_SRC_HAVE_U64_CAPABILITY
4748         LC_SRC_HAVE_FOLIO_BATCH_REINIT
4749
4750         # 6.4
4751         LC_SRC_HAVE_IOV_ITER_IOVEC
4752         LC_SRC_HAVE_IOVEC_WITH_IOV_MEMBER
4753         LC_SRC_HAVE_CLASS_CREATE_MODULE_ARG
4754
4755         # 6.5
4756         LC_SRC_HAVE_FILEMAP_SPLICE_READ
4757         LC_SRC_HAVE_ENUM_ITER_PIPE
4758         LC_SRC_HAVE_GET_USER_PAGES_WITHOUT_VMA
4759         LC_SRC_HAVE_FOLIO_BATCH
4760         LC_SRC_HAVE_STRUCT_PAGEVEC
4761
4762         # 6.6
4763         LC_SRC_HAVE_FLUSH___WORKQUEUE
4764         LC_SRC_HAVE_INODE_GET_CTIME
4765         LC_SRC_HAVE_MMAP_WRITE_TRYLOCK
4766         LC_SRC_HAVE_GENERIC_FILEATTR_HAS_MASK_ARG
4767         LC_SRC_HAVE_NSPROXY_COUNT_AS_REFCOUNT
4768
4769         # 6.7
4770         LC_SRC_HAVE_INODE_GET_MTIME_SEC
4771         LC_SRC_HAVE_SHRINKER_ALLOC
4772
4773         # 6.8
4774         LC_SRC_HAVE_DENTRY_D_CHILDREN
4775         LC_SRC_HAVE_GENERIC_ERROR_REMOVE_FOLIO
4776
4777         # kernel patch to extend integrity interface
4778         LC_SRC_BIO_INTEGRITY_PREP_FN
4779 ])
4780
4781 AC_DEFUN([LC_PROG_LINUX_RESULTS], [
4782         AS_IF([test "x$enable_gss" != xno], [
4783                 LC_KEY_TYPE_INSTANTIATE_2ARGS
4784
4785                 LB2_TEST_CHECK_CONFIG_IM([CRYPTO_MD5], [],
4786                         [AC_MSG_WARN(
4787                         [kernel MD5 support is recommended by using GSS.])])
4788                 LB2_TEST_CHECK_CONFIG_IM([CRYPTO_SHA1], [],
4789                         [AC_MSG_WARN(
4790                         [kernel SHA1 support is recommended by using GSS.])])
4791                 LB2_TEST_CHECK_CONFIG_IM([CRYPTO_SHA256], [],
4792                         [AC_MSG_WARN(
4793                         [kernel SHA256 support is recommended by using GSS.])])
4794                 LB2_TEST_CHECK_CONFIG_IM([CRYPTO_SHA512], [],
4795                         [AC_MSG_WARN(
4796                         [kernel SHA512 support is recommended by using GSS.])])
4797         ])
4798         AS_IF([test "x$enable_server" != xno], [
4799                 LC_CONFIG_QUOTA
4800                 LC_STACK_SIZE
4801         ])
4802         LC_CONFIG_FHANDLE
4803         LC_POSIX_ACL_CONFIG
4804         LC_HAVE_PROJECT_QUOTA
4805
4806         # 3.11
4807         LC_INVALIDATE_RANGE
4808         LC_HAVE_DIR_CONTEXT
4809         LC_D_COMPARE_5ARGS
4810         LC_HAVE_DCOUNT
4811         LC_HAVE_DENTRY_D_U_D_ALIAS_LIST
4812         LC_HAVE_DENTRY_D_U_D_ALIAS_HLIST
4813         LC_HAVE_DENTRY_D_CHILD
4814         LC_PID_NS_FOR_CHILDREN
4815
4816         # 3.12
4817         LC_OLDSIZE_TRUNCATE_PAGECACHE
4818         LC_PTR_ERR_OR_ZERO_MISSING
4819         LC_KIOCB_KI_LEFT
4820         LC_REGISTER_SHRINKER_RET
4821
4822         # 3.13
4823         LC_VFS_RENAME_5ARGS
4824         LC_VFS_UNLINK_3ARGS
4825         LC_HAVE_D_IS_POSITIVE
4826
4827         # 3.14
4828         LC_HAVE_BVEC_ITER
4829         LC_HAVE_TRUNCATE_IPAGES_FINAL
4830         LC_IOPS_RENAME_WITH_FLAGS
4831         LC_IOP_SET_ACL
4832
4833         # 3.15
4834         LC_VFS_RENAME_6ARGS
4835
4836         # 3.16
4837         LC_DIRECTIO_USE_ITER
4838         LC_HAVE_IOV_ITER_INIT_DIRECTION
4839         LC_HAVE_IOV_ITER_TRUNCATE
4840         LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
4841         LC_PAGECACHE_GET_PAGE
4842
4843         # 3.17
4844         LC_HAVE_INTERVAL_BLK_INTEGRITY
4845         LC_KEY_MATCH_DATA
4846         LC_HAVE_BLK_INTEGRITY_ITER
4847
4848         # 3.18
4849         LC_PERCPU_COUNTER_INIT
4850         LC_NFS_FILLDIR_USE_CTX
4851
4852         # 3.19
4853         LC_KIOCB_HAS_NBYTES
4854         LC_HAVE_DQUOT_QC_DQBLK
4855         LC_HAVE_AIO_COMPLETE
4856         LC_HAVE_IS_ROOT_INODE
4857
4858         # 3.20
4859         LC_BACKING_DEV_INFO_REMOVAL
4860
4861         # 4.1.0
4862         LC_IOV_ITER_RW
4863         LC_HAVE___BI_CNT
4864
4865         # 4.2
4866         LC_BIO_ENDIO_USES_ONE_ARG
4867         LC_SYMLINK_OPS_USE_NAMEIDATA
4868         LC_ACCOUNT_PAGE_DIRTIED_3ARGS
4869         LC_HAVE_CRYPTO_ALLOC_SKCIPHER
4870
4871         # 4.3
4872         LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
4873         LC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD
4874         LC_HAVE_CACHE_HEAD_HLIST
4875         LC_HAVE_XATTR_HANDLER_SIMPLIFIED
4876
4877         # 4.4
4878         LC_HAVE_LOCKS_LOCK_FILE_WAIT
4879         LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
4880         LC_HAVE_XATTR_HANDLER_NAME
4881         LC_HAVE_BI_OPF
4882         LC_HAVE_SUBMIT_BIO_2ARGS
4883         LC_HAVE_CLEAN_BDEV_ALIASES
4884
4885         # 4.5
4886         LC_HAVE_FILE_DENTRY
4887
4888         # 4.5
4889         LC_HAVE_INODE_LOCK
4890         LC_HAVE_IOP_GET_LINK
4891
4892         # 4.6
4893         LC_HAVE_IN_COMPAT_SYSCALL
4894         LC_HAVE_XATTR_HANDLER_INODE_PARAM
4895         LC_LOCK_PAGE_MEMCG
4896         LC_HAVE_DOWN_WRITE_KILLABLE
4897
4898         # 4.7
4899         LC_D_IN_LOOKUP
4900         LC_D_INIT
4901         LC_DIRECTIO_2ARGS
4902         LC_GENERIC_WRITE_SYNC_2ARGS
4903         LC_FOP_ITERATE_SHARED
4904
4905         # 4.8
4906         LC_HAVE_POSIX_ACL_VALID_USER_NS
4907         LC_D_COMPARE_4ARGS
4908         LC_FULL_NAME_HASH_3ARGS
4909         LC_STRUCT_POSIX_ACL_XATTR
4910         LC_IOP_XATTR
4911
4912         # 4.9
4913         LC_GROUP_INFO_GID
4914         LC_VFS_SETXATTR
4915         LC_POSIX_ACL_UPDATE_MODE
4916         LC_HAVE_BDI_IO_PAGES
4917
4918         # 4.10
4919         LC_IOP_GENERIC_READLINK
4920         LC_HAVE_VM_FAULT_ADDRESS
4921
4922         # 4.11
4923         LC_INODEOPS_ENHANCED_GETATTR
4924         LC_VM_OPERATIONS_REMOVE_VMF_ARG
4925         LC_HAVE_KEY_USAGE_REFCOUNT
4926         LC_HAVE_CRYPTO_MAX_ALG_NAME_128
4927         LC_HAVE_FSMAP_HEADER
4928         LC_HAVE_PERCPU_COUNTER_ADD_BATCH
4929
4930         # 4.12
4931         LC_CURRENT_TIME
4932         LC_SUPER_SETUP_BDI_NAME
4933         LC_BI_STATUS
4934
4935         # 4.13
4936         LC_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL
4937         LC_HAVE_GET_INODE_USAGE
4938
4939         # 4.14
4940         LC_PAGEVEC_INIT_ONE_PARAM
4941         LC_BI_BDEV
4942         LC_INTERVAL_TREE_CACHED
4943
4944         # 4.17
4945         LC_VM_FAULT_T
4946         LC_VM_FAULT_RETRY
4947         LC_I_PAGES
4948
4949         # 4.18
4950         LC_ALLOC_FILE_PSEUDO
4951         LC_INODE_TIMESPEC64
4952
4953         # 4.20
4954         LC_RADIX_TREE_TAG_SET
4955         LC_UAPI_LINUX_MOUNT_H
4956         LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
4957
4958         # 5.0
4959         LC_GENL_FAMILY_HAS_RESV_START_OP
4960
4961         # 5.1
4962         LC_HAVE_BVEC_ITER_ALL
4963
4964         # 5.2
4965         LC_KEYRING_SEARCH_4ARGS
4966
4967         # 5.3
4968         LC_BIO_BI_PHYS_SEGMENTS
4969         LC_HAVE_FLUSH_DELAYED_FPUT
4970         LC_LM_COMPARE_OWNER_EXISTS
4971
4972         # 5.5
4973         LC_FSCRYPT_DIGESTED_NAME
4974
4975         # 5.7
4976         LC_FSCRYPT_DUMMY_CONTEXT_ENABLED
4977
4978         # 5.8
4979         LC_HAVE_KTHREAD_USE_MM
4980
4981         # 5.9
4982         LC_HAVE_ITER_FILE_SPLICE_WRITE
4983
4984         # 5.9
4985         LC_FSCRYPT_FNAME_ALLOC_BUFFER
4986         LC_FSCRYPT_SET_CONTEXT
4987         LC_FSCRYPT_D_REVALIDATE
4988         LC_FSCRYPT_NOKEY_NAME
4989         LC_FSCRYPT_SET_TEST_DUMMY_ENC_CHAR_ARG
4990         LC_FSCRYPT_DUMMY_POLICY
4991
4992         # 5.10
4993         LC_HAVE_BDI_DEBUG_STATS
4994         LC_FSCRYPT_IS_NOKEY_NAME
4995         LC_FSCRYPT_PREPARE_READDIR
4996
4997         # 5.11
4998         LC_BIO_SET_DEV
4999
5000         # 5.12
5001         LC_HAVE_USER_NAMESPACE_ARG
5002
5003         # 5.13
5004         LC_HAVE_FILEATTR_GET
5005         LC_HAVE_COPY_PAGE_FROM_ITER_ATOMIC
5006
5007         # 5.15
5008         LC_HAVE_GET_ACL_RCU_ARG
5009
5010         # 5.15
5011         LC_HAVE_GET_ACL_RCU_ARG
5012         LC_HAVE_INVALIDATE_LOCK
5013         LC_HAVE_FAULT_IN_IOV_ITER_READABLE
5014
5015         # 5.16
5016         LC_HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG
5017         LC_HAVE_KIOCB_COMPLETE_2ARGS
5018         LC_EXPORTS_DELETE_FROM_PAGE_CACHE
5019         LC_HAVE_WB_STAT_MOD
5020
5021         # 5.17
5022         LC_HAVE_INVALIDATE_FOLIO
5023         LC_HAVE_DIRTY_FOLIO
5024
5025         # 5.18
5026         LC_HAVE_ALLOC_INODE_SB
5027
5028         # 5.19
5029         LC_GRAB_CACHE_PAGE_WRITE_BEGIN_WITH_FLAGS
5030         LC_HAVE_ADDRESS_SPACE_OPERATIONS_READ_FOLIO
5031         LC_HAVE_READ_CACHE_PAGE_FILLER_WITH_FILE
5032         LC_HAVE_ADDRESS_SPACE_OPERATIONS_RELEASE_FOLIO
5033         LC_HAVE_LSMCONTEXT_INIT
5034         LC_SECURITY_DENTRY_INIT_SECURTY_WITH_CTX
5035
5036         # 6.0
5037         LC_HAVE_NO_LLSEEK
5038         LC_DQUOT_TRANSFER_WITH_USER_NS
5039         LC_HAVE_ADDRESS_SPACE_OPERATIONS_MIGRATE_FOLIO
5040         LC_REGISTER_SHRINKER_FORMAT_NAMED
5041         LC_HAVE_VFS_SETXATTR_NON_CONST_VALUE
5042         LC_HAVE_IOV_ITER_GET_PAGES_ALLOC2
5043
5044         # 6.1
5045         LC_HAVE_GET_RANDOM_U32_AND_U64
5046         LC_NFS_FILLDIR_USE_CTX_RETURN_BOOL
5047         LC_HAVE_FILEMAP_GET_FOLIOS_CONTIG
5048
5049         # 6.2
5050         LC_HAVE_GET_RANDOM_U32_BELOW
5051         LC_HAVE_ACL_WITH_DENTRY
5052
5053         # 6.3
5054         LC_HAVE_MNT_IDMAP_ARG
5055         LC_HAVE_LOCKS_LOCK_FILE_WAIT_IN_FILELOCK
5056         LC_HAVE_U64_CAPABILITY
5057         LC_HAVE_FOLIO_BATCH_REINIT
5058
5059         # 6.4
5060         LC_HAVE_IOV_ITER_IOVEC
5061         LC_HAVE_IOVEC_WITH_IOV_MEMBER
5062         LC_HAVE_CLASS_CREATE_MODULE_ARG
5063
5064         # 6.5
5065         LC_HAVE_FILEMAP_SPLICE_READ
5066         LC_HAVE_ENUM_ITER_PIPE
5067         LC_HAVE_GET_USER_PAGES_WITHOUT_VMA
5068         LC_HAVE_FOLIO_BATCH
5069         LC_HAVE_STRUCT_PAGEVEC
5070
5071         # 6.6
5072         LC_HAVE_FLUSH___WORKQUEUE
5073         LC_HAVE_INODE_GET_CTIME
5074         LC_HAVE_MMAP_WRITE_TRYLOCK
5075         LC_HAVE_GENERIC_FILEATTR_HAS_MASK_ARG
5076         LC_HAVE_NSPROXY_COUNT_AS_REFCOUNT
5077
5078         # 6.7
5079         LC_HAVE_INODE_GET_MTIME_SEC
5080         LC_HAVE_SHRINKER_ALLOC
5081
5082         # 6.8
5083         LC_HAVE_DENTRY_D_CHILDREN
5084         LC_HAVE_GENERIC_ERROR_REMOVE_FOLIO
5085
5086         # kernel patch to extend integrity interface
5087         LC_BIO_INTEGRITY_PREP_FN
5088 ])
5089
5090 #
5091 # LC_PROG_LINUX
5092 #
5093 # Lustre linux kernel checks
5094 #
5095 AC_DEFUN([LC_PROG_LINUX], [
5096         AC_MSG_NOTICE([Lustre kernel checks
5097 ==============================================================================])
5098
5099         LC_CONFIG_PINGER
5100         LC_CONFIG_CHECKSUM
5101         LC_CONFIG_FLOCK
5102         LC_CONFIG_LRU_RESIZE
5103         LC_CONFIG_GSS
5104
5105         LC_GLIBC_SUPPORT_FHANDLES
5106         LC_GLIBC_SUPPORT_COPY_FILE_RANGE
5107         LC_OPENSSL_SSK
5108         LC_OPENSSL_GETSEPOL
5109
5110         # 4.1.0 - Check export
5111         LC_HAVE_SYNC_READ_WRITE
5112
5113         # 4.8 - Check export
5114         LC_EXPORT_DEFAULT_FILE_SPLICE_READ
5115
5116         # 5.2 - Check export
5117         LC_ACCOUNT_PAGE_DIRTIED
5118
5119 ]) # LC_PROG_LINUX
5120
5121 #
5122 # LC_CONFIG_CLIENT
5123 #
5124 # Check whether to build the client side of Lustre
5125 #
5126 AC_DEFUN([LC_CONFIG_CLIENT], [
5127 AC_MSG_CHECKING([whether to build Lustre client support])
5128 AC_ARG_ENABLE([client],
5129         AS_HELP_STRING([--disable-client],
5130                 [disable Lustre client support]),
5131         [], [enable_client="yes"])
5132 AC_MSG_RESULT([$enable_client])
5133 ]) # LC_CONFIG_CLIENT
5134
5135 #
5136 # --enable-mpitests
5137 #
5138 AC_DEFUN([LB_CONFIG_MPITESTS], [
5139 AC_ARG_ENABLE([mpitests],
5140         AS_HELP_STRING([--enable-mpitests=<yes|no|mpicc wrapper>],
5141                        [include mpi tests]), [
5142                 enable_mpitests="yes"
5143                 case $enableval in
5144                 yes)
5145                         MPICC_WRAPPER="mpicc"
5146                         MPI_BIN=$(eval which $MPICC_WRAPPER | xargs dirname)
5147                         ;;
5148                 no)
5149                         enable_mpitests="no"
5150                         MPI_BIN=""
5151                         ;;
5152                 *)
5153                         MPICC_WRAPPER=$enableval
5154                         MPI_BIN=$(eval echo $MPICC_WRAPPER | xargs dirname)
5155                         ;;
5156                 esac
5157         ], [
5158                 enable_mpitests="yes"
5159                 MPICC_WRAPPER="mpicc"
5160                 MPI_BIN=$(eval which $MPICC_WRAPPER | xargs dirname)
5161         ])
5162
5163         if test "x$enable_mpitests" != "xno"; then
5164                 oldcc=$CC
5165                 CC=$MPICC_WRAPPER
5166                 AC_CACHE_CHECK([whether mpitests can be built],
5167                 lb_cv_mpi_tests, [AC_COMPILE_IFELSE([AC_LANG_SOURCE([
5168                         #include <mpi.h>
5169                         int main(void) {
5170                                 int flag;
5171                                 MPI_Initialized(&flag);
5172                                 return 0;
5173                         }
5174                 ])], [lb_cv_mpi_tests="yes"], [lb_cv_mpi_tests="no"])
5175                 ])
5176                 enable_mpitests=$lb_cv_mpi_tests
5177                 CC=$oldcc
5178         fi
5179         AC_SUBST(MPI_BIN)
5180         AC_SUBST(MPICC_WRAPPER)
5181 ]) # LB_CONFIG_MPITESTS
5182
5183 #
5184 # LC_ENABLE_QUOTA
5185 #
5186 # whether to enable quota support global control
5187 #
5188 AC_DEFUN([LC_ENABLE_QUOTA], [
5189 AC_MSG_CHECKING([whether to enable quota support global control])
5190 AC_ARG_ENABLE([quota],
5191         AS_HELP_STRING([--enable-quota],
5192                 [enable quota support]),
5193         [], [enable_quota="yes"])
5194 AS_IF([test "x$enable_quota" = xyes],
5195         [AC_MSG_RESULT([yes])],
5196         [AC_MSG_RESULT([no])])
5197 ]) # LC_ENABLE_QUOTA
5198
5199 #
5200 # LC_QUOTA
5201 #
5202 AC_DEFUN([LC_QUOTA], [
5203 #check global
5204 LC_ENABLE_QUOTA
5205 #check for utils
5206 AS_IF([test "x$enable_quota" != xno -a "x$enable_utils" != xno], [
5207         AC_CHECK_HEADER([sys/quota.h],
5208                 [AC_DEFINE(HAVE_SYS_QUOTA_H, 1,
5209                         [Define to 1 if you have <sys/quota.h>.])],
5210                 [AC_MSG_ERROR([did not find <sys/quota.h> on your system])])
5211 ])
5212 ]) # LC_QUOTA
5213
5214 #
5215 # LC_OSD_ADDON
5216 #
5217 # configure support for optional OSD implementation
5218 #
5219 AC_DEFUN([LC_OSD_ADDON], [
5220 AC_MSG_CHECKING([whether to use OSD addon])
5221 AC_ARG_WITH([osd],
5222         AS_HELP_STRING([--with-osd=path],
5223                 [set path to optional osd]),
5224         [
5225         case "$with_osd" in
5226         no)
5227                 ENABLEOSDADDON=0
5228                 ;;
5229         *)
5230                 OSDADDON="$with_osd"
5231                 ENABLEOSDADDON=1
5232                 ;;
5233         esac
5234         ], [
5235                 ENABLEOSDADDON=0
5236         ])
5237 AS_IF([test $ENABLEOSDADDON -eq 0], [
5238         AC_MSG_RESULT([no])
5239         OSDADDON=""
5240 ], [
5241         OSDMODNAME=$(basename $OSDADDON)
5242         AS_IF([test -e $LUSTRE/$OSDMODNAME], [
5243                 AC_MSG_RESULT([cannot link])
5244                 OSDADDON=""
5245         ], [ln -s $OSDADDON $LUSTRE/$OSDMODNAME], [
5246                 AC_MSG_RESULT([$OSDMODNAME])
5247                 OSDADDON="obj-m += $OSDMODNAME/"
5248         ], [
5249                 AC_MSG_RESULT([cannot link])
5250                 OSDADDON=""
5251         ])
5252 ])
5253 AC_SUBST(OSDADDON)
5254 ]) # LC_OSD_ADDON
5255
5256 #
5257 # LC_CONFIG_CRYPTO
5258 #
5259 # Check whether to enable Lustre client crypto
5260 #
5261 AC_DEFUN([LC_CONFIG_CRYPTO], [
5262 AC_MSG_CHECKING([whether to enable Lustre client crypto])
5263 AC_ARG_ENABLE([crypto],
5264         AS_HELP_STRING([--enable-crypto=yes|no|in-kernel],
5265                 [enable Lustre client crypto (default is yes), use 'in-kernel' to force use of in-kernel fscrypt instead of embedded llcrypt]),
5266         [], [enable_crypto="auto"])
5267 AS_IF([test "x$enable_crypto" != xno -a "x$enable_dist" = xno], [
5268         AC_MSG_RESULT(
5269         )
5270         LC_IS_ENCRYPTED
5271         LC_FSCRYPT_SUPPORT])
5272 AS_IF([test "x$enable_crypto" = xin-kernel], [
5273         AS_IF([test "x$has_fscrypt_support" = xyes], [
5274               AC_DEFINE(HAVE_LUSTRE_CRYPTO, 1, [Enable Lustre client crypto via in-kernel fscrypt])], [
5275               AC_MSG_ERROR([Lustre client crypto cannot be enabled via in-kernel fscrypt.])
5276               enable_crypto=no])],
5277         [AS_IF([test "x$has_is_encrypted" = xyes], [
5278               AC_DEFINE(HAVE_LUSTRE_CRYPTO, 1, [Enable Lustre client crypto via embedded llcrypt])
5279               AC_DEFINE(CONFIG_LL_ENCRYPTION, 1, [embedded llcrypt])
5280               AC_DEFINE(HAVE_FSCRYPT_DUMMY_CONTEXT_ENABLED, 1, [embedded llcrypt uses llcrypt_dummy_context_enabled()])
5281               enable_crypto="embedded-llcrypt"
5282               enable_llcrypt=yes], [
5283               AS_IF([test "x$enable_crypto" = xyes],
5284                     [AC_MSG_ERROR([Lustre client crypto cannot be enabled because of lack of encryption support in your kernel.])])
5285               AS_IF([test "x$enable_crypto" != xno -a "x$enable_dist" = xno],
5286                     [AC_MSG_WARN(Lustre client crypto cannot be enabled because of lack of encryption support in your kernel.)])
5287               enable_crypto=no])])
5288 AS_IF([test "x$enable_dist" != xno], [
5289         enable_crypto=yes
5290         enable_llcrypt=yes])
5291 AC_MSG_RESULT([$enable_crypto])
5292 ]) # LC_CONFIG_CRYPTO
5293
5294 #
5295 # LC_CONFIGURE
5296 #
5297 # other configure checks
5298 #
5299 AC_DEFUN([LC_CONFIGURE], [
5300 AC_MSG_NOTICE([Lustre core checks
5301 ==============================================================================])
5302
5303 # maximum MDS thread count
5304 LC_MDS_MAX_THREADS
5305
5306 # lustre/utils/gss/gss_util.c
5307 # lustre/utils/llog_reader.c
5308 # lustre/utils/create_iam.c
5309 # lustre/utils/libiam.c
5310 AC_CHECK_HEADERS([netdb.h endian.h])
5311
5312 # lustre/utils/llverfs.c lustre/utils/libmount_utils_ldiskfs.c
5313 AC_CHECK_HEADERS([ext2fs/ext2fs.h], [], [
5314         AS_IF([test "x$enable_utils" = xyes -a "x$enable_ldiskfs" = xyes], [
5315                 AC_MSG_ERROR([
5316 ext2fs.h not found. Please install e2fsprogs development package.
5317                 ])
5318         ])
5319 ])
5320
5321 # lustre/tests/statx_test.c
5322 AC_CHECK_FUNCS([statx])
5323
5324 # lustre/utils/lfs.c
5325 AS_IF([test "$enable_dist" = "no"], [
5326                 AC_CHECK_LIB([z], [crc32], [
5327                                  AC_CHECK_HEADER([zlib.h], [], [
5328                                                  AC_MSG_ERROR([zlib.h not found.])])
5329                                  ], [
5330                                  AC_MSG_ERROR([
5331                 zlib library not found. Please install zlib development package.])
5332                 ])
5333 ])
5334
5335 SELINUX=""
5336
5337 AC_CHECK_LIB([selinux], [is_selinux_enabled],
5338         [AC_CHECK_HEADERS([selinux/selinux.h],
5339                         [SELINUX="-lselinux"
5340                         AC_DEFINE([HAVE_SELINUX], 1,
5341                                 [support for selinux ])],
5342                         [AC_MSG_WARN([
5343
5344 No libselinux-devel package found, unable to build selinux enabled tools
5345 ])
5346 ])],
5347         [AC_MSG_WARN([
5348
5349 No selinux package found, unable to build selinux enabled tools
5350 ])
5351 ])
5352 AC_SUBST(SELINUX)
5353
5354 AC_CHECK_LIB([keyutils], [add_key])
5355
5356 # Super safe df
5357 AC_MSG_CHECKING([whether to report minimum OST free space])
5358 AC_ARG_ENABLE([mindf],
5359         AS_HELP_STRING([--enable-mindf],
5360                 [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
5361         [], [enable_mindf="no"])
5362 AC_MSG_RESULT([$enable_mindf])
5363 AS_IF([test "$enable_mindf" = "yes"], [
5364         AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])
5365         AC_SUBST(ENABLE_MINDF, yes)
5366 ], [
5367         AC_SUBST(ENABLE_MINDF, no)
5368 ])
5369
5370 AC_MSG_CHECKING([whether to randomly failing memory alloc])
5371 AC_ARG_ENABLE([fail_alloc],
5372         AS_HELP_STRING([--disable-fail-alloc],
5373                 [disable randomly alloc failure]),
5374         [], [enable_fail_alloc="yes"])
5375 AC_MSG_RESULT([$enable_fail_alloc])
5376 AS_IF([test "x$enable_fail_alloc" != xno], [
5377         AC_DEFINE([RANDOM_FAIL_ALLOC], 1, [enable randomly alloc failure])
5378         AC_SUBST(ENABLE_FAIL_ALLOC, yes)
5379 ], [
5380         AC_SUBST(ENABLE_FAIL_ALLOC, no)
5381 ])
5382
5383 AC_MSG_CHECKING([whether to check invariants (expensive cpu-wise)])
5384 AC_ARG_ENABLE([invariants],
5385         AS_HELP_STRING([--enable-invariants],
5386                 [enable invariant checking (cpu intensive)]),
5387         [], [enable_invariants="no"])
5388 AC_MSG_RESULT([$enable_invariants])
5389 AS_IF([test "x$enable_invariants" = xyes], [
5390         AC_DEFINE([CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK], 1,
5391                   [enable invariant checking])
5392         AC_SUBST(ENABLE_INVARIANTS, yes)
5393 ], [
5394         AC_SUBST(ENABLE_INVARIANTS, no)
5395 ])
5396
5397 AC_MSG_CHECKING([whether to track references with lu_ref])
5398 AC_ARG_ENABLE([lu_ref],
5399         AS_HELP_STRING([--enable-lu_ref],
5400                 [enable lu_ref reference tracking code]),
5401         [], [enable_lu_ref="no"])
5402 AC_MSG_RESULT([$enable_lu_ref])
5403 AS_IF([test "x$enable_lu_ref" = xyes], [
5404         AC_DEFINE([CONFIG_LUSTRE_DEBUG_LU_REF], 1,
5405                   [enable lu_ref reference tracking code])
5406         AC_SUBST(ENABLE_LU_REF, yes)
5407 ], [
5408         AC_SUBST(ENABLE_LU_REF, no)
5409 ])
5410
5411 AC_MSG_CHECKING([whether to enable page state tracking])
5412 AC_ARG_ENABLE([pgstate-track],
5413         AS_HELP_STRING([--enable-pgstate-track],
5414                 [enable page state tracking]),
5415         [], [enable_pgstat_track="no"])
5416 AC_MSG_RESULT([$enable_pgstat_track])
5417 AS_IF([test "x$enable_pgstat_track" = xyes], [
5418         AC_DEFINE([CONFIG_DEBUG_PAGESTATE_TRACKING], 1,
5419                   [enable page state tracking code])
5420         AC_SUBST(ENABLE_PGSTAT_TRACK, yes)
5421 ], [
5422         AC_SUBST(ENABLE_PGSTAT_TRACK, no)
5423 ])
5424
5425 PKG_PROG_PKG_CONFIG
5426 AC_MSG_CHECKING([systemd unit file directory])
5427 AC_ARG_WITH([systemdsystemunitdir],
5428         [AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
5429                 [Directory for systemd service files])],
5430         [], [with_systemdsystemunitdir=auto])
5431 AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"],
5432         [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
5433         AS_IF([test "x$def_systemdsystemunitdir" = "x"],
5434                 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
5435                 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
5436                 with_systemdsystemunitdir=no],
5437         [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
5438 AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
5439         [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
5440 AC_MSG_RESULT([$with_systemdsystemunitdir])
5441
5442 AC_MSG_CHECKING([bash-completion directory])
5443 AC_ARG_WITH([bash-completion-dir],
5444         AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
5445                 [Install the bash auto-completion script in this directory.]),
5446         [],
5447         [with_bash_completion_dir=yes])
5448 AS_IF([test "x$with_bash_completion_dir" = "xyes"], [
5449         BASH_COMPLETION_DIR="`pkg-config --variable=completionsdir bash-completion`"
5450         AS_IF([test "x$BASH_COMPLETION_DIR" = "x"], [
5451                 [BASH_COMPLETION_DIR="/usr/share/bash-completion/completions"]
5452         ])
5453 ], [
5454         BASH_COMPLETION_DIR="$with_bash_completion_dir"
5455 ])
5456 AC_SUBST([BASH_COMPLETION_DIR])
5457 AC_MSG_RESULT([$BASH_COMPLETION_DIR])
5458 ]) # LC_CONFIGURE
5459
5460 #
5461 # LC_CONDITIONALS
5462 #
5463 # AM_CONDITIONALS for lustre
5464 #
5465 AC_DEFUN([LC_CONDITIONALS], [
5466 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
5467 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
5468 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
5469 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
5470 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
5471 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
5472 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
5473 AM_CONDITIONAL(GSS_SSK, test x$enable_ssk = xyes)
5474 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
5475 AM_CONDITIONAL(HAVE_SYSTEMD, test "x$with_systemdsystemunitdir" != "xno")
5476 AM_CONDITIONAL(ENABLE_BASH_COMPLETION, test "x$with_bash_completion_dir" != "xno")
5477 AM_CONDITIONAL(XATTR_HANDLER, test "x$lb_cv_compile_xattr_handler_flags" = xyes)
5478 AM_CONDITIONAL(SELINUX, test "$SELINUX" = "-lselinux")
5479 AM_CONDITIONAL(GETSEPOL, test x$enable_getsepol = xyes &&
5480                          test x$config_getsepol = xyes)
5481 AM_CONDITIONAL(LLCRYPT, test x$enable_llcrypt = xyes)
5482 AM_CONDITIONAL(LIBAIO, test x$enable_libaio = xyes)
5483 ]) # LC_CONDITIONALS
5484
5485 #
5486 # LC_CONFIG_FILES
5487 #
5488 # files that should be generated with AC_OUTPUT
5489 #
5490 AC_DEFUN([LC_CONFIG_FILES],
5491 [AC_CONFIG_FILES([
5492 lustre/Makefile
5493 lustre/autoMakefile
5494 lustre/autoconf/Makefile
5495 lustre/conf/Makefile
5496 lustre/conf/resource/Makefile
5497 lustre/doc/Makefile
5498 lustre/include/Makefile
5499 lustre/include/lustre/Makefile
5500 lustre/include/uapi/linux/lustre/Makefile
5501 lustre/kernel_patches/targets/5.14-rhel9.3.target
5502 lustre/kernel_patches/targets/5.14-rhel9.2.target
5503 lustre/kernel_patches/targets/5.14-rhel9.1.target
5504 lustre/kernel_patches/targets/5.14-rhel9.0.target
5505 lustre/kernel_patches/targets/4.18-rhel8.9.target
5506 lustre/kernel_patches/targets/4.18-rhel8.8.target
5507 lustre/kernel_patches/targets/4.18-rhel8.7.target
5508 lustre/kernel_patches/targets/4.18-rhel8.6.target
5509 lustre/kernel_patches/targets/4.18-rhel8.5.target
5510 lustre/kernel_patches/targets/4.18-rhel8.4.target
5511 lustre/kernel_patches/targets/4.18-rhel8.3.target
5512 lustre/kernel_patches/targets/4.18-rhel8.2.target
5513 lustre/kernel_patches/targets/4.18-rhel8.1.target
5514 lustre/kernel_patches/targets/4.18-rhel8.target
5515 lustre/kernel_patches/targets/3.10-rhel7.9.target
5516 lustre/kernel_patches/targets/3.10-rhel7.8.target
5517 lustre/kernel_patches/targets/3.10-rhel7.7.target
5518 lustre/kernel_patches/targets/3.10-rhel7.6.target
5519 lustre/kernel_patches/targets/3.10-rhel7.5.target
5520 lustre/kernel_patches/targets/4.14-rhel7.5.target
5521 lustre/kernel_patches/targets/4.14-rhel7.6.target
5522 lustre/kernel_patches/targets/4.12-sles12sp4.target
5523 lustre/kernel_patches/targets/4.12-sles12sp5.target
5524 lustre/kernel_patches/targets/4.12-sles15sp1.target
5525 lustre/kernel_patches/targets/5.3-sles15sp2.target
5526 lustre/kernel_patches/targets/5.3-sles15sp3.target
5527 lustre/kernel_patches/targets/5.14-sles15sp4.target
5528 lustre/kernel_patches/targets/5.14-sles15sp5.target
5529 lustre/kernel_patches/targets/3.x-fc18.target
5530 lustre/kernel_patches/targets/5.10-oe2203.target
5531 lustre/kernel_patches/targets/5.10-oe2203sp1.target
5532 lustre/kernel_patches/targets/5.10-oe2203sp2.target
5533 lustre/ldlm/Makefile
5534 lustre/ldlm/autoMakefile
5535 lustre/ec/autoMakefile
5536 lustre/ec/Makefile
5537 lustre/fid/Makefile
5538 lustre/fid/autoMakefile
5539 lustre/llite/Makefile
5540 lustre/llite/autoMakefile
5541 lustre/lov/Makefile
5542 lustre/lov/autoMakefile
5543 lustre/mdc/Makefile
5544 lustre/mdc/autoMakefile
5545 lustre/lmv/Makefile
5546 lustre/lmv/autoMakefile
5547 lustre/lfsck/Makefile
5548 lustre/lfsck/autoMakefile
5549 lustre/mdt/Makefile
5550 lustre/mdt/autoMakefile
5551 lustre/mdd/Makefile
5552 lustre/mdd/autoMakefile
5553 lustre/fld/Makefile
5554 lustre/fld/autoMakefile
5555 lustre/obdclass/Makefile
5556 lustre/obdclass/autoMakefile
5557 lustre/obdecho/Makefile
5558 lustre/obdecho/autoMakefile
5559 lustre/ofd/Makefile
5560 lustre/ofd/autoMakefile
5561 lustre/osc/Makefile
5562 lustre/osc/autoMakefile
5563 lustre/ost/Makefile
5564 lustre/ost/autoMakefile
5565 lustre/osd-ldiskfs/Makefile
5566 lustre/osd-ldiskfs/autoMakefile
5567 lustre/osd-zfs/Makefile
5568 lustre/osd-zfs/autoMakefile
5569 lustre/mgc/Makefile
5570 lustre/mgc/autoMakefile
5571 lustre/mgs/Makefile
5572 lustre/mgs/autoMakefile
5573 lustre/target/Makefile
5574 lustre/target/autoMakefile
5575 lustre/ptlrpc/Makefile
5576 lustre/ptlrpc/autoMakefile
5577 lustre/ptlrpc/gss/Makefile
5578 lustre/ptlrpc/gss/autoMakefile
5579 lustre/quota/Makefile
5580 lustre/quota/autoMakefile
5581 lustre/scripts/Makefile
5582 lustre/scripts/systemd/Makefile
5583 lustre/tests/Makefile
5584 lustre/tests/mpi/Makefile
5585 lustre/tests/iabf/Makefile
5586 lustre/tests/lutf/Makefile
5587 lustre/tests/lutf/src/Makefile
5588 lustre/kunit/Makefile
5589 lustre/kunit/autoMakefile
5590 lustre/utils/Makefile
5591 lustre/utils/gss/Makefile
5592 lustre/osp/Makefile
5593 lustre/osp/autoMakefile
5594 lustre/lod/Makefile
5595 lustre/lod/autoMakefile
5596 ])
5597 ]) # LC_CONFIG_FILES