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