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