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