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