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