Whamcloud - gitweb
LU-16302 llite: Use alloc_inode_sb() to allocate inodes
[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="$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_STACK_SIZE], [
100 LB_CHECK_COMPILE([if stack size is at least 8k],
101 stack_size_8k, [
102         #include <linux/thread_info.h>
103 ], [
104         #if THREAD_SIZE < 8192
105         #error "stack size < 8192"
106         #endif
107 ], [], [AC_MSG_ERROR([
108
109 Lustre requires that Linux is configured with at least a 8KB stack.
110 ])])
111 ]) # LC_STACK_SIZE
112
113 #
114 # LC_MDS_MAX_THREADS
115 #
116 # Allow the user to set the MDS thread upper limit
117 #
118 AC_DEFUN([LC_MDS_MAX_THREADS], [
119 AC_MSG_CHECKING([for maximum number of MDS threads])
120 AC_ARG_WITH([mds_max_threads],
121         AS_HELP_STRING([--with-mds-max-threads=count],
122                 [maximum threads available on the MDS: (default=512)]),
123         [AC_DEFINE_UNQUOTED(MDS_MAX_THREADS, $with_mds_max_threads,
124                 [maximum number of MDS threads])])
125 AC_MSG_RESULT([$with_mds_max_threads])
126 ]) # LC_MDS_MAX_THREADS
127
128 #
129 # LC_CONFIG_PINGER
130 #
131 # the pinger is temporary, until we have the recovery node in place
132 #
133 AC_DEFUN([LC_CONFIG_PINGER], [
134 AC_MSG_CHECKING([whether to enable Lustre pinger support])
135 AC_ARG_ENABLE([pinger],
136         AS_HELP_STRING([--disable-pinger],
137                 [disable recovery pinger support]),
138         [], [enable_pinger="yes"])
139 AC_MSG_RESULT([$enable_pinger])
140 AS_IF([test "x$enable_pinger" != xno],
141         [AC_DEFINE(CONFIG_LUSTRE_FS_PINGER, 1,[Use the Pinger])])
142 ]) # LC_CONFIG_PINGER
143
144 #
145 # LC_CONFIG_CHECKSUM
146 #
147 # do checksum of bulk data between client and OST
148 #
149 AC_DEFUN([LC_CONFIG_CHECKSUM], [
150 AC_MSG_CHECKING([whether to enable data checksum support])
151 AC_ARG_ENABLE([checksum],
152         AS_HELP_STRING([--disable-checksum],
153                 [disable data checksum support]),
154         [], [enable_checksum="yes"])
155 AC_MSG_RESULT([$enable_checksum])
156 AS_IF([test "x$enable_checksum" != xno],
157         [AC_DEFINE(ENABLE_CHECKSUM, 1, [do data checksums])])
158 ]) # LC_CONFIG_CHECKSUM
159
160 #
161 # LC_CONFIG_FLOCK
162 #
163 # enable distributed flock by default
164 #
165 AC_DEFUN([LC_CONFIG_FLOCK], [
166 AC_MSG_CHECKING([whether to enable flock by default])
167 AC_ARG_ENABLE([flock],
168         AS_HELP_STRING([--disable-flock],
169                 [disable flock by default]),
170         [], [enable_flock="yes"])
171 AC_MSG_RESULT([$enable_flock])
172 AS_IF([test "x$enable_flock" != xno],
173         [AC_DEFINE(ENABLE_FLOCK, 1, [enable flock by default])])
174 ]) # LC_CONFIG_FLOCK
175
176 #
177 # LC_CONFIG_HEALTH_CHECK_WRITE
178 #
179 # Turn off the actual write to the disk
180 #
181 AC_DEFUN([LC_CONFIG_HEALTH_CHECK_WRITE], [
182 AC_MSG_CHECKING([whether to enable a write with the health check])
183 AC_ARG_ENABLE([health_write],
184         AS_HELP_STRING([--enable-health_write],
185                 [enable disk writes when doing health check]),
186         [], [enable_health_write="no"])
187 AC_MSG_RESULT([$enable_health_write])
188 AS_IF([test "x$enable_health_write" != xno],
189         [AC_DEFINE(USE_HEALTH_CHECK_WRITE, 1, [Write when Checking Health])])
190 ]) # LC_CONFIG_HEALTH_CHECK_WRITE
191
192 #
193 # LC_CONFIG_LRU_RESIZE
194 #
195 AC_DEFUN([LC_CONFIG_LRU_RESIZE], [
196 AC_MSG_CHECKING([whether to enable lru self-adjusting])
197 AC_ARG_ENABLE([lru_resize],
198         AS_HELP_STRING([--enable-lru-resize],
199                 [enable lru resize support]),
200         [], [enable_lru_resize="yes"])
201 AC_MSG_RESULT([$enable_lru_resize])
202 AS_IF([test "x$enable_lru_resize" != xno],
203         [AC_DEFINE(HAVE_LRU_RESIZE_SUPPORT, 1, [Enable lru resize support])])
204 ]) # LC_CONFIG_LRU_RESIZE
205
206 #
207 # LC_QUOTA_CONFIG
208 #
209 # Quota support. The kernel must support CONFIG_QUOTA.
210 #
211 AC_DEFUN([LC_QUOTA_CONFIG], [
212 LB_CHECK_CONFIG_IM([QUOTA], [],
213         [AC_MSG_ERROR([
214
215 Lustre quota requires that CONFIG_QUOTA is enabled in your kernel.
216 ])])
217 ]) # LC_QUOTA_CONFIG
218
219 #
220 # LC_CONFIG_FHANDLE
221 #
222 # fhandle kernel support for open_by_handle_at() and name_to_handle_at()
223 # system calls. The kernel must support CONFIG_FHANDLE.
224 #
225 AC_DEFUN([LC_CONFIG_FHANDLE], [
226 LB_CHECK_CONFIG_IM([FHANDLE], [],
227         [AC_MSG_ERROR([
228
229 Lustre fid handling requires that CONFIG_FHANDLE is enabled in your kernel.
230 ])])
231 ]) # LC_CONFIG_FHANDLE
232
233 #
234 # LC_POSIX_ACL_CONFIG
235 #
236 # POSIX ACL support.
237 #
238 AC_DEFUN([LC_POSIX_ACL_CONFIG], [
239 LB_CHECK_CONFIG_IM([FS_POSIX_ACL],
240         [AC_DEFINE(CONFIG_LUSTRE_FS_POSIX_ACL, 1, [Enable POSIX acl])
241 ], [ ])
242 ]) # LC_POSIX_ACL_CONFIG
243
244 LB_CHECK_CONFIG_IM([CRYPTO_MD5], [],
245                 [AC_MSG_WARN([kernel MD5 support is recommended by using GSS.])])
246
247 #
248 # LC_CONFIG_GSS_KEYRING
249 #
250 # default 'auto', tests for dependencies, if found, enables;
251 # only called if gss is enabled
252 #
253 AC_DEFUN([LC_CONFIG_GSS_KEYRING], [
254 AC_MSG_CHECKING([whether to enable gss keyring backend])
255 AC_ARG_ENABLE([gss_keyring],
256         [AS_HELP_STRING([--disable-gss-keyring],
257                 [disable gss keyring backend])],
258         [], [AS_IF([test "x$enable_gss" != xno], [
259                         enable_gss_keyring="yes"], [
260                         enable_gss_keyring="auto"])])
261 AC_MSG_RESULT([$enable_gss_keyring])
262 AS_IF([test "x$enable_gss_keyring" != xno], [
263         LB_CHECK_CONFIG_IM([KEYS], [], [
264                 gss_keyring_conf_test="fail"
265                 AC_MSG_WARN([GSS keyring backend requires that CONFIG_KEYS be enabled in your kernel.])])
266
267         AC_CHECK_LIB([keyutils], [keyctl_search], [], [
268                 gss_keyring_conf_test="fail"
269                 AC_MSG_WARN([GSS keyring backend requires libkeyutils])])
270
271         AS_IF([test "x$gss_keyring_conf_test" != xfail], [
272                 AC_DEFINE([HAVE_GSS_KEYRING], [1],
273                         [Define this if you enable gss keyring backend])
274                 enable_gss_keyring="yes"
275         ], [
276                 AS_IF([test "x$enable_gss_keyring" = xyes], [
277                         AC_MSG_ERROR([Cannot enable gss_keyring. See above for details.])
278                 ])
279                 enable_ssk="no"
280         ])
281 ], [
282         enable_ssk="no"
283 ])
284 ]) # LC_CONFIG_GSS_KEYRING
285
286 #
287 # LC_KEY_TYPE_INSTANTIATE_2ARGS
288 #
289 # rhel7 key_type->instantiate takes 2 args (struct key, struct key_preparsed_payload)
290 #
291 AC_DEFUN([LC_KEY_TYPE_INSTANTIATE_2ARGS], [
292 LB_CHECK_COMPILE([if 'key_type->instantiate' has two args],
293 key_type_instantiate_2args, [
294         #include <linux/key-type.h>
295 ],[
296         ((struct key_type *)0)->instantiate(0, NULL);
297 ],[
298         AC_DEFINE(HAVE_KEY_TYPE_INSTANTIATE_2ARGS, 1,
299                 [key_type->instantiate has two args])
300 ])
301 ]) # LC_KEY_TYPE_INSTANTIATE_2ARGS
302
303 #
304 # LC_CONFIG_SUNRPC
305 #
306 AC_DEFUN([LC_CONFIG_SUNRPC], [
307 LB_CHECK_CONFIG_IM([SUNRPC], [], [
308         AS_IF([test "x$sunrpc_required" = xyes], [
309                 AC_MSG_ERROR([
310
311 kernel SUNRPC support is required by using GSS.
312 ])
313         ])])
314 ]) # LC_CONFIG_SUNRPC
315
316 #
317 # LC_CONFIG_GSS (default 'auto' (tests for dependencies, if found, enables))
318 #
319 # Build gss and related tools of Lustre. Currently both kernel and user space
320 # parts are depend on linux platform.
321 #
322 AC_DEFUN([LC_CONFIG_GSS], [
323 AC_MSG_CHECKING([whether to enable gss support])
324 AC_ARG_ENABLE([gss],
325         [AS_HELP_STRING([--enable-gss], [enable gss support])],
326         [], [enable_gss="auto"])
327 AC_MSG_RESULT([$enable_gss])
328
329 AC_ARG_VAR([TEST_JOBS],
330     [simultaneous jobs during configure (defaults to $(nproc))])
331 if test "x$ac_cv_env_TEST_JOBS_set" != "xset"; then
332         TEST_JOBS=${TEST_JOBS:-$(nproc)}
333 fi
334 AC_SUBST(TEST_JOBS)
335
336 AC_ARG_VAR([TEST_DIR],
337     [location of temporary parallel configure tests (defaults to $PWD/lb2)])
338         TEST_DIR=${TEST_DIR:-${ac_pwd}/_lpb}
339 AC_SUBST(TEST_DIR)
340
341 AS_IF([test "x$enable_gss" != xno], [
342         LC_CONFIG_GSS_KEYRING
343         LC_KEY_TYPE_INSTANTIATE_2ARGS
344         sunrpc_required=$enable_gss
345         LC_CONFIG_SUNRPC
346         sunrpc_required="no"
347
348         LB_CHECK_CONFIG_IM([CRYPTO_MD5], [],
349                 [AC_MSG_WARN([kernel MD5 support is recommended by using GSS.])])
350         LB_CHECK_CONFIG_IM([CRYPTO_SHA1], [],
351                 [AC_MSG_WARN([kernel SHA1 support is recommended by using GSS.])])
352         LB_CHECK_CONFIG_IM([CRYPTO_SHA256], [],
353                 [AC_MSG_WARN([kernel SHA256 support is recommended by using GSS.])])
354         LB_CHECK_CONFIG_IM([CRYPTO_SHA512], [],
355                 [AC_MSG_WARN([kernel SHA512 support is recommended by using GSS.])])
356
357         require_krb5=$enable_gss
358         AC_KERBEROS_V5
359         require_krb5="no"
360
361         AS_IF([test -n "$KRBDIR"], [
362                 gss_conf_test="success"
363         ], [
364                 gss_conf_test="failure"
365         ])
366
367         AS_IF([test "x$gss_conf_test" = xsuccess && test "x$enable_gss" != xno], [
368                 AC_DEFINE([HAVE_GSS], [1], [Define this is if you enable gss])
369                 enable_gss="yes"
370         ], [
371                 enable_gss_keyring="no"
372                 enable_gss="no"
373         ])
374
375         AS_IF([test "x$enable_ssk" != xno], [
376                 enable_ssk=$enable_gss
377         ])
378 ], [
379         enable_gss_keyring="no"
380 ])
381 ]) # LC_CONFIG_GSS
382
383 # LC_OPENSSL_HMAC
384 #
385 # OpenSSL 1.0+ return int for HMAC functions but older SLES11 versions do not
386 AC_DEFUN([LC_OPENSSL_HMAC], [
387 has_hmac_functions="no"
388 saved_flags="$CFLAGS"
389 CFLAGS="$CFLAGS -Werror"
390 AC_MSG_CHECKING([whether OpenSSL has HMAC_Init_ex])
391 AS_IF([test "x$enable_ssk" != xno], [
392 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
393         #include <openssl/hmac.h>
394         #include <openssl/evp.h>
395
396         int main(void) {
397                 int rc;
398                 rc = HMAC_Init_ex(NULL, "test", 4, EVP_md_null(), NULL);
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="$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         }
425 ])],[
426         AC_DEFINE(HAVE_OPENSSL_EVP_PKEY, 1, [OpenSSL EVP_PKEY_get_params])
427         has_evp_pkey="yes"
428 ])
429 ])
430 CFLAGS="$saved_flags"
431 AC_MSG_RESULT([$has_evp_pkey])
432 ]) # LC_OPENSSL_EVP_PKEY
433
434 #
435 # LC_OPENSSL_SSK
436 #
437 # Check whether to enable Lustre client crypto
438 #
439 AC_DEFUN([LC_OPENSSL_SSK], [
440 AC_MSG_CHECKING([whether OpenSSL has functions needed for SSK])
441 AS_IF([test "x$enable_ssk" != xno], [
442         AC_MSG_RESULT(
443         )
444         LC_OPENSSL_HMAC
445         LC_OPENSSL_EVP_PKEY
446 ])
447 AS_IF([test "x$has_hmac_functions" = xyes -o "x$has_evp_pkey" = xyes], [
448         AC_DEFINE(HAVE_OPENSSL_SSK, 1, [OpenSSL HMAC functions needed for SSK])
449 ], [
450         enable_ssk="no"
451 ])
452 AC_MSG_RESULT([$enable_ssk])
453 ]) # LC_OPENSSL_SSK
454
455 # LC_OPENSSL_GETSEPOL
456 #
457 # OpenSSL is needed for l_getsepol
458 AC_DEFUN([LC_OPENSSL_GETSEPOL], [
459 saved_flags="$CFLAGS"
460 CFLAGS="$CFLAGS -Werror"
461 AC_MSG_CHECKING([whether openssl-devel is present])
462 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
463         #include <openssl/evp.h>
464
465         int main(void) {
466                 EVP_MD_CTX *mdctx = EVP_MD_CTX_create();
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 in 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_INVALIDATE_RANGE], [
496 LB_CHECK_COMPILE([if 'address_space_operations.invalidatepage' requires 3 arguments],
497 address_space_ops_invalidatepage_3args, [
498         #include <linux/fs.h>
499 ],[
500         struct address_space_operations a_ops;
501         a_ops.invalidatepage(NULL, 0, 0);
502 ],[
503         AC_DEFINE(HAVE_INVALIDATE_RANGE, 1,
504                 [address_space_operations.invalidatepage needs 3 arguments])
505 ])
506 ]) # LC_INVALIDATE_RANGE
507
508 #
509 # LC_HAVE_DIR_CONTEXT
510 #
511 # 3.11 readdir now takes the new struct dir_context
512 #
513 AC_DEFUN([LC_HAVE_DIR_CONTEXT], [
514 LB_CHECK_COMPILE([if 'dir_context' exist],
515 dir_context, [
516         #include <linux/fs.h>
517 ],[
518 #ifdef FMODE_KABI_ITERATE
519 #error "back to use readdir in kabi_extand mode"
520 #else
521         struct dir_context ctx;
522
523         ctx.pos = 0;
524 #endif
525 ],[
526         AC_DEFINE(HAVE_DIR_CONTEXT, 1,
527                 [dir_context exist])
528 ])
529 ]) # LC_HAVE_DIR_CONTEXT
530
531 #
532 # LC_D_COMPARE_5ARGS
533 #
534 # 3.11 dentry_operations.d_compare() taken 5 arguments.
535 #
536 AC_DEFUN([LC_D_COMPARE_5ARGS], [
537 LB_CHECK_COMPILE([if 'd_compare' taken 5 arguments],
538 d_compare_5args, [
539         #include <linux/dcache.h>
540 ],[
541         ((struct dentry_operations*)0)->d_compare(NULL,NULL,0,NULL,NULL);
542 ],[
543         AC_DEFINE(HAVE_D_COMPARE_5ARGS, 1,
544                 [d_compare need 5 arguments])
545 ])
546 ]) # LC_D_COMPARE_5ARGS
547
548 #
549 # LC_HAVE_DCOUNT
550 #
551 # 3.11 need to access d_count to get dentry reference count
552 #
553 AC_DEFUN([LC_HAVE_DCOUNT], [
554 LB_CHECK_COMPILE([if 'd_count' exists],
555 d_count, [
556         #include <linux/dcache.h>
557 ],[
558         struct dentry de = { };
559         int count;
560
561         count = d_count(&de);
562 ],[
563         AC_DEFINE(HAVE_D_COUNT, 1,
564                 [d_count exist])
565 ])
566 ]) # LC_HAVE_DCOUNT
567
568 #
569 # LC_PID_NS_FOR_CHILDREN
570 #
571 # 3.11 replaces pid_ns by pid_ns_for_children in struct nsproxy
572 #
573 AC_DEFUN([LC_PID_NS_FOR_CHILDREN], [
574 LB_CHECK_COMPILE([if 'struct nsproxy' has 'pid_ns_for_children'],
575 pid_ns_for_children, [
576         #include <linux/nsproxy.h>
577 ],[
578         struct nsproxy ns;
579         ns.pid_ns_for_children = NULL;
580 ],[
581         AC_DEFINE(HAVE_PID_NS_FOR_CHILDREN, 1,
582                   ['struct nsproxy' has 'pid_ns_for_children'])
583 ])
584 ]) # LC_PID_NS_FOR_CHILDREN
585
586 #
587 # LC_OLDSIZE_TRUNCATE_PAGECACHE
588 #
589 # 3.12 truncate_pagecache without oldsize parameter
590 #
591 AC_DEFUN([LC_OLDSIZE_TRUNCATE_PAGECACHE], [
592 LB_CHECK_COMPILE([if 'truncate_pagecache' with 'old_size' parameter],
593 truncate_pagecache_old_size, [
594         #include <linux/mm.h>
595 ],[
596         truncate_pagecache(NULL, 0, 0);
597 ],[
598         AC_DEFINE(HAVE_OLDSIZE_TRUNCATE_PAGECACHE, 1,
599                 [with oldsize])
600 ])
601 ]) # LC_OLDSIZE_TRUNCATE_PAGECACHE
602
603 #
604 # LC_PTR_ERR_OR_ZERO
605 #
606 # For some reason SLES11SP4 is missing the PTR_ERR_OR_ZERO macro
607 # It was added to linux kernel 3.12
608 #
609 AC_DEFUN([LC_PTR_ERR_OR_ZERO_MISSING], [
610 LB_CHECK_COMPILE([if 'PTR_ERR_OR_ZERO' is missing],
611 is_err_or_null, [
612         #include <linux/err.h>
613 ],[
614         if (PTR_ERR_OR_ZERO(NULL)) return 0;
615 ],[
616         AC_DEFINE(HAVE_PTR_ERR_OR_ZERO, 1,
617                 ['PTR_ERR_OR_ZERO' exist])
618 ])
619 ]) # LC_PTR_ERR_OR_ZERO_MISSING
620
621 #
622 # LC_HAVE_DENTRY_D_U_D_ALIAS
623 #
624 # 3.11 kernel moved d_alias to the union d_u in struct dentry
625 #
626 # Some distros move d_alias to d_u but it is still a struct list
627 #
628 AC_DEFUN([LC_HAVE_DENTRY_D_U_D_ALIAS], [
629 AS_IF([test "x$lb_cv_compile_i_dentry_d_alias_list" = xyes], [
630         LB_CHECK_COMPILE([if list 'dentry.d_u.d_alias' exist],
631         d_alias, [
632                 #include <linux/list.h>
633                 #include <linux/dcache.h>
634         ],[
635                 struct dentry de;
636                 INIT_LIST_HEAD(&de.d_u.d_alias);
637         ],[
638                 AC_DEFINE(HAVE_DENTRY_D_U_D_ALIAS, 1,
639                         [list dentry.d_u.d_alias exist])
640         ])
641 ],[
642         LB_CHECK_COMPILE([if hlist 'dentry.d_u.d_alias' exist],
643         d_alias, [
644                 #include <linux/list.h>
645                 #include <linux/dcache.h>
646         ],[
647                 struct dentry de;
648                 INIT_HLIST_NODE(&de.d_u.d_alias);
649         ],[
650                 AC_DEFINE(HAVE_DENTRY_D_U_D_ALIAS, 1,
651                         [hlist dentry.d_u.d_alias exist])
652         ])
653 ])
654 ]) # LC_HAVE_DENTRY_D_U_D_ALIAS
655
656 #
657 # LC_HAVE_DENTRY_D_CHILD
658 #
659 # 3.11 kernel d_child has been moved out of the union d_u
660 # in struct dentry
661 #
662 AC_DEFUN([LC_HAVE_DENTRY_D_CHILD], [
663 LB_CHECK_COMPILE([if 'dentry.d_child' exist],
664 d_child, [
665         #include <linux/list.h>
666         #include <linux/dcache.h>
667 ],[
668         struct dentry de;
669         INIT_LIST_HEAD(&de.d_child);
670 ],[
671         AC_DEFINE(HAVE_DENTRY_D_CHILD, 1,
672                 [dentry.d_child exist])
673 ])
674 ]) # LC_HAVE_DENTRY_D_CHILD
675
676 #
677 # LC_KIOCB_KI_LEFT
678 #
679 # 3.12 ki_left removed from struct kiocb
680 #
681 AC_DEFUN([LC_KIOCB_KI_LEFT], [
682 LB_CHECK_COMPILE([if 'struct kiocb' with 'ki_left' member],
683 kiocb_ki_left, [
684         #include <linux/aio.h>
685 ],[
686         ((struct kiocb*)0)->ki_left = 0;
687 ],[
688         AC_DEFINE(HAVE_KIOCB_KI_LEFT, 1,
689                 [ki_left exist])
690 ])
691 ]) # LC_KIOCB_KI_LEFT
692
693 #
694 # LC_REGISTER_SHRINKER_RET
695 #
696 # v3.11-8748-g1d3d4437eae1 register_shrinker returns a status
697 #
698 AC_DEFUN([LC_REGISTER_SHRINKER_RET], [
699 LB_CHECK_COMPILE([if register_shrinker() returns status],
700 register_shrinker_ret, [
701         #include <linux/mm.h>
702 ],[
703         if (register_shrinker(NULL))
704                 unregister_shrinker(NULL);
705 ],[
706         AC_DEFINE(HAVE_REGISTER_SHRINKER_RET, 1,
707                 [register_shrinker() returns status])
708 ])
709 ]) # LC_REGISTER_SHRINKER_RET
710
711 #
712 # LC_VFS_RENAME_5ARGS
713 #
714 # 3.13 has vfs_rename with 5 args
715 #
716 AC_DEFUN([LC_VFS_RENAME_5ARGS], [
717 LB_CHECK_COMPILE([if Linux kernel has 'vfs_rename' with 5 args],
718 vfs_rename_5args, [
719         #include <linux/fs.h>
720 ],[
721         vfs_rename(NULL, NULL, NULL, NULL, NULL);
722 ], [
723         AC_DEFINE(HAVE_VFS_RENAME_5ARGS, 1,
724                 [kernel has vfs_rename with 5 args])
725 ])
726 ]) # LC_VFS_RENAME_5ARGS
727
728 #
729 # LC_VFS_UNLINK_3ARGS
730 #
731 # 3.13 has vfs_unlink with 3 args
732 #
733 AC_DEFUN([LC_VFS_UNLINK_3ARGS], [
734 LB_CHECK_COMPILE([if Linux kernel has 'vfs_unlink' with 3 args],
735 vfs_unlink_3args, [
736         #include <linux/fs.h>
737 ],[
738         vfs_unlink(NULL, NULL, NULL);
739 ], [
740         AC_DEFINE(HAVE_VFS_UNLINK_3ARGS, 1,
741                 [kernel has vfs_unlink with 3 args])
742 ])
743 ]) # LC_VFS_UNLINK_3ARGS
744
745 # LC_HAVE_D_IS_POSITIVE
746 #
747 # Kernel version 3.13 b18825a7c8e37a7cf6abb97a12a6ad71af160de7
748 # d_is_positive is added
749 #
750 AC_DEFUN([LC_HAVE_D_IS_POSITIVE], [
751 LB_CHECK_COMPILE([if 'd_is_positive' exist],
752 d_is_positive, [
753         #include <linux/dcache.h>
754 ],[
755         d_is_positive(NULL);
756 ],[
757         AC_DEFINE(HAVE_D_IS_POSITIVE, 1,
758                 ['d_is_positive' is available])
759 ])
760 ]) # LC_HAVE_D_IS_POSITIVE
761
762 #
763 # LC_HAVE_BVEC_ITER
764 #
765 # 3.14 move some of its data in struct bio into the new
766 # struct bvec_iter
767 #
768 AC_DEFUN([LC_HAVE_BVEC_ITER], [
769 LB_CHECK_COMPILE([if Linux kernel has struct bvec_iter],
770 have_bvec_iter, [
771         #include <linux/bio.h>
772 ],[
773         struct bvec_iter iter;
774
775         iter.bi_bvec_done = 0;
776 ], [
777         AC_DEFINE(HAVE_BVEC_ITER, 1,
778                 [kernel has struct bvec_iter])
779 ])
780 ]) # LC_HAVE_BVEC_ITER
781
782 #
783 # LC_IOP_SET_ACL
784 #
785 # 3.14 adds set_acl method to inode_operations
786 # see kernel commit 893d46e443346370cd4ea81d9d35f72952c62a37
787 #
788 AC_DEFUN([LC_IOP_SET_ACL], [
789 LB_CHECK_COMPILE([if 'inode_operations' has '.set_acl' member function],
790 inode_ops_set_acl, [
791         #include <linux/fs.h>
792 ],[
793         struct inode_operations iop;
794         iop.set_acl = NULL;
795 ],[
796         AC_DEFINE(HAVE_IOP_SET_ACL, 1,
797                 [inode_operations has .set_acl member function])
798 ])
799 ]) # LC_IOP_SET_ACL
800
801 #
802 # LC_HAVE_TRUNCATE_IPAGE_FINAL
803 #
804 # 3.14 bring truncate_inode_pages_final for evict_inode
805 #
806 AC_DEFUN([LC_HAVE_TRUNCATE_IPAGES_FINAL], [
807 LB_CHECK_COMPILE([if Linux kernel has truncate_inode_pages_final],
808 truncate_ipages_final, [
809         #include <linux/mm.h>
810 ],[
811         truncate_inode_pages_final(NULL);
812 ], [
813         AC_DEFINE(HAVE_TRUNCATE_INODE_PAGES_FINAL, 1,
814                 [kernel has truncate_inode_pages_final])
815 ])
816 ]) # LC_HAVE_TRUNCATE_IPAGES_FINAL
817
818 #
819 # LC_IOPS_RENAME_WITH_FLAGS
820 #
821 # 3.14 has inode_operations->rename with 5 args
822 # commit 520c8b16505236fc82daa352e6c5e73cd9870cff
823 #
824 AC_DEFUN([LC_IOPS_RENAME_WITH_FLAGS], [
825 LB_CHECK_COMPILE([if 'inode_operations->rename' taken flags as argument],
826 iops_rename_with_flags, [
827         #include <linux/fs.h>
828 ],[
829         struct inode *i1 = NULL, *i2 = NULL;
830         struct dentry *d1 = NULL, *d2 = NULL;
831         int rc;
832         rc = ((struct inode_operations *)0)->rename(i1, d1, i2, d2, 0);
833 ], [
834         AC_DEFINE(HAVE_IOPS_RENAME_WITH_FLAGS, 1,
835                 [inode_operations->rename need flags as argument])
836 ])
837 ]) # LC_IOPS_RENAME_WITH_FLAGS
838
839 #
840 # LC_VFS_RENAME_6ARGS
841 #
842 # 3.15 has vfs_rename with 6 args
843 #
844 AC_DEFUN([LC_VFS_RENAME_6ARGS], [
845 LB_CHECK_COMPILE([if Linux kernel has 'vfs_rename' with 6 args],
846 vfs_rename_6args, [
847         #include <linux/fs.h>
848 ],[
849         vfs_rename(NULL, NULL, NULL, NULL, NULL, NULL);
850 ], [
851         AC_DEFINE(HAVE_VFS_RENAME_6ARGS, 1,
852                 [kernel has vfs_rename with 6 args])
853 ])
854 ]) # LC_VFS_RENAME_6ARGS
855
856 #
857 # LC_DIRECTIO_USE_ITER
858 #
859 # 3.16 kernel changes direct IO to use iov_iter
860 #
861 AC_DEFUN([LC_DIRECTIO_USE_ITER], [
862 LB_CHECK_COMPILE([if direct IO uses iov_iter],
863 direct_io_iter, [
864         #include <linux/fs.h>
865 ],[
866         struct address_space_operations ops = { };
867         struct iov_iter *iter = NULL;
868         loff_t offset = 0;
869
870         ops.direct_IO(0, NULL, iter, offset);
871 ],[
872         AC_DEFINE(HAVE_DIRECTIO_ITER, 1,
873                 [direct IO uses iov_iter])
874 ])
875 ]) # LC_DIRECTIO_USE_ITER
876
877 #
878 # LC_HAVE_IOV_ITER_INIT_DIRECTION
879 #
880 #
881 # 3.16 linux commit 71d8e532b1549a478e6a6a8a44f309d050294d00
882 #      changed iov_iter_init api to start accepting a tag
883 #      that defines if its a read or write operation
884 #
885 AC_DEFUN([LC_HAVE_IOV_ITER_INIT_DIRECTION], [
886 tmp_flags="$EXTRA_KCFLAGS"
887 EXTRA_KCFLAGS="-Werror"
888 LB_CHECK_COMPILE([if 'iov_iter_init' takes a tag],
889 iter_init, [
890         #include <linux/uio.h>
891         #include <linux/fs.h>
892 ],[
893         const struct iovec *iov = NULL;
894
895         iov_iter_init(NULL, READ, iov, 1, 0);
896 ],[
897         AC_DEFINE(HAVE_IOV_ITER_INIT_DIRECTION, 1,
898                 [iov_iter_init handles directional tag])
899 ])
900 EXTRA_KCFLAGS="$tmp_flags"
901 ]) # LC_HAVE_IOV_ITER_INIT_DIRECTION
902
903 #
904 # LC_HAVE_IOV_ITER_TRUNCATE
905 #
906 #
907 # 3.16 introduces a new API iov_iter_truncate()
908 #
909 AC_DEFUN([LC_HAVE_IOV_ITER_TRUNCATE], [
910 tmp_flags="$EXTRA_KCFLAGS"
911 EXTRA_KCFLAGS="-Werror"
912 LB_CHECK_COMPILE([if 'iov_iter_truncate' exists ],
913 iter_truncate, [
914         #include <linux/uio.h>
915         #include <linux/fs.h>
916 ],[
917         struct iov_iter *i = NULL;
918
919         iov_iter_truncate(i, 0);
920 ],[
921         AC_DEFINE(HAVE_IOV_ITER_TRUNCATE, 1, [iov_iter_truncate exists])
922 ])
923 EXTRA_KCFLAGS="$tmp_flags"
924 ]) # LC_HAVE_IOV_ITER_TRUNCATE
925
926 #
927 # LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
928 #
929 # 3.16 introduces [read|write]_iter to struct file_operations
930 #
931 AC_DEFUN([LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER], [
932 LB_CHECK_COMPILE([if 'file_operations.[read|write]_iter' exist],
933 file_function_iter, [
934         #include <linux/fs.h>
935 ],[
936         ((struct file_operations *)NULL)->read_iter(NULL, NULL);
937         ((struct file_operations *)NULL)->write_iter(NULL, NULL);
938 ],[
939         AC_DEFINE(HAVE_FILE_OPERATIONS_READ_WRITE_ITER, 1,
940                 [file_operations.[read|write]_iter functions exist])
941 ])
942 ]) # LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
943
944 #
945 # LC_HAVE_INTERVAL_BLK_INTEGRITY
946 #
947 # 3.17 replace sector_size with interval in struct blk_integrity
948 #
949 AC_DEFUN([LC_HAVE_INTERVAL_BLK_INTEGRITY], [
950 LB_CHECK_COMPILE([if 'blk_integrity.interval' exist],
951 interval_blk_integrity, [
952         #include <linux/blkdev.h>
953 ],[
954         ((struct blk_integrity *)0)->interval = 0;
955 ],[
956         AC_DEFINE(HAVE_INTERVAL_BLK_INTEGRITY, 1,
957                 [blk_integrity.interval exist])
958 ])
959 ]) # LC_HAVE_INTERVAL_BLK_INTEGRITY
960
961 #
962 # LC_KEY_MATCH_DATA
963 #
964 # 3.17  replaces key_type::match with match_preparse
965 #       and has new struct key_match_data
966 #
967 AC_DEFUN([LC_KEY_MATCH_DATA], [
968 LB_CHECK_COMPILE([if struct key_match field exist],
969 key_match, [
970         #include <linux/key-type.h>
971 ],[
972         struct key_match_data data;
973
974         data.raw_data = NULL;
975 ],[
976         AC_DEFINE(HAVE_KEY_MATCH_DATA, 1,
977                 [struct key_match_data exist])
978 ])
979 ]) # LC_KEY_MATCH_DATA
980
981 #
982 # LC_HAVE_BLK_INTEGRITY_ITER
983 #
984 # Linux commit v3.17-rc5-69-g1859308853b1 replaces
985 # struct blk_integrity_exchg with struct blk_integrity_iter
986 #
987 AC_DEFUN([LC_HAVE_BLK_INTEGRITY_ITER], [
988 LB_CHECK_COMPILE([if struct blk_integrity_iter exist],
989 blk_integrity_iter, [
990         #ifdef HAVE_LINUX_BLK_INTEGRITY_HEADER
991         # include <linux/blk-integrity.h>
992         #else
993         # include <linux/blkdev.h>
994         #endif
995 ],[
996         struct blk_integrity_iter iter;
997
998         iter.prot_buf = NULL;
999 ],[
1000         AC_DEFINE(HAVE_BLK_INTEGRITY_ITER, 1,
1001                 [kernel has struct blk_integrity_iter])
1002 ])
1003 ]) # LC_HAVE_BLK_INTEGRITY_ITER
1004
1005 #
1006 # LC_NFS_FILLDIR_USE_CTX
1007 #
1008 # 3.18 kernel moved from void cookie to struct dir_context
1009 #
1010 AC_DEFUN([LC_NFS_FILLDIR_USE_CTX], [
1011 tmp_flags="$EXTRA_KCFLAGS"
1012 EXTRA_KCFLAGS="-Werror"
1013 LB_CHECK_COMPILE([if filldir_t uses struct dir_context],
1014 filldir_ctx, [
1015         #include <linux/fs.h>
1016 ],[
1017         int filldir(struct dir_context *ctx, const char* name,
1018                     int i, loff_t off, u64 tmp, unsigned temp)
1019         {
1020                 return 0;
1021         }
1022
1023         struct dir_context ctx = {
1024                 .actor = filldir,
1025         };
1026
1027         ctx.actor(NULL, "test", 0, (loff_t) 0, 0, 0);
1028 ],[
1029         AC_DEFINE(HAVE_FILLDIR_USE_CTX, 1,
1030                 [filldir_t needs struct dir_context as argument])
1031 ])
1032 EXTRA_KCFLAGS="$tmp_flags"
1033 ]) # LC_NFS_FILLDIR_USE_CTX
1034
1035 #
1036 # LC_PERCPU_COUNTER_INIT
1037 #
1038 # 3.18  For kernels 3.18 and after percpu_counter_init starts
1039 #       to pass a GFP_* memory allocation flag for internal
1040 #       memory allocation purposes.
1041 #
1042 AC_DEFUN([LC_PERCPU_COUNTER_INIT], [
1043 LB_CHECK_COMPILE([if percpu_counter_init uses GFP_* flag as argument],
1044 percpu_counter_init, [
1045         #include <linux/percpu_counter.h>
1046 ],[
1047         percpu_counter_init(NULL, 0, GFP_KERNEL);
1048 ],[
1049         AC_DEFINE(HAVE_PERCPU_COUNTER_INIT_GFP_FLAG, 1,
1050                 [percpu_counter_init uses GFP_* flag])
1051 ])
1052 ]) # LC_PERCPU_COUNTER_INIT
1053
1054 #
1055 # LC_KIOCB_HAS_NBYTES
1056 #
1057 # 3.19 kernel removed ki_nbytes from struct kiocb
1058 #
1059 AC_DEFUN([LC_KIOCB_HAS_NBYTES], [
1060 LB_CHECK_COMPILE([if struct kiocb has ki_nbytes field],
1061 ki_nbytes, [
1062         #include <linux/fs.h>
1063 ],[
1064         struct kiocb iocb = { };
1065
1066         iocb.ki_nbytes = 0;
1067 ],[
1068         AC_DEFINE(HAVE_KI_NBYTES, 1, [ki_nbytes field exist])
1069 ])
1070 ]) # LC_KIOCB_HAS_NBYTES
1071
1072 #
1073 # LC_HAVE_DQUOT_QC_DQBLK
1074 #
1075 # 3.19 has quotactl_ops->[sg]et_dqblk that take struct kqid and qc_dqblk
1076 # Added in commit 14bf61ffe
1077 #
1078 AC_DEFUN([LC_HAVE_DQUOT_QC_DQBLK], [
1079 tmp_flags="$EXTRA_KCFLAGS"
1080 EXTRA_KCFLAGS="-Werror"
1081 LB_CHECK_COMPILE([if 'quotactl_ops.set_dqblk' takes struct qc_dqblk],
1082 qc_dqblk, [
1083         #include <linux/fs.h>
1084         #include <linux/quota.h>
1085 ],[
1086         ((struct quotactl_ops *)0)->set_dqblk(NULL, *((struct kqid*)0), (struct qc_dqblk*)0);
1087 ],[
1088         AC_DEFINE(HAVE_DQUOT_QC_DQBLK, 1,
1089                 [quotactl_ops.set_dqblk takes struct qc_dqblk])
1090         AC_DEFINE(HAVE_DQUOT_KQID, 1,
1091                 [quotactl_ops.set_dqblk takes struct kqid])
1092 ])
1093 EXTRA_KCFLAGS="$tmp_flags"
1094 ]) # LC_HAVE_DQUOT_QC_DQBLK
1095
1096 #
1097 # LC_HAVE_AIO_COMPLETE
1098 #
1099 # 3.19 kernel makes aio_complete() static
1100 #
1101 AC_DEFUN([LC_HAVE_AIO_COMPLETE], [
1102 LB_CHECK_COMPILE([if kernel has exported aio_complete() ],
1103 aio_complete, [
1104         #include <linux/aio.h>
1105 ],[
1106         aio_complete(NULL, 0, 0);
1107 ],[
1108         AC_DEFINE(HAVE_AIO_COMPLETE, 1, [aio_complete defined])
1109 ])
1110 ]) # LC_HAVE_AIO_COMPLETE
1111
1112 #
1113 # LC_HAVE_IS_ROOT_INODE
1114 #
1115 # 3.19 kernel adds is_root_inode()
1116 # Commit a7400222e3eb ("new helper: is_root_inode()")
1117 #
1118 AC_DEFUN([LC_HAVE_IS_ROOT_INODE], [
1119 LB_CHECK_COMPILE([if kernel has is_root_inode() ],
1120 is_root_inode, [
1121         #include <linux/fs.h>
1122 ],[
1123         is_root_inode(NULL);
1124 ],[
1125         AC_DEFINE(HAVE_IS_ROOT_INODE, 1, [is_root_inode defined])
1126 ])
1127 ]) # LC_HAVE_IS_ROOT_INODE
1128
1129 #
1130 # LC_BACKING_DEV_INFO_REMOVAL
1131 #
1132 # 3.20 kernel removed backing_dev_info from address_space
1133 #
1134 AC_DEFUN([LC_BACKING_DEV_INFO_REMOVAL], [
1135 LB_CHECK_COMPILE([if struct address_space has backing_dev_info],
1136 backing_dev_info, [
1137         #include <linux/fs.h>
1138 ],[
1139         struct address_space mapping;
1140
1141         mapping.backing_dev_info = NULL;
1142 ],[
1143         AC_DEFINE(HAVE_BACKING_DEV_INFO, 1, [backing_dev_info exist])
1144 ])
1145 ]) # LC_BACKING_DEV_INFO_REMOVAL
1146
1147 #
1148 # LC_HAVE_BDI_CAP_MAP_COPY
1149 #
1150 # 3.20  removed mmap handling for backing devices since
1151 #       it breaks on non-MMU systems. See kernel commit
1152 #       b4caecd48005fbed3949dde6c1cb233142fd69e9
1153 #
1154 AC_DEFUN([LC_HAVE_BDI_CAP_MAP_COPY], [
1155 LB_CHECK_COMPILE([if have 'BDI_CAP_MAP_COPY'],
1156 bdi_cap_map_copy, [
1157         #include <linux/backing-dev.h>
1158 ],[
1159         struct backing_dev_info info;
1160
1161         info.capabilities = BDI_CAP_MAP_COPY;
1162 ],[
1163         AC_DEFINE(HAVE_BDI_CAP_MAP_COPY, 1,
1164                 [BDI_CAP_MAP_COPY exist])
1165 ])
1166 ]) # LC_HAVE_BDI_CAP_MAP_COPY
1167
1168 #
1169 # LC_HAVE_PROJECT_QUOTA
1170 #
1171 # Kernel version v4.0-rc1-197-g847aac644e92
1172 #
1173 AC_DEFUN([LC_HAVE_PROJECT_QUOTA], [
1174 LB_CHECK_COMPILE([if get_projid exists],
1175 get_projid, [
1176         struct inode;
1177         #include <linux/quota.h>
1178 ],[
1179         struct dquot_operations ops = { };
1180
1181         ops.get_projid(NULL, NULL);
1182 ],[
1183         AC_DEFINE(HAVE_PROJECT_QUOTA, 1,
1184                 [get_projid function exists])
1185 ])
1186 ]) # LC_HAVE_PROJECT_QUOTA
1187
1188 #
1189 # LC_IOV_ITER_RW
1190 #
1191 # 4.1 kernel has iov_iter_rw
1192 #
1193 AC_DEFUN([LC_IOV_ITER_RW], [
1194 LB_CHECK_COMPILE([if iov_iter_rw exist],
1195 iov_iter_rw, [
1196         #include <linux/fs.h>
1197         #include <linux/uio.h>
1198 ],[
1199         struct iov_iter *iter = NULL;
1200
1201         iov_iter_rw(iter);
1202 ],[
1203         AC_DEFINE(HAVE_IOV_ITER_RW, 1,
1204                 [iov_iter_rw exist])
1205 ])
1206 ]) # LC_IOV_ITER_RW
1207
1208 #
1209 # LC_HAVE_SYNC_READ_WRITE
1210 #
1211 # 4.1 new_sync_[read|write] no longer exported
1212 #
1213 AC_DEFUN([LC_HAVE_SYNC_READ_WRITE], [
1214 LB_CHECK_EXPORT([new_sync_read], [fs/read_write.c],
1215         [AC_DEFINE(HAVE_SYNC_READ_WRITE, 1,
1216                         [new_sync_[read|write] is exported by the kernel])])
1217 ]) # LC_HAVE_SYNC_READ_WRITE
1218
1219 #
1220 # LC_HAVE___BI_CNT
1221 #
1222 # 4.1 redefined bi_cnt as __bi_cnt in commit dac56212e8127dbc0
1223 #
1224 AC_DEFUN([LC_HAVE___BI_CNT], [
1225 LB_CHECK_COMPILE([if Linux kernel has __bi_cnt in struct bio],
1226 have___bi_cnt, [
1227         #include <asm/atomic.h>
1228         #include <linux/bio.h>
1229         #include <linux/blk_types.h>
1230 ],[
1231         struct bio bio = { };
1232         int cnt;
1233         cnt = atomic_read(&bio.__bi_cnt);
1234 ], [
1235         AC_DEFINE(HAVE___BI_CNT, 1,
1236                 [struct bio has __bi_cnt])
1237 ])
1238 ]) # LC_HAVE___BI_CNT
1239
1240 #
1241 # LC_SYMLINK_OPS_USE_NAMEIDATA
1242 #
1243 # For the 4.2+ kernels the file system internal symlink api no
1244 # longer uses struct nameidata as a argument
1245 #
1246 AC_DEFUN([LC_SYMLINK_OPS_USE_NAMEIDATA], [
1247 LB_CHECK_COMPILE([if symlink inode operations have struct nameidata argument],
1248 symlink_use_nameidata, [
1249         #include <linux/namei.h>
1250         #include <linux/fs.h>
1251 ],[
1252         struct nameidata *nd = NULL;
1253
1254         ((struct inode_operations *)0)->follow_link(NULL, nd);
1255         ((struct inode_operations *)0)->put_link(NULL, nd, NULL);
1256 ],[
1257         AC_DEFINE(HAVE_SYMLINK_OPS_USE_NAMEIDATA, 1,
1258                 [symlink inode operations need struct nameidata argument])
1259 ])
1260 ]) # LC_SYMLINK_OPS_USE_NAMEIDATA
1261
1262 #
1263 # LC_BIO_ENDIO_USES_ONE_ARG
1264 #
1265 # 4.2 kernel bio_endio now only takes one argument
1266 #
1267 AC_DEFUN([LC_BIO_ENDIO_USES_ONE_ARG], [
1268 LB_CHECK_COMPILE([if 'bio_endio' with one argument exist],
1269 bio_endio, [
1270         #include <linux/bio.h>
1271 ],[
1272         bio_endio(NULL);
1273 ],[
1274         AC_DEFINE(HAVE_BIO_ENDIO_USES_ONE_ARG, 1,
1275                 [bio_endio takes only one argument])
1276 ])
1277 ]) # LC_BIO_ENDIO_USES_ONE_ARG
1278
1279 #
1280 # LC_ACCOUNT_PAGE_DIRTIED_3ARGS
1281 #
1282 # 4.2 [to 4.5] kernel page dirtied takes 3 arguments
1283 #
1284 AC_DEFUN([LC_ACCOUNT_PAGE_DIRTIED_3ARGS], [
1285 LB_CHECK_COMPILE([if 'account_page_dirtied' with 3 args exists],
1286 account_page_dirtied, [
1287         #include <linux/mm.h>
1288 ],[
1289         account_page_dirtied(NULL, NULL, NULL);
1290 ],[
1291         AC_DEFINE(HAVE_ACCOUNT_PAGE_DIRTIED_3ARGS, 1,
1292                 [account_page_dirtied takes three arguments])
1293 ])
1294 ]) # LC_ACCOUNT_PAGE_DIRTIED_3ARGS
1295
1296 #
1297 # LC_HAVE_CRYPTO_ALLOC_SKCIPHER
1298 #
1299 # Kernel version 4.12 commit 7a7ffe65c8c5
1300 # introduced crypto_alloc_skcipher().
1301 #
1302 AC_DEFUN([LC_HAVE_CRYPTO_ALLOC_SKCIPHER], [
1303 LB_CHECK_COMPILE([if crypto_alloc_skcipher is defined],
1304 crypto_alloc_skcipher, [
1305         #include <crypto/skcipher.h>
1306 ],[
1307         crypto_alloc_skcipher(NULL, 0, 0);
1308 ],[
1309         AC_DEFINE(HAVE_CRYPTO_ALLOC_SKCIPHER, 1,
1310                 [crypto_alloc_skcipher is defined])
1311 ])
1312 ]) # LC_HAVE_CRYPTO_ALLOC_SKCIPHER
1313
1314 #
1315 # LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
1316 #
1317 # 4.3 replace interval with interval_exp in 'struct blk_integrity'
1318 # 'struct blk_integrity_profile' is also added in this version,
1319 # thus use this to determine whether 'struct blk_integrity' has profile
1320 #
1321 AC_DEFUN([LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY], [
1322 LB_CHECK_COMPILE([if 'blk_integrity.interval_exp' exist],
1323 blk_integrity_interval_exp, [
1324         #include <linux/blkdev.h>
1325 ],[
1326         ((struct blk_integrity *)0)->interval_exp = 0;
1327 ],[
1328         AC_DEFINE(HAVE_INTERVAL_EXP_BLK_INTEGRITY, 1,
1329                 [blk_integrity.interval_exp exist])
1330 ])
1331 ]) # LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
1332
1333 #
1334 # LC_HAVE_CACHE_HEAD_HLIST
1335 #
1336 # 4.3 kernel swiched to hlist for cache_head
1337 #
1338 AC_DEFUN([LC_HAVE_CACHE_HEAD_HLIST], [
1339 LB_CHECK_COMPILE([if 'struct cache_head' has 'cache_list' field],
1340 cache_head_has_hlist, [
1341         #include <linux/sunrpc/cache.h>
1342 ],[
1343         do {} while(sizeof(((struct cache_head *)0)->cache_list));
1344 ],[
1345         AC_DEFINE(HAVE_CACHE_HEAD_HLIST, 1,
1346                 [cache_head has hlist cache_list])
1347 ])
1348 ]) # LC_HAVE_CACHE_HEAD_HLIST
1349
1350 #
1351 # LC_HAVE_XATTR_HANDLER_SIMPLIFIED
1352 #
1353 # Kernel version 4.3 commit e409de992e3ea3674393465f07cc71c948edd87a
1354 # simplified xattr_handler handling by passing in the handler pointer
1355 #
1356 AC_DEFUN([LC_HAVE_XATTR_HANDLER_SIMPLIFIED], [
1357 tmp_flags="$EXTRA_KCFLAGS"
1358 EXTRA_KCFLAGS="-Werror"
1359 LB_CHECK_COMPILE([if 'struct xattr_handler' functions pass in handler pointer],
1360 xattr_handler_simplified, [
1361         #include <linux/xattr.h>
1362 ],[
1363         struct xattr_handler handler;
1364
1365         ((struct xattr_handler *)0)->get(&handler, NULL, NULL, NULL, 0);
1366         ((struct xattr_handler *)0)->set(&handler, NULL, NULL, NULL, 0, 0);
1367 ],[
1368         AC_DEFINE(HAVE_XATTR_HANDLER_SIMPLIFIED, 1, [handler pointer is parameter])
1369 ])
1370 EXTRA_KCFLAGS="$tmp_flags"
1371 ]) # LC_HAVE_XATTR_HANDLER_SIMPLIFIED
1372
1373 #
1374 # LC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD
1375 #
1376 # 4.3 replace interval with interval_exp in 'struct blk_integrity'.
1377 #
1378 AC_DEFUN([LC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD], [
1379 LB_CHECK_COMPILE([if 'bio_integrity_payload.bip_iter' exist],
1380 bio_integrity_payload_bip_iter, [
1381         #include <linux/bio.h>
1382 ],[
1383         ((struct bio_integrity_payload *)0)->bip_iter.bi_size = 0;
1384 ],[
1385         AC_DEFINE(HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD, 1,
1386                 [bio_integrity_payload.bip_iter exist])
1387 ])
1388 ]) # LC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD
1389
1390 #
1391 # LC_BIO_INTEGRITY_PREP_FN
1392 #
1393 # Lustre kernel patch extents bio_integrity_prep to accept optional
1394 # generate/verify_fn as extra args.
1395 #
1396 AC_DEFUN([LC_BIO_INTEGRITY_PREP_FN], [
1397 LB_CHECK_COMPILE([if 'bio_integrity_prep_fn' exists],
1398 bio_integrity_prep_fn, [
1399         #include <linux/bio.h>
1400 ],[
1401         bio_integrity_prep_fn(NULL, NULL, NULL);
1402 ],[
1403         AC_DEFINE(HAVE_BIO_INTEGRITY_PREP_FN, 1,
1404                 [kernel has bio_integrity_prep_fn])
1405         AC_SUBST(PATCHED_INTEGRITY_INTF)
1406 ],[
1407         AC_SUBST(PATCHED_INTEGRITY_INTF, [#])
1408 ])
1409 ]) # LC_BIO_INTEGRITY_PREP_FN
1410
1411 # LC_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL
1412 #
1413 # 13 kernel integrity API has changed and in 4.13+
1414 # (as well as in rhel 8.4) bio_integrity_prep() returns boolean true
1415 # on success.
1416 #
1417 AC_DEFUN([LC_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL], [
1418 LB_CHECK_COMPILE([if 'bio_integrity_prep_fn' returns bool],
1419 bio_integrity_prep, [
1420        #include <linux/bio.h>
1421        #include <linux/typecheck.h>
1422 ],[
1423         #pragma GCC diagnostic warning "-Werror"
1424         typedef bool (*bio_integrity_prep_type)(struct bio *bio) ;
1425
1426         typecheck_fn(bio_integrity_prep_type, bio_integrity_prep);
1427 ],[
1428        AC_DEFINE(HAVE_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL, 1,
1429                [bio_integrity_prep_fn returns bool])
1430 ])
1431 ]) # LC_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL
1432
1433 #
1434 # LC_HAVE_BI_OPF
1435 #
1436 # 4.4/4.8 redefined bi_rw as bi_opf (SLES12/kernel commit 4382e33ad37486)
1437 #
1438 AC_DEFUN([LC_HAVE_BI_OPF], [
1439 LB_CHECK_COMPILE([if Linux kernel has bi_opf in struct bio],
1440 have_bi_opf, [
1441         #include <linux/bio.h>
1442 ],[
1443         struct bio bio;
1444
1445         bio.bi_opf = 0;
1446 ], [
1447         AC_DEFINE(HAVE_BI_OPF, 1,
1448                 [struct bio has bi_opf])
1449 ])
1450 ]) # LC_HAVE_BI_OPF
1451
1452 #
1453 # LC_HAVE_SUBMIT_BIO_2ARGS
1454 #
1455 # 4.4 removed an argument from submit_bio
1456 #
1457 AC_DEFUN([LC_HAVE_SUBMIT_BIO_2ARGS], [
1458 LB_CHECK_COMPILE([if submit_bio takes two arguments],
1459 have_submit_bio_2args, [
1460         #include <linux/bio.h>
1461 ],[
1462         struct bio bio;
1463         submit_bio(READ, &bio);
1464 ], [
1465         AC_DEFINE(HAVE_SUBMIT_BIO_2ARGS, 1,
1466                 [submit_bio takes two arguments])
1467 ])
1468 ]) # LC_HAVE_SUBMIT_BIO_2_ARGS
1469
1470 #
1471 # LC_HAVE_CLEAN_BDEV_ALIASES
1472 #
1473 # 4.4/4.9 unmap_underlying_metadata was replaced by clean_bdev_aliases
1474 # (SLES12/kernel commit 29f3ad7d8380364c)
1475 #
1476 AC_DEFUN([LC_HAVE_CLEAN_BDEV_ALIASES], [
1477 LB_CHECK_COMPILE([if kernel has clean_bdev_aliases],
1478 have_clean_bdev_aliases, [
1479         #include <linux/buffer_head.h>
1480 ],[
1481         clean_bdev_aliases(NULL,1,1);
1482 ], [
1483         AC_DEFINE(HAVE_CLEAN_BDEV_ALIASES, 1,
1484                 [kernel has clean_bdev_aliases])
1485 ])
1486 ]) # LC_HAVE_CLEAN_BDEV_ALIASES
1487
1488 #
1489 # LC_HAVE_LOCKS_LOCK_FILE_WAIT
1490 #
1491 # 4.4 kernel have moved locks API users to
1492 # locks_lock_inode_wait()
1493 #
1494 AC_DEFUN([LC_HAVE_LOCKS_LOCK_FILE_WAIT], [
1495 LB_CHECK_COMPILE([if 'locks_lock_file_wait' exists],
1496 locks_lock_file_wait, [
1497         #include <linux/fs.h>
1498 ],[
1499         locks_lock_file_wait(NULL, NULL);
1500 ],[
1501         AC_DEFINE(HAVE_LOCKS_LOCK_FILE_WAIT, 1,
1502                 [kernel has locks_lock_file_wait])
1503 ])
1504 ]) # LC_HAVE_LOCKS_LOCK_FILE_WAIT
1505
1506 #
1507 # LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
1508 #
1509 # 4.4 kernel merged type-specific data with the payload data for keys
1510 #
1511 AC_DEFUN([LC_HAVE_KEY_PAYLOAD_DATA_ARRAY], [
1512 LB_CHECK_COMPILE([if 'struct key' has 'payload.data' as an array],
1513 key_payload_data_array, [
1514         #include <linux/key.h>
1515 ],[
1516         struct key key = { };
1517
1518         key.payload.data[0] = NULL;
1519 ],[
1520         AC_DEFINE(HAVE_KEY_PAYLOAD_DATA_ARRAY, 1, [payload.data is an array])
1521 ])
1522 ]) #LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
1523
1524 #
1525 # LC_HAVE_XATTR_HANDLER_NAME
1526 #
1527 # Kernel version 4.4 commit 98e9cb5711c68223f0e4d5201b9a6add255ec550
1528 # add a name member to struct xattr_handler
1529 #
1530 AC_DEFUN([LC_HAVE_XATTR_HANDLER_NAME], [
1531 tmp_flags="$EXTRA_KCFLAGS"
1532 EXTRA_KCFLAGS="-Werror"
1533 LB_CHECK_COMPILE([if 'struct xattr_handler' has a name member],
1534 xattr_handler_name, [
1535         #include <linux/xattr.h>
1536 ],[
1537         ((struct xattr_handler *)NULL)->name = NULL;
1538 ],[
1539         AC_DEFINE(HAVE_XATTR_HANDLER_NAME, 1, [xattr_handler has a name member])
1540 ])
1541 EXTRA_KCFLAGS="$tmp_flags"
1542 ]) # LC_HAVE_XATTR_HANDLER_NAME
1543
1544 #
1545 # LC_HAVE_FILE_DENTRY
1546 #
1547 # 4.5 adds wrapper file_dentry
1548 #
1549 AC_DEFUN([LC_HAVE_FILE_DENTRY], [
1550 LB_CHECK_COMPILE([if Linux kernel has 'file_dentry'],
1551 file_dentry, [
1552         #include <linux/fs.h>
1553 ],[
1554         file_dentry(NULL);
1555 ], [
1556         AC_DEFINE(HAVE_FILE_DENTRY, 1,
1557                 [kernel has file_dentry])
1558 ])
1559 ]) # LC_HAVE_FILE_DENTRY
1560
1561 #
1562 # LC_HAVE_INODE_LOCK
1563 #
1564 # 4.5 introduced inode_lock
1565 #
1566 AC_DEFUN([LC_HAVE_INODE_LOCK], [
1567 LB_CHECK_COMPILE([if 'inode_lock' is defined],
1568 inode_lock, [
1569         #include <linux/fs.h>
1570 ],[
1571         inode_lock(NULL);
1572 ], [
1573         AC_DEFINE(HAVE_INODE_LOCK, 1,
1574                   [inode_lock is defined])
1575 ])
1576 ]) # LC_HAVE_INODE_LOCK
1577
1578 #
1579 # LC_HAVE_IOP_GET_LINK
1580 #
1581 # 4.5 vfs replaced iop->follow_link with
1582 # iop->get_link
1583 #
1584 AC_DEFUN([LC_HAVE_IOP_GET_LINK], [
1585 LB_CHECK_COMPILE([if 'iop' has 'get_link'],
1586 inode_ops_get_link, [
1587         #include <linux/fs.h>
1588 ],[
1589         struct inode_operations iop;
1590         iop.get_link = NULL;
1591 ],[
1592         AC_DEFINE(HAVE_IOP_GET_LINK, 1,
1593                 [have iop get_link])
1594 ])
1595 ]) # LC_HAVE_IOP_GET_LINK
1596
1597 #
1598 # LC_HAVE_IN_COMPAT_SYSCALL
1599 #
1600 # 4.6 renamed is_compat_task to in_compat_syscall
1601 #
1602 AC_DEFUN([LC_HAVE_IN_COMPAT_SYSCALL], [
1603 LB_CHECK_COMPILE([if 'in_compat_syscall' is defined],
1604 in_compat_syscall, [
1605         #include <linux/compat.h>
1606 ],[
1607         in_compat_syscall();
1608 ],[
1609         AC_DEFINE(HAVE_IN_COMPAT_SYSCALL, 1,
1610                 [have in_compat_syscall])
1611 ])
1612 ]) # LC_HAVE_IN_COMPAT_SYSCALL
1613
1614 #
1615 # LC_HAVE_XATTR_HANDLER_INODE_PARAM
1616 #
1617 # Kernel version 4.6 commit b296821a7c42fa58baa17513b2b7b30ae66f3336
1618 # and commit 5930122683dff58f0846b0f0405b4bd598a3ba6a added inode parameter
1619 # to xattr_handler functions
1620 #
1621 AC_DEFUN([LC_HAVE_XATTR_HANDLER_INODE_PARAM], [
1622 tmp_flags="$EXTRA_KCFLAGS"
1623 EXTRA_KCFLAGS="-Werror"
1624 LB_CHECK_COMPILE([if 'struct xattr_handler' functions have inode parameter],
1625 xattr_handler_inode_param, [
1626         #include <linux/xattr.h>
1627 ],[
1628         const struct xattr_handler handler;
1629
1630         ((struct xattr_handler *)0)->get(&handler, NULL, NULL, NULL, NULL, 0);
1631         ((struct xattr_handler *)0)->set(&handler, NULL, NULL, NULL, NULL, 0, 0);
1632 ],[
1633         AC_DEFINE(HAVE_XATTR_HANDLER_INODE_PARAM, 1, [needs inode parameter])
1634 ])
1635 EXTRA_KCFLAGS="$tmp_flags"
1636 ]) # LC_HAVE_XATTR_HANDLER_INODE_PARAM
1637
1638 #
1639 # LC_D_IN_LOOKUP
1640 #
1641 # Kernel version 4.6 commit 85c7f81041d57cfe9dc97f4680d5586b54534a39
1642 # introduced parallel lookups in the VFS layer. The inline function
1643 # d_in_lookup was added to notify when the same item was being queried
1644 # at the same time.
1645 #
1646 AC_DEFUN([LC_D_IN_LOOKUP], [
1647 tmp_flags="$EXTRA_KCFLAGS"
1648 EXTRA_KCFLAGS="-Werror"
1649 LB_CHECK_COMPILE([if 'd_in_lookup' is defined],
1650 d_in_lookup, [
1651         #include <linux/dcache.h>
1652 ],[
1653         d_in_lookup(NULL);
1654 ],[
1655         AC_DEFINE(HAVE_D_IN_LOOKUP, 1, [d_in_lookup is defined])
1656 ])
1657 EXTRA_KCFLAGS="$tmp_flags"
1658 ]) # LC_D_IN_LOOKUP
1659
1660 #
1661 # LC_LOCK_PAGE_MEMCG
1662 #
1663 # Kernel version 4.6 adds lock_page_memcg(page)
1664 # Linux commit v5.15-12273-gab2f9d2d3626
1665 #   mm: unexport {,un}lock_page_memcg
1666 #
1667 AC_DEFUN([LC_LOCK_PAGE_MEMCG], [
1668 LB_CHECK_COMPILE([if 'lock_page_memcg' is defined],
1669 lock_page_memcg, [
1670         #include <linux/memcontrol.h>
1671 ],[
1672         lock_page_memcg(NULL);
1673 ],[
1674         AC_DEFINE(HAVE_LOCK_PAGE_MEMCG, 1,
1675                 [lock_page_memcg is defined])
1676 ])
1677 ]) # LC_LOCK_PAGE_MEMCG
1678
1679 #
1680 # LC_HAVE_DOWN_WRITE_KILLABLE
1681 #
1682 # Kernel version v4.6-rc3-28-g916633a40370
1683 #
1684 AC_DEFUN([LC_HAVE_DOWN_WRITE_KILLABLE], [
1685 LB_CHECK_COMPILE([if down_write_killable exists],
1686 down_write_killable, [
1687         struct rw_semaphore sem;
1688         #include <linux/rwsem.h>
1689 ],[
1690         int rc;
1691
1692         rc = down_write_killable(&sem);
1693 ],[
1694         AC_DEFINE(HAVE_DOWN_WRITE_KILLABLE, 1,
1695                 [down_write_killable function exists])
1696 ])
1697 ]) # LC_HAVE_DOWN_WRITE_KILLABLE
1698
1699 #
1700 # LC_D_INIT
1701 #
1702 # Kernel version 4.7-rc5 commit 285b102d3b745f3c2c110c9c327741d87e64aacc
1703 # add new d_init to initialize dentry at allocation time
1704 #
1705 AC_DEFUN([LC_D_INIT], [
1706 LB_CHECK_COMPILE([if dentry operations supports 'd_init'],
1707 d_init, [
1708         #include <linux/dcache.h>
1709 ],[
1710         struct dentry_operations ops = { };
1711         int rc;
1712
1713         rc = ops.d_init(NULL);
1714 ],[
1715         AC_DEFINE(HAVE_D_INIT, 1, ['d_init' exists])
1716 ])
1717 ]) # LC_D_INIT
1718
1719 #
1720 # LC_DIRECTIO_2ARGS
1721 #
1722 # Kernel version 4.7 commit c8b8e32d700fe943a935e435ae251364d016c497
1723 # direct-io: eliminate the offset argument to ->direct_IO
1724 #
1725 AC_DEFUN([LC_DIRECTIO_2ARGS], [
1726 LB_CHECK_COMPILE([if '->direct_IO()' taken 2 arguments],
1727 direct_io_2args, [
1728         #include <linux/fs.h>
1729 ],[
1730         struct address_space_operations ops = { };
1731         struct iov_iter *iter = NULL;
1732         struct kiocb *iocb = NULL;
1733         int rc;
1734
1735         rc = ops.direct_IO(iocb, iter);
1736 ],[
1737         AC_DEFINE(HAVE_DIRECTIO_2ARGS, 1,
1738                 [direct_IO need 2 arguments])
1739 ])
1740 ]) # LC_DIRECTIO_2ARGS
1741
1742 #
1743 # LC_GENERIC_WRITE_SYNC_2ARGS
1744 #
1745 # Kernel version 4.7 commit dde0c2e79848298cc25621ad080d47f94dbd7cce
1746 # fs: add IOCB_SYNC and IOCB_DSYNC
1747 #
1748 AC_DEFUN([LC_GENERIC_WRITE_SYNC_2ARGS], [
1749 LB_CHECK_COMPILE([if 'generic_write_sync()' taken 2 arguments],
1750 generic_write_sync_2args, [
1751         #include <linux/fs.h>
1752 ],[
1753         struct kiocb *iocb = NULL;
1754         ssize_t rc;
1755
1756         rc = generic_write_sync(iocb, 0);
1757 ],[
1758         AC_DEFINE(HAVE_GENERIC_WRITE_SYNC_2ARGS, 1,
1759                 [generic_write_sync need 2 arguments])
1760 ])
1761 ]) # LC_GENERIC_WRITE_SYNC_2ARGS
1762
1763 #
1764 # LC_FOP_ITERATE_SHARED
1765 #
1766 # Kernel v4.6-rc3-29-g6192269 adds iterate_shared method to file_operations
1767 #
1768 AC_DEFUN([LC_FOP_ITERATE_SHARED], [
1769 LB_CHECK_COMPILE([if 'file_operations' has 'iterate_shared'],
1770 fop_iterate_shared, [
1771         #include <linux/fs.h>
1772 ],[
1773         struct file_operations fop;
1774         fop.iterate_shared = NULL;
1775 ],[
1776         AC_DEFINE(HAVE_FOP_ITERATE_SHARED, 1,
1777                 [file_operations has iterate_shared])
1778 ])
1779 ]) # LC_FOP_ITERATE_SHARED
1780
1781 #
1782 # LC_EXPORT_DEFAULT_FILE_SPLICE_READ
1783 #
1784 # 4.8-rc8 commit 82c156f853840645604acd7c2cebcb75ed1b6652 switched
1785 # generic_file_splice_read() to using ->read_iter. We can test this
1786 # change since default_file_splice_read() is no longer exported.
1787 #
1788 AC_DEFUN([LC_EXPORT_DEFAULT_FILE_SPLICE_READ], [
1789 LB_CHECK_EXPORT([default_file_splice_read], [fs/splice.c],
1790         [AC_DEFINE(HAVE_DEFAULT_FILE_SPLICE_READ_EXPORT, 1,
1791                         [default_file_splice_read is exported])])
1792 ]) # LC_EXPORT_DEFAULT_FILE_SPLCE_READ
1793
1794 #
1795 # LC_HAVE_POSIX_ACL_VALID_USER_NS
1796 #
1797 # 4.8 posix_acl_valid takes struct user_namespace
1798 #
1799 AC_DEFUN([LC_HAVE_POSIX_ACL_VALID_USER_NS], [
1800 LB_CHECK_COMPILE([if 'posix_acl_valid' takes 'struct user_namespace'],
1801 posix_acl_valid, [
1802         #include <linux/fs.h>
1803         #include <linux/posix_acl.h>
1804 ],[
1805         posix_acl_valid((struct user_namespace*)NULL, (const struct posix_acl*)NULL);
1806 ],[
1807         AC_DEFINE(HAVE_POSIX_ACL_VALID_USER_NS, 1,
1808                 [posix_acl_valid takes struct user_namespace])
1809 ])
1810 ]) # LC_HAVE_POSIX_ACL_VALID_USER_NS
1811
1812 #
1813 # LC_D_COMPARE_4ARGS
1814 #
1815 # Kernel version 4.8 commit 6fa67e707559303e086303aeecc9e8b91ef497d5
1816 # get rid of 'parent' argument of ->d_compare()
1817 #
1818 AC_DEFUN([LC_D_COMPARE_4ARGS], [
1819 LB_CHECK_COMPILE([if 'd_compare' taken 4 arguments],
1820 d_compare_4args, [
1821         #include <linux/dcache.h>
1822 ],[
1823         ((struct dentry_operations*)0)->d_compare(NULL,0,NULL,NULL);
1824 ],[
1825         AC_DEFINE(HAVE_D_COMPARE_4ARGS, 1,
1826                 [d_compare need 4 arguments])
1827 ])
1828 ]) # LC_D_COMPARE_4ARGS
1829
1830 #
1831 # LC_FULL_NAME_HASH_3ARGS
1832 #
1833 # Kernel version 4.8 commit 8387ff2577eb9ed245df9a39947f66976c6bcd02
1834 # vfs: make the string hashes salt the hash
1835 #
1836 AC_DEFUN([LC_FULL_NAME_HASH_3ARGS], [
1837 LB_CHECK_COMPILE([if 'full_name_hash' taken 3 arguments],
1838 full_name_hash_3args, [
1839         #include <linux/stringhash.h>
1840 ],[
1841         unsigned int hash;
1842         hash = full_name_hash(NULL,NULL,0);
1843 ],[
1844         AC_DEFINE(HAVE_FULL_NAME_HASH_3ARGS, 1,
1845                 [full_name_hash need 3 arguments])
1846 ])
1847 ]) # LC_FULL_NAME_HASH_3ARGS
1848
1849 #
1850 # LC_STRUCT_POSIX_ACL_XATTR
1851 #
1852 # Kernel version 4.8 commit 2211d5ba5c6c4e972ba6dbc912b2897425ea6621
1853 # posix_acl: xattr representation cleanups
1854 #
1855 AC_DEFUN([LC_STRUCT_POSIX_ACL_XATTR], [
1856 LB_CHECK_COMPILE([if 'struct posix_acl_xattr_{header,entry}' defined],
1857 struct_posix_acl_xattr, [
1858         #include <linux/fs.h>
1859         #include <linux/posix_acl_xattr.h>
1860 ],[
1861         struct posix_acl_xattr_header *h = NULL;
1862         struct posix_acl_xattr_entry  *e;
1863         e = (void *)(h + 1);
1864 ],[
1865         AC_DEFINE(HAVE_STRUCT_POSIX_ACL_XATTR, 1,
1866                 [struct posix_acl_xattr_{header,entry} defined])
1867 ])
1868 ]) # LC_STRUCT_POSIX_ACL_XATTR
1869
1870 #
1871 # LC_IOP_XATTR
1872 #
1873 # Kernel version 4.8 commit fd50ecaddf8372a1d96e0daeaac0f93cf04e4d42
1874 # removed {get,set,remove}xattr inode operations
1875 #
1876 AC_DEFUN([LC_IOP_XATTR], [
1877 LB_CHECK_COMPILE([if 'inode_operations' has {get,set,remove}xattr members],
1878 inode_ops_xattr, [
1879         #include <linux/fs.h>
1880 ],[
1881         struct inode_operations iop;
1882         iop.setxattr = NULL;
1883         iop.getxattr = NULL;
1884         iop.removexattr = NULL;
1885 ],[
1886         AC_DEFINE(HAVE_IOP_XATTR, 1,
1887                 [inode_operations has {get,set,remove}xattr members])
1888 ])
1889 ]) # LC_IOP_XATTR
1890
1891 #
1892 # LC_GROUP_INFO_GID
1893 #
1894 # Kernel version 4.9 commit 81243eacfa400f5f7b89f4c2323d0de9982bb0fb
1895 # cred: simpler, 1D supplementary groups
1896 #
1897 AC_DEFUN([LC_GROUP_INFO_GID], [
1898 LB_CHECK_COMPILE([if 'struct group_info' has member 'gid'],
1899 group_info_gid, [
1900         #include <linux/cred.h>
1901 ],[
1902         kgid_t *p;
1903         p = ((struct group_info *)0)->gid;
1904 ],[
1905         AC_DEFINE(HAVE_GROUP_INFO_GID, 1,
1906                 [struct group_info has member gid])
1907 ])
1908 ]) # LC_GROUP_INFO_GID
1909
1910 #
1911 # LC_VFS_SETXATTR
1912 #
1913 # Kernel version 4.9 commit 5d6c31910bc0713e37628dc0ce677dcb13c8ccf4
1914 # added __vfs_{get,set,remove}xattr helpers
1915 #
1916 AC_DEFUN([LC_VFS_SETXATTR], [
1917 LB_CHECK_COMPILE([if '__vfs_setxattr' helper is available],
1918 vfs_setxattr, [
1919         #include <linux/xattr.h>
1920 ],[
1921         __vfs_setxattr(NULL, NULL, NULL, NULL, 0, 0);
1922 ],[
1923         AC_DEFINE(HAVE_VFS_SETXATTR, 1,
1924                 ['__vfs_setxattr' is available])
1925 ])
1926 ]) # LC_VFS_SETXATTR
1927
1928 #
1929 # LC_POSIX_ACL_UPDATE_MODE
1930 #
1931 # Kernel version 4.9 commit 073931017b49d9458aa351605b43a7e34598caef
1932 # posix_acl: Clear SGID bit when setting file permissions
1933 #
1934 AC_DEFUN([LC_POSIX_ACL_UPDATE_MODE], [
1935 LB_CHECK_COMPILE([if 'posix_acl_update_mode' exists],
1936 posix_acl_update_mode, [
1937         #include <linux/fs.h>
1938         #include <linux/posix_acl.h>
1939 ],[
1940         posix_acl_update_mode(NULL, NULL, NULL);
1941 ],[
1942         AC_DEFINE(HAVE_POSIX_ACL_UPDATE_MODE, 1,
1943                 ['posix_acl_update_mode' is available])
1944 ])
1945 ]) # LC_POSIX_ACL_UPDATE_MODE
1946
1947 #
1948 # LC_HAVE_BDI_IO_PAGES
1949 #
1950 # Kernel version 4.9 commit 9491ae4aade6814afcfa67f4eb3e3342c2b39750
1951 # mm: don't cap request size based on read-ahead setting
1952 # This patch introduces a bdi hint, io_pages.
1953 #
1954 AC_DEFUN([LC_HAVE_BDI_IO_PAGES], [
1955 LB_CHECK_COMPILE([if 'struct backing_dev_info' has 'io_pages' field],
1956 bdi_has_io_pages, [
1957         #include <linux/backing-dev.h>
1958 ],[
1959         struct backing_dev_info info;
1960
1961         info.io_pages = 0;
1962 ],[
1963         AC_DEFINE(HAVE_BDI_IO_PAGES, 1,
1964                 [backing_dev_info has io_pages])
1965 ])
1966 ]) # LC_HAVE_BDI_IO_PAGES
1967
1968 #
1969 # LC_IOP_GENERIC_READLINK
1970 #
1971 # Kernel version 4.10 commit dfeef68862edd7d4bafe68ef7aeb5f658ef24bb5
1972 # removed generic_readlink from individual file systems
1973 #
1974 AC_DEFUN([LC_IOP_GENERIC_READLINK], [
1975 LB_CHECK_COMPILE([if 'generic_readlink' still exist],
1976 inode_ops_readlink, [
1977         #include <linux/fs.h>
1978 ],[
1979         struct inode_operations iop;
1980         iop.readlink = generic_readlink;
1981 ],[
1982         AC_DEFINE(HAVE_IOP_GENERIC_READLINK, 1,
1983                 [generic_readlink has been removed])
1984 ])
1985 ]) # LC_IOP_GENERIC_READLINK
1986
1987 #
1988 # LC_HAVE_VM_FAULT_ADDRESS
1989 #
1990 # Kernel version 4.10 commit 1a29d85eb0f19b7d8271923d8917d7b4f5540b3e
1991 # removed virtual_address field. Need to use address field instead
1992 #
1993 AC_DEFUN([LC_HAVE_VM_FAULT_ADDRESS], [
1994 LB_CHECK_COMPILE([if 'struct vm_fault' replaced virtual_address with address field],
1995 vm_fault_address, [
1996         #include <linux/mm.h>
1997 ],[
1998                 struct vm_fault vmf = { 0 };
1999                 unsigned long addr = (unsigned long)vmf.address;
2000                 (void)addr;
2001 ],[
2002         AC_DEFINE(HAVE_VM_FAULT_ADDRESS, 1,
2003                 [virtual_address has been replaced by address field])
2004 ])
2005 ]) # LC_HAVE_VM_FAULT_ADDRESS
2006
2007 #
2008 # LC_INODEOPS_ENHANCED_GETATTR
2009 #
2010 # Kernel version 4.11 commit a528d35e8bfcc521d7cb70aaf03e1bd296c8493f
2011 # expanded getattr to be able to get more stat information.
2012 #
2013 AC_DEFUN([LC_INODEOPS_ENHANCED_GETATTR], [
2014 LB_CHECK_COMPILE([if 'inode_operations' getattr member can gather advance stats],
2015 getattr_path, [
2016         #include <linux/fs.h>
2017 ],[
2018         struct path path;
2019
2020         ((struct inode_operations *)1)->getattr(&path, NULL, 0, 0);
2021 ],[
2022         AC_DEFINE(HAVE_INODEOPS_ENHANCED_GETATTR, 1,
2023                 [inode_operations .getattr member function can gather advance stats])
2024 ])
2025 ]) # LC_INODEOPS_ENHANCED_GETATTR
2026
2027 #
2028 # LC_VM_OPERATIONS_REMOVE_VMF_ARG
2029 #
2030 # Kernel version 4.11 commit 11bac80004499ea59f361ef2a5516c84b6eab675
2031 # removed struct vm_area_struct as an argument for vm_operations since
2032 # in the same kernel version struct vma_area_struct was folded into
2033 # struct vm_fault.
2034 #
2035 AC_DEFUN([LC_VM_OPERATIONS_REMOVE_VMF_ARG], [
2036 LB_CHECK_COMPILE([if 'struct vm_operations' removed struct vm_area_struct],
2037 vm_operations_no_vm_area_struct, [
2038         #include <linux/mm.h>
2039 ],[
2040         struct vm_fault vmf;
2041
2042         ((struct vm_operations_struct *)0)->fault(&vmf);
2043         ((struct vm_operations_struct *)0)->page_mkwrite(&vmf);
2044 ],[
2045         AC_DEFINE(HAVE_VM_OPS_USE_VM_FAULT_ONLY, 1,
2046                 ['struct vm_operations' remove struct vm_area_struct argument])
2047 ])
2048 ]) # LC_VM_OPERATIONS_REMOVE_VMF_ARG
2049
2050 #
2051 # LC_HAVE_KEY_USAGE_REFCOUNT
2052 #
2053 # Kernel version 4.11 commit fff292914d3a2f1efd05ca71c2ba72a3c663201e
2054 # converted key.usage from atomic_t to refcount_t.
2055 #
2056 AC_DEFUN([LC_HAVE_KEY_USAGE_REFCOUNT], [
2057 LB_CHECK_COMPILE([if 'key.usage' is refcount_t],
2058 key_usage_refcount, [
2059         #include <linux/key.h>
2060 ],[
2061         struct key key = { };
2062
2063         refcount_read(&key.usage);
2064 ],[
2065         AC_DEFINE(HAVE_KEY_USAGE_REFCOUNT, 1, [key.usage is of type refcount_t])
2066 ])
2067 ]) #LC_HAVE_KEY_USAGE_REFCOUNT
2068
2069 #
2070 # LC_HAVE_CRYPTO_MAX_ALG_NAME_128
2071 #
2072 # Kernel version 4.11 commit f437a3f477cce402dbec6537b29e9e33962c9f73
2073 # switched CRYPTO_MAX_ALG_NAME from 64 to 128.
2074 #
2075 AC_DEFUN([LC_HAVE_CRYPTO_MAX_ALG_NAME_128], [
2076 LB_CHECK_COMPILE([if 'CRYPTO_MAX_ALG_NAME' is 128],
2077 crypto_max_alg_name, [
2078         #include <linux/crypto.h>
2079 ],[
2080         #if CRYPTO_MAX_ALG_NAME != 128
2081         exit(1);
2082         #endif
2083 ],[
2084         AC_DEFINE(HAVE_CRYPTO_MAX_ALG_NAME_128, 1,
2085                 ['CRYPTO_MAX_ALG_NAME' is 128])
2086 ])
2087 ]) # LC_HAVE_CRYPTO_MAX_ALG_NAME_128
2088
2089 #
2090 # Kernel version 4.12 commit 47f38c539e9a42344ff5a664942075bd4df93876
2091 # CURRENT_TIME is not 64 bit time safe so it was replaced with
2092 # current_time()
2093 #
2094 AC_DEFUN([LC_CURRENT_TIME], [
2095 LB_CHECK_COMPILE([if CURRENT_TIME has been replaced with current_time],
2096 current_time, [
2097         #include <linux/fs.h>
2098 ],[
2099         struct iattr attr;
2100
2101         attr.ia_atime = current_time(NULL);
2102 ],[
2103         AC_DEFINE(HAVE_CURRENT_TIME, 1,
2104                 [current_time() has replaced CURRENT_TIME])
2105 ])
2106 ]) # LIBCFS_CURRENT_TIME
2107
2108 #
2109 # LC_HAVE_GET_INODE_USAGE
2110 #
2111 # Kernel version v4.12-rc2-43-g7a9ca53aea10
2112 #
2113 AC_DEFUN([LC_HAVE_GET_INODE_USAGE], [
2114 LB_CHECK_COMPILE([if get_inode_usage exists],
2115 get_inode_usage, [
2116         struct inode;
2117         #include <linux/quota.h>
2118 ],[
2119         struct dquot_operations ops = { };
2120
2121         ops.get_inode_usage(NULL, NULL);
2122 ],[
2123         AC_DEFINE(HAVE_GET_INODE_USAGE, 1,
2124                 [get_inode_usage function exists])
2125 ])
2126 ]) # LC_HAVE_GET_INODE_USAGE
2127
2128
2129 #
2130 # Kernel version 4.12-rc3 85787090a21eb749d8b347eaf9ff1a455637473c
2131 # changed struct super_block s_uuid into a proper uuid_t
2132 #
2133 AC_DEFUN([LC_SUPER_BLOCK_S_UUID], [
2134 LB_CHECK_COMPILE([if 'struct super_block' s_uuid is uuid_t],
2135 super_block_s_uuid, [
2136         #include <linux/fs.h>
2137 ],[
2138         struct super_block sb;
2139
2140         uuid_parse(NULL, &sb.s_uuid);
2141 ],[
2142         AC_DEFINE(HAVE_S_UUID_AS_UUID_T, 1, ['s_uuid' is an uuid_t])
2143 ])
2144 ]) # LC_SUPER_BLOCK_S_UUID
2145
2146 #
2147 # LC_SUPER_SETUP_BDI_NAME
2148 #
2149 # Kernel version 4.12 commit 9594caf216dc0fe3e318b34af0127276db661241
2150 # unified bdi handling
2151 #
2152 AC_DEFUN([LC_SUPER_SETUP_BDI_NAME], [
2153 LB_CHECK_COMPILE([if 'super_setup_bdi_name' exist],
2154 super_setup_bdi_name, [
2155         #include <linux/fs.h>
2156 ],[
2157         super_setup_bdi_name(NULL, "lustre");
2158 ],[
2159         AC_DEFINE(HAVE_SUPER_SETUP_BDI_NAME, 1,
2160                 ['super_setup_bdi_name' is available])
2161 ])
2162 ]) # LC_SUPER_SETUP_BDI_NAME
2163
2164 #
2165 # LC_BI_STATUS
2166 #
2167 # 4.12 replace bi_error to bi_status
2168 #
2169 AC_DEFUN([LC_BI_STATUS], [
2170 LB_CHECK_COMPILE([if 'bi_status' exist],
2171 bi_status, [
2172         #include <linux/blk_types.h>
2173 ],[
2174         ((struct bio *)0)->bi_status = 0;
2175 ],[
2176         AC_DEFINE(HAVE_BI_STATUS, 1,
2177                 ['bi_status' is available])
2178 ])
2179 ]) # LC_BI_STATUS
2180
2181 #
2182 # LC_BIO_INTEGRITY_ENABLED
2183 #
2184 # 4.13 removed bio_integrity_enabled
2185 #
2186 AC_DEFUN([LC_BIO_INTEGRITY_ENABLED], [
2187 LB_CHECK_COMPILE([if 'bio_integrity_enabled' exist],
2188 bio_integrity_enabled, [
2189         #include <linux/bio.h>
2190 ],[
2191         bio_integrity_enabled(NULL);
2192 ],[
2193         AC_DEFINE(HAVE_BIO_INTEGRITY_ENABLED, 1,
2194                 ['bio_integrity_enabled' is available])
2195 ])
2196 ]) # LC_BIO_INTEGRITY_ENABLED
2197
2198 #
2199 # LC_PAGEVEC_INIT_ONE_PARAM
2200 #
2201 # 4.14 pagevec_init takes one parameter
2202 #
2203 AC_DEFUN([LC_PAGEVEC_INIT_ONE_PARAM], [
2204 LB_CHECK_COMPILE([if 'pagevec_init' takes one parameter],
2205 pagevec_init, [
2206         #include <linux/pagevec.h>
2207 ],[
2208         pagevec_init(NULL);
2209 ],[
2210         AC_DEFINE(HAVE_PAGEVEC_INIT_ONE_PARAM, 1,
2211                 ['pagevec_init' takes one parameter])
2212 ])
2213 ]) # LC_PAGEVEC_INIT_ONE_PARAM
2214
2215 #
2216 # LC_BI_BDEV
2217 #
2218 # 4.14 replaced bi_bdev to bi_disk
2219 #
2220 AC_DEFUN([LC_BI_BDEV], [
2221 LB_CHECK_COMPILE([if 'bi_bdev' exist],
2222 bi_bdev, [
2223         #include <linux/bio.h>
2224 ],[
2225         ((struct bio *)0)->bi_bdev = NULL;
2226 ],[
2227         AC_DEFINE(HAVE_BI_BDEV, 1,
2228                 ['bi_bdev' is available])
2229 ])
2230 ]) # LC_BI_BDEV
2231
2232 #
2233 # LC_INTERVAL_TREE_CACHED
2234 #
2235 # 4.14 f808c13fd3738948e10196496959871130612b61
2236 # switched INTERVAL_TREE_DEFINE to use cached RB_Trees.
2237 #
2238 AC_DEFUN([LC_INTERVAL_TREE_CACHED], [
2239 tmp_flags="$EXTRA_KCFLAGS"
2240 EXTRA_KCFLAGS="-Werror"
2241 LB_CHECK_COMPILE([if interval_trees use rb_tree_cached],
2242 itree_cached, [
2243         #include <linux/interval_tree_generic.h>
2244         struct foo { struct rb_node rb; int last; int a,b;};
2245         #define START(n) ((n)->a)
2246         #define LAST(n) ((n)->b)
2247         struct rb_root_cached tree;
2248         INTERVAL_TREE_DEFINE(struct foo, rb, int, last,
2249                 START, LAST, , foo);
2250 ],[
2251         foo_insert(NULL, &tree);
2252 ],[
2253         AC_DEFINE(HAVE_INTERVAL_TREE_CACHED, 1,
2254                 [interval trees use rb_tree_cached])
2255 ])
2256 EXTRA_KCFLAGS="$tmp_flags"
2257 ]) # LC_INTERVAL_TREE_CACHED
2258
2259 #
2260 # LC_IS_ENCRYPTED
2261 #
2262 # 4.14 introduced IS_ENCRYPTED and S_ENCRYPTED
2263 #
2264 AC_DEFUN([LC_IS_ENCRYPTED], [
2265 LB_CHECK_COMPILE([if IS_ENCRYPTED is defined],
2266 is_encrypted, [
2267         #include <linux/fs.h>
2268 ],[
2269         IS_ENCRYPTED((struct inode *)0);
2270 ],[
2271         has_is_encrypted="yes"
2272 ])
2273 ]) # LC_IS_ENCRYPTED
2274
2275 #
2276 # LC_I_PAGES
2277 #
2278 # kernel 4.17 commit b93b016313b3ba8003c3b8bb71f569af91f19fc7
2279 #
2280 AC_DEFUN([LC_I_PAGES], [
2281 LB_CHECK_COMPILE([if struct address_space has i_pages],
2282 i_pages, [
2283         #include <linux/fs.h>
2284 ],[
2285         struct address_space mapping = {};
2286         void *i_pages;
2287
2288         i_pages = &mapping.i_pages;
2289 ],[
2290         AC_DEFINE(HAVE_I_PAGES, 1,
2291                 [struct address_space has i_pages])
2292 ])
2293 ]) # LC_I_PAGES
2294
2295 #
2296 # LC_VM_FAULT_T
2297 #
2298 # kernel 4.17 commit 3d3539018d2cbd12e5af4a132636ee7fd8d43ef0
2299 # mm: create the new vm_fault_t type
2300 #
2301 AC_DEFUN([LC_VM_FAULT_T], [
2302 LB_CHECK_COMPILE([if vm_fault_t type exists],
2303 vm_fault_t, [
2304         #include <linux/mm_types.h>
2305 ],[
2306         vm_fault_t x = VM_FAULT_SIGBUS;
2307         (void)x
2308 ],[
2309         AC_DEFINE(HAVE_VM_FAULT_T, 1,
2310                 [if vm_fault_t type exists])
2311 ])
2312 ]) # LC_VM_FAULT_T
2313
2314 #
2315 # LC_VM_FAULT_RETRY
2316 #
2317 # kernel 4.17 commit 3d3539018d2cbd12e5af4a132636ee7fd8d43ef0
2318 # mm: VM_FAULT_RETRY is defined in enum vm_fault_reason
2319 #
2320 AC_DEFUN([LC_VM_FAULT_RETRY], [
2321 LB_CHECK_COMPILE([if VM_FAULT_RETRY is defined],
2322 VM_FAULT_RETRY, [
2323         #include <linux/mm.h>
2324 ],[
2325         #ifndef VM_FAULT_RETRY
2326                 vm_fault_t x;
2327                 x = VM_FAULT_RETRY;
2328         #endif
2329 ],[
2330         AC_DEFINE(HAVE_VM_FAULT_RETRY, 1,
2331                 [if VM_FAULT_RETRY is defined])
2332 ])
2333 ]) # LC_VM_FAULT_RETRY
2334
2335 #
2336 # LC_ALLOC_FILE_PSEUDO
2337 #
2338 # kernel 4.18-rc1 commit d93aa9d82aea80b80f225dbf9c7986df444d8106
2339 # new wrapper: alloc_file_pseudo()
2340 #
2341 AC_DEFUN([LC_ALLOC_FILE_PSEUDO], [
2342 LB_CHECK_COMPILE([if 'alloc_file_pseudo' is defined],
2343 alloc_file_pseudo, [
2344         #include <linux/file.h>
2345 ],[
2346         struct file *file;
2347         file = alloc_file_pseudo(NULL, NULL, "[test]",
2348                                  00000002, NULL);
2349 ],[
2350         AC_DEFINE(HAVE_ALLOC_FILE_PSEUDO, 1,
2351                 ['alloc_file_pseudo' exist])
2352 ])
2353 ]) # LC_ALLOC_FILE_PSEUDO
2354
2355 #
2356 # LC_INODE_TIMESPEC64
2357 #
2358 # kernel 4.17-rc7 commit 8efd6894ff089adeeac7cb9f32125b85d963d1bc
2359 # fs: add timespec64_truncate()
2360 # kernel 4.18 commit 95582b00838837fc07e042979320caf917ce3fe6
2361 # inode timestamps switched to timespec64
2362 # kernel 4.19-rc2 commit 976516404ff3fab2a8caa8bd6f5efc1437fed0b8
2363 # y2038: remove unused time interfaces
2364 # ...
2365 #  timespec_trunc
2366 # ...
2367 # When inode times are timespec64 stop using the deprecated
2368 # time interfaces.
2369 #
2370 # kernel v5.5-rc1-6-gba70609d5ec6 ba70609d5ec664a8f36ba1c857fcd97a478adf79
2371 # fs: Delete timespec64_trunc()
2372 #
2373 AC_DEFUN([LC_INODE_TIMESPEC64], [
2374 tmp_flags="$EXTRA_KCFLAGS"
2375 EXTRA_KCFLAGS="-Werror"
2376 LB_CHECK_COMPILE([if inode timestamps are struct timespec64],
2377 inode_timespec64, [
2378         #include <linux/fs.h>
2379 ],[
2380         struct inode *inode = NULL;
2381         struct timespec64 ts = {0, 1};
2382
2383         inode->i_atime = ts;
2384         (void)inode;
2385 ],[
2386         AC_DEFINE(HAVE_INODE_TIMESPEC64, 1,
2387                 [inode times are using timespec64])
2388 ])
2389 EXTRA_KCFLAGS="$tmp_flags"
2390 ]) # LC_INODE_TIMESPEC64
2391
2392 #
2393 # LC_RADIX_TREE_TAG_SET
2394 #
2395 # kernel 4.20 commit v4.19-rc5-248-g9b89a0355144
2396 # xarray: Add XArray marks - replaced radix_tree_tag_set
2397 #
2398 AC_DEFUN([LC_RADIX_TREE_TAG_SET], [
2399 tmp_flags="$EXTRA_KCFLAGS"
2400 EXTRA_KCFLAGS="-Werror"
2401 LB_CHECK_COMPILE([if 'radix_tree_tag_set' exists],
2402 radix_tree_tag_set, [
2403         #include <linux/fs.h>
2404         #include <linux/radix-tree.h>
2405 ],[
2406         radix_tree_tag_set(NULL, 0, PAGECACHE_TAG_DIRTY);
2407 ],[
2408         AC_DEFINE(HAVE_RADIX_TREE_TAG_SET, 1,
2409                 [radix_tree_tag_set exists])
2410 ])
2411 EXTRA_KCFLAGS="$tmp_flags"
2412 ]) # LC_RADIX_TREE_TAG_SET
2413
2414 #
2415 # LC_UAPI_LINUX_MOUNT_H
2416 #
2417 # kernel 4.20 commit e262e32d6bde0f77fb0c95d977482fc872c51996
2418 # vfs: Suppress MS_* flag defs within the kernel ...
2419 #
2420 AC_DEFUN([LC_UAPI_LINUX_MOUNT_H], [
2421 tmp_flags="$EXTRA_KCFLAGS"
2422 EXTRA_KCFLAGS="-Werror"
2423 LB_CHECK_COMPILE([if MS_RDONLY was moved to uapi/linux/mount.h],
2424 uapi_linux_mount, [
2425         #include <uapi/linux/mount.h>
2426 ],[
2427         int x = MS_RDONLY;
2428         (void)x;
2429 ],[
2430         AC_DEFINE(HAVE_UAPI_LINUX_MOUNT_H, 1,
2431                 [if MS_RDONLY was moved to uapi/linux/mount.h])
2432 ])
2433 EXTRA_KCFLAGS="$tmp_flags"
2434 ]) # LC_UAPI_LINUX_MOUNT_H
2435
2436 #
2437 # LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
2438 #
2439 # kernel 4.20 commit 1863d77f15da0addcd293a1719fa5d3ef8cde3ca
2440 # SUNRPC: Replace the cache_detail->hash_lock with a regular spinlock
2441 #
2442 # Now that the reader functions are all RCU protected, use a regular
2443 # spinlock rather than a reader/writer lock.
2444 #
2445 AC_DEFUN([LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK], [
2446 tmp_flags="$EXTRA_KCFLAGS"
2447 EXTRA_KCFLAGS="-Werror"
2448 LB_CHECK_COMPILE([if cache_detail->hash_lock is a spinlock],
2449 hash_lock_isa_spinlock_t, [
2450         #include <linux/sunrpc/cache.h>
2451 ],[
2452         spinlock_t *lock = &(((struct cache_detail *)0)->hash_lock);
2453         spin_lock(lock);
2454 ],[
2455         AC_DEFINE(HAVE_CACHE_HASH_SPINLOCK, 1,
2456                 [if cache_detail->hash_lock is a spinlock])
2457 ])
2458 EXTRA_KCFLAGS="$tmp_flags"
2459 ]) # LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
2460
2461 #
2462 # LB_HAVE_BVEC_ITER_ALL
2463 #
2464 # kernel 5.1 commit 6dc4f100c175dd0511ae8674786e7c9006cdfbfa
2465 # block: allow bio_for_each_segment_all() to iterate over multi-page bvec
2466 #
2467 AC_DEFUN([LB_HAVE_BVEC_ITER_ALL], [
2468 tmp_flags="$EXTRA_KCFLAGS"
2469 EXTRA_KCFLAGS="-Werror"
2470 LB_CHECK_COMPILE([if bvec_iter_all exists for multi-page bvec iternation],
2471 ext4fs_dirhash, [
2472         #include <linux/bvec.h>
2473 ],[
2474         struct bvec_iter_all iter;
2475         (void)iter;
2476 ],[
2477         AC_DEFINE(HAVE_BVEC_ITER_ALL, 1,
2478                 [if bvec_iter_all exists for multi-page bvec iternation])
2479 ])
2480 EXTRA_KCFLAGS="$tmp_flags"
2481 ]) # LB_HAVE_BVEC_ITER_ALL
2482
2483 #
2484 # LC_ACCOUNT_PAGE_DIRTIED
2485 #
2486 # After 5.2 kernel page dirtied is not exported
2487 #
2488 AC_DEFUN([LC_ACCOUNT_PAGE_DIRTIED], [
2489 LB_CHECK_EXPORT([account_page_dirtied], [mm/page-writeback.c],
2490         [AC_DEFINE(HAVE_ACCOUNT_PAGE_DIRTIED_EXPORT, 1,
2491                         [account_page_dirtied is exported])])
2492 ]) # LC_ACCOUNT_PAGE_DIRTIED
2493
2494 #
2495 # LC_KEYRING_SEARCH_4ARGS
2496 #
2497 # Kernel 5.2 commit dcf49dbc8077
2498 # keys: Add a 'recurse' flag for keyring searches
2499 #
2500 AC_DEFUN([LC_KEYRING_SEARCH_4ARGS], [
2501 LB_CHECK_COMPILE([if 'keyring_search' has 4 args],
2502 keyring_search_4args, [
2503         #include <linux/key.h>
2504 ],[
2505         key_ref_t keyring;
2506         keyring_search(keyring, NULL, NULL, false);
2507 ],[
2508         AC_DEFINE(HAVE_KEYRING_SEARCH_4ARGS, 1,
2509                 [keyring_search has 4 args])
2510 ])
2511 ]) # LC_KEYRING_SEARCH_4ARGS
2512
2513 #
2514 # LC_BIO_BI_PHYS_SEGMENTS
2515 #
2516 # kernel 5.3-rc1 commit 14ccb66b3f585b2bc21e7256c96090abed5a512c
2517 # block: remove the bi_phys_segments field in struct bio
2518 #
2519 AC_DEFUN([LC_BIO_BI_PHYS_SEGMENTS], [
2520 tmp_flags="$EXTRA_KCFLAGS"
2521 EXTRA_KCFLAGS="-Werror"
2522 LB_CHECK_COMPILE([if struct bio has bi_phys_segments member],
2523 bye_bio_bi_phys_segments, [
2524         #include <linux/bio.h>
2525 ],[
2526         struct bio *bio = NULL;
2527         bio->bi_phys_segments++;
2528 ],[
2529         AC_DEFINE(HAVE_BIO_BI_PHYS_SEGMENTS, 1,
2530                 [struct bio has bi_phys_segments member])
2531 ])
2532 EXTRA_KCFLAGS="$tmp_flags"
2533 ]) # LC_BIO_BI_PHYS_SEGMENTS
2534
2535 #
2536 # LC_LM_COMPARE_OWNER_EXISTS
2537 #
2538 # kernel 5.3-rc3 commit f85d93385e9fe6886a751f647f6812a89bf6bee3
2539 # locks: Cleanup lm_compare_owner and lm_owner_key
2540 # removed lm_compare_owner
2541 #
2542 AC_DEFUN([LC_LM_COMPARE_OWNER_EXISTS], [
2543 tmp_flags="$EXTRA_KCFLAGS"
2544 EXTRA_KCFLAGS="-Werror"
2545 LB_CHECK_COMPILE([if lock_manager_operations has lm_compare_owner],
2546 lock_manager_ops_lm_compare_owner, [
2547         #include <linux/fs.h>
2548 ],[
2549         struct lock_manager_operations lm_ops;
2550         lm_ops.lm_compare_owner = NULL;
2551 ],[
2552         AC_DEFINE(HAVE_LM_COMPARE_OWNER, 1,
2553                 [lock_manager_operations has lm_compare_owner])
2554 ])
2555 EXTRA_KCFLAGS="$tmp_flags"
2556 ]) # LC_LM_COMPARE_OWNER_EXISTS
2557
2558 #
2559 # LC_FSCRYPT_SUPPORT
2560 #
2561 # 5.4 introduced fscrypt encryption policies v2
2562 #
2563 AC_DEFUN([LC_FSCRYPT_SUPPORT], [
2564 LB_CHECK_COMPILE([for fscrypt in-kernel support],
2565 fscrypt_support, [
2566         #define __FS_HAS_ENCRYPTION 0
2567         #include <linux/fscrypt.h>
2568 ],[
2569         fscrypt_ioctl_get_policy_ex(NULL, NULL);
2570 ],[
2571         has_fscrypt_support="yes"
2572 ])
2573 ]) # LC_FSCRYPT_SUPPORT
2574
2575 #
2576 # LC_FSCRYPT_DIGESTED_NAME
2577 #
2578 # Kernel 5.5-rc4 edc440e3d27fb31e6f9663cf413fad97d714c060
2579 # improved the format of no-key names. This results in the
2580 # removal of FSCRYPT_FNAME_DIGEST and FSCRYPT_FNAME_DIGEST_SIZE.
2581 #
2582 AC_DEFUN([LC_FSCRYPT_DIGESTED_NAME], [
2583 tmp_flags="$EXTRA_KCFLAGS"
2584 EXTRA_KCFLAGS="-Werror"
2585 LB_CHECK_COMPILE([if fscrypt has 'struct fscrypt_digested_name'],
2586 fscrypt_digested_name, [
2587         #include <linux/fscrypt.h>
2588 ],[
2589         struct fscrypt_digested_name fname;
2590
2591         fname.hash = 0;
2592 ],[
2593         AC_DEFINE(HAVE_FSCRYPT_DIGESTED_NAME, 1,
2594                 ['struct fscrypt_digested_name' exists])
2595 ])
2596 EXTRA_KCFLAGS="$tmp_flags"
2597 ]) # LC_FSCRYPT_DIGESTED_NAME
2598
2599 #
2600 # LC_FSCRYPT_DUMMY_CONTEXT_ENABLED
2601 #
2602 # Kernel 5.7-rc7 ed318a6cc0b620440e65f48eb527dc3df7269ce4
2603 # replaces fscrypt_dummy_context_enabled() with
2604 # fscrypt_get_dummy_context(). Later kernels rename
2605 # fscrypt_get_dummy_context() to fscrypt_get_dummy_policy()
2606 # which is why we test fscrypt_dummy_context_enabled().
2607 #
2608 AC_DEFUN([LC_FSCRYPT_DUMMY_CONTEXT_ENABLED], [
2609 tmp_flags="$EXTRA_KCFLAGS"
2610 EXTRA_KCFLAGS="-Werror"
2611 LB_CHECK_COMPILE([if fscrypt_dummy_context_enabled() exists],
2612 fscrypt_dummy_context_enabled, [
2613         #include <linux/fscrypt.h>
2614 ],[
2615         fscrypt_dummy_context_enabled(NULL);
2616 ],[
2617         AC_DEFINE(HAVE_FSCRYPT_DUMMY_CONTEXT_ENABLED, 1,
2618                 [fscrypt_dummy_context_enabled() exists])
2619 ])
2620 EXTRA_KCFLAGS="$tmp_flags"
2621 ]) # LC_FSCRYPT_DUMMY_CONTEXT_ENABLED
2622
2623 #
2624 # LC_HAVE_ITER_FILE_SPLICE_WRITE
2625 #
2626 # Linux commit v5.9-rc1-6-g36e2c7421f02
2627 #  fs: don't allow splice read/write without explicit ops
2628 #
2629 AC_DEFUN([LC_HAVE_ITER_FILE_SPLICE_WRITE], [
2630 tmp_flags="$EXTRA_KCFLAGS"
2631 EXTRA_KCFLAGS="-Werror"
2632 LB_CHECK_COMPILE([if 'iter_file_splice_write' exists],
2633 iter_file_splice_write, [
2634         #include <linux/fs.h>
2635 ],[
2636         (void)iter_file_splice_write(NULL, NULL, NULL, 1, 0);
2637 ],[
2638         AC_DEFINE(HAVE_ITER_FILE_SPLICE_WRITE, 1,
2639                 ['iter_file_splice_write' exists])
2640 ])
2641 EXTRA_KCFLAGS="$tmp_flags"
2642 ]) # LC_HAVE_ITER_FILE_SPLICE_WRITE
2643
2644 #
2645 # LC_FSCRYPT_IS_NOKEY_NAME
2646 #
2647 # Kernel 5.10-rc4 159e1de201b6fca10bfec50405a3b53a561096a8
2648 # introduced fscrypt_is_nokey_name() inline macro. While
2649 # introduced for 5.10 kernels it was backported to earlier
2650 # Ubuntu kernels. Also it hides the change introduced due
2651 # to git commit 501e43fbe for kernel 5.9 which also was
2652 # backported to earlier Ubuntu kernels.
2653 #
2654 AC_DEFUN([LC_FSCRYPT_IS_NOKEY_NAME], [
2655 tmp_flags="$EXTRA_KCFLAGS"
2656 EXTRA_KCFLAGS="-Werror"
2657 LB_CHECK_COMPILE([if fscrypt_is_nokey_name() exists],
2658 fscrypt_is_no_key_name, [
2659         #include <linux/fscrypt.h>
2660 ],[
2661         fscrypt_is_nokey_name(NULL);
2662 ],[
2663         AC_DEFINE(HAVE_FSCRYPT_IS_NOKEY_NAME, 1,
2664                 [fscrypt_is_nokey_name() exists])
2665 ])
2666 EXTRA_KCFLAGS="$tmp_flags"
2667 ]) # LC_FSCRYPT_IS_NOKEY_NAME
2668
2669 #
2670 # LC_BIO_SET_DEV
2671 #
2672 # Linux: v5.11-rc5-9-g309dca309fc3
2673 #   block: store a block_device pointer in struct bio
2674 # created bio_set_dev macro
2675 # Linux: v5.15-rc6-127-gcf6d6238cdd3
2676 #   block: turn macro helpers into inline functions
2677 # created inline function(s).
2678 #
2679 # Only provide a bio_set_dev it is is not proveded by the kernel
2680 #
2681 AC_DEFUN([LC_BIO_SET_DEV], [
2682 tmp_flags="$EXTRA_KCFLAGS"
2683 EXTRA_KCFLAGS="-Werror"
2684         LB_CHECK_COMPILE([if 'bio_set_dev' is available],
2685         [bio_set_dev], [
2686                 #include <linux/bio.h>
2687         ],[
2688                 struct bio *bio = NULL;
2689                 struct block_device *bdev = NULL;
2690
2691                 bio_set_dev(bio, bdev);
2692         ],[
2693                 AC_DEFINE(HAVE_BIO_SET_DEV, 1, ['bio_set_dev' is available])
2694         ])
2695 EXTRA_KCFLAGS="$tmp_flags"
2696 ]) # LC_BIO_SET_DEV
2697
2698 #
2699 # LC_HAVE_USER_NAMESPACE_ARG
2700 #
2701 # kernel 5.12 commit 549c7297717c32ee53f156cd949e055e601f67bb
2702 # fs: make helpers idmap mount aware
2703 # Extend some inode methods with an additional user namespace argument.
2704 #
2705 AC_DEFUN([LC_HAVE_USER_NAMESPACE_ARG], [
2706 tmp_flags="$EXTRA_KCFLAGS"
2707 EXTRA_KCFLAGS="-Werror"
2708 LB_CHECK_COMPILE([if 'inode_operations' members have user namespace argument],
2709 user_namespace_argument, [
2710         #include <linux/fs.h>
2711 ],[
2712         ((struct inode_operations *)1)->getattr((struct user_namespace *)NULL,
2713                                                 NULL, NULL, 0, 0);
2714 ],[
2715         AC_DEFINE(HAVE_USER_NAMESPACE_ARG, 1,
2716                 ['inode_operations' members have user namespace argument])
2717 ])
2718 EXTRA_KCFLAGS="$tmp_flags"
2719 ]) # LC_HAVE_USER_NAMESPACE_ARG
2720
2721 #
2722 # LC_HAVE_GET_ACL_RCU_ARG
2723 #
2724 # kernel 5.15 commit 0cad6246621b5887d5b33fea84219d2a71f2f99a
2725 # vfs: add rcu argument to ->get_acl() callback
2726 # Add a rcu argument to the ->get_acl() callback to allow
2727 # get_cached_acl_rcu() to call the ->get_acl() method.
2728 #
2729 AC_DEFUN([LC_HAVE_GET_ACL_RCU_ARG], [
2730 tmp_flags="$EXTRA_KCFLAGS"
2731 EXTRA_KCFLAGS="-Werror"
2732 LB_CHECK_COMPILE([if 'get_acl' has a rcu argument],
2733 get_acl_rcu_argument, [
2734         #include <linux/fs.h>
2735 ],[
2736         ((struct inode_operations *)1)->get_acl((struct inode *)NULL, 0, false);
2737 ],[
2738         AC_DEFINE(HAVE_GET_ACL_RCU_ARG, 1,
2739                 ['get_acl' has a rcu argument])
2740 ])
2741 EXTRA_KCFLAGS="$tmp_flags"
2742 ]) # LC_HAVE_GET_ACL_RCU_ARG
2743
2744 #
2745 # LC_HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG
2746 #
2747 # Linux v5.15-rc1-20-g15bf32398ad4
2748 # security: Return xattr name from security_dentry_init_security()
2749 #
2750 AC_DEFUN([LC_HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG], [
2751 tmp_flags="$EXTRA_KCFLAGS"
2752 EXTRA_KCFLAGS="-Werror"
2753 LB_CHECK_COMPILE([if security_dentry_init_security() returns xattr name],
2754 security_dentry_init_security_xattr_name_arg, [
2755         #include <linux/security.h>
2756 ],[
2757         struct dentry *dentry = NULL;
2758         int mode = 0;
2759         const struct qstr *name = NULL;
2760         const char *xattr_name = NULL;
2761         void **ctx = NULL;
2762         u32 *ctxlen = 0;
2763         int rc = security_dentry_init_security(dentry, mode, name, &xattr_name,
2764                                                ctx, ctxlen);
2765         (void)rc;
2766
2767 ],[
2768         AC_DEFINE(HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG, 1,
2769                 [security_dentry_init_security() returns xattr name])
2770 ])
2771 EXTRA_KCFLAGS="$tmp_flags"
2772 ]) # LC_HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG
2773
2774 #
2775 # LC_HAVE_KIOCB_COMPLETE_2ARGS
2776 #
2777 # kernel v5.15-rc6-145-g6b19b766e8f0
2778 # fs: get rid of the res2 iocb->ki_complete argument
2779 #
2780 AC_DEFUN([LC_HAVE_KIOCB_COMPLETE_2ARGS], [
2781 tmp_flags="$EXTRA_KCFLAGS"
2782 EXTRA_KCFLAGS="-Werror"
2783 LB_CHECK_COMPILE([if kiocb->ki_complete() has 2 arguments],
2784 kiocb_ki_complete_2args, [
2785         #include <linux/fs.h>
2786
2787         static void complete_fn(struct kiocb *iocb, long ret)
2788         {
2789                 (void)iocb;
2790                 (void)ret;
2791         }
2792 ],[
2793         struct kiocb *kio = NULL;
2794
2795         kio->ki_complete = complete_fn;
2796 ],[
2797         AC_DEFINE(HAVE_KIOCB_COMPLETE_2ARGS, 1,
2798                 [kiocb->ki_complete() has 2 arguments])
2799 ])
2800 EXTRA_KCFLAGS="$tmp_flags"
2801 ]) # LC_HAVE_KIOCB_COMPLETE_2ARGS
2802
2803 #
2804 # LC_HAVE_INVALIDATE_FOLIO
2805 #
2806 # linux commit v5.17-rc4-10-g128d1f8241d6
2807 # fs: Add invalidate_folio() aops method
2808 #
2809 AC_DEFUN([LC_HAVE_INVALIDATE_FOLIO], [
2810 tmp_flags="$EXTRA_KCFLAGS"
2811 EXTRA_KCFLAGS="-Werror"
2812 LB_CHECK_COMPILE([if have address_spaace_operaions->invalidate_folio() member],
2813 address_spaace_operaions_invalidate_folio, [
2814                 #include <linux/fs.h>
2815         ],[
2816                 struct address_space_operations *aops = NULL;
2817                 struct folio *folio = NULL;
2818                 aops->invalidate_folio(folio, 0, PAGE_SIZE);
2819         ],[
2820                 AC_DEFINE(HAVE_INVALIDATE_FOLIO, 1,
2821                         [address_spaace_operaions->invalidate_folio() member exists])
2822         ])
2823 EXTRA_KCFLAGS="$tmp_flags"
2824 ]) # LC_HAVE_INVALIDATE_FOLIO
2825
2826 #
2827 # LC_HAVE_DIRTY_FOLIO
2828 #
2829 # linux commit v5.17-rc4-38-g6f31a5a261db
2830 # fs: Add aops->dirty_folio
2831 # ... replaces ->set_page_dirty() with ->dirty_folio()
2832 #
2833 AC_DEFUN([LC_HAVE_DIRTY_FOLIO], [
2834 tmp_flags="$EXTRA_KCFLAGS"
2835 EXTRA_KCFLAGS="-Werror"
2836 LB_CHECK_COMPILE([if have address_spaace_operaions->dirty_folio() member],
2837 address_spaace_operaions_dirty_folio, [
2838                 #include <linux/fs.h>
2839         ],[
2840                 struct address_space_operations *aops = NULL;
2841                 struct address_space *mapping = NULL;
2842                 struct folio *folio = NULL;
2843                 bool dirty = aops->dirty_folio(mapping, folio);
2844                 (void) dirty;
2845         ],[
2846                 AC_DEFINE(HAVE_DIRTY_FOLIO, 1,
2847                         [address_spaace_operaions->dirty_folio() member exists])
2848         ])
2849 EXTRA_KCFLAGS="$tmp_flags"
2850 ]) # LC_HAVE_DIRTY_FOLIO
2851
2852 #
2853 # LC_HAVE_ALLOC_INODE_SB
2854 #
2855 # linux commit v5.17-49-g8b9f3ac5b01d
2856 #   fs: introduce alloc_inode_sb() to allocate filesystems specific inode
2857 #
2858 AC_DEFUN([LC_HAVE_ALLOC_INODE_SB], [
2859 tmp_flags="$EXTRA_KCFLAGS"
2860 EXTRA_KCFLAGS="-Werror"
2861 LB_CHECK_COMPILE([if alloc_inode_sb() exists],
2862 alloc_inode_sb, [
2863                 #include <linux/fs.h>
2864         ],[
2865                 struct super_block *sb = NULL;
2866                 struct kmem_cache *cache = NULL;
2867
2868                 (void)alloc_inode_sb(sb, cache, GFP_NOFS);
2869         ],[
2870                 AC_DEFINE(HAVE_ALLOC_INODE_SB, 1,
2871                         [alloc_inode_sb() exists])
2872         ])
2873 EXTRA_KCFLAGS="$tmp_flags"
2874 ]) # LC_HAVE_ALLOC_INODE_SB
2875
2876 AC_DEFUN([LC_PROG_LINUX_SRC], [])
2877 AC_DEFUN([LC_PROG_LINUX_RESULTS], [])
2878
2879 #
2880 # LC_PROG_LINUX
2881 #
2882 # Lustre linux kernel checks
2883 #
2884 AC_DEFUN([LC_PROG_LINUX], [
2885         AC_MSG_NOTICE([Lustre kernel checks
2886 ==============================================================================])
2887
2888         LC_CONFIG_PINGER
2889         LC_CONFIG_CHECKSUM
2890         LC_CONFIG_FLOCK
2891         LC_CONFIG_HEALTH_CHECK_WRITE
2892         LC_CONFIG_LRU_RESIZE
2893         LC_CONFIG_FHANDLE
2894         LC_CONFIG_GSS
2895
2896         # 3.10
2897         LC_HAVE_PROJECT_QUOTA
2898
2899         # 3.11
2900         LC_INVALIDATE_RANGE
2901         LC_HAVE_DIR_CONTEXT
2902         LC_D_COMPARE_5ARGS
2903         LC_HAVE_DCOUNT
2904         LC_HAVE_DENTRY_D_U_D_ALIAS
2905         LC_HAVE_DENTRY_D_CHILD
2906         LC_PID_NS_FOR_CHILDREN
2907
2908         # 3.12
2909         LC_OLDSIZE_TRUNCATE_PAGECACHE
2910         LC_PTR_ERR_OR_ZERO_MISSING
2911         LC_KIOCB_KI_LEFT
2912         LC_REGISTER_SHRINKER_RET
2913
2914         # 3.13
2915         LC_VFS_RENAME_5ARGS
2916         LC_VFS_UNLINK_3ARGS
2917         LC_HAVE_D_IS_POSITIVE
2918
2919         # 3.14
2920         LC_HAVE_BVEC_ITER
2921         LC_HAVE_TRUNCATE_IPAGES_FINAL
2922         LC_IOPS_RENAME_WITH_FLAGS
2923         LC_IOP_SET_ACL
2924
2925         # 3.15
2926         LC_VFS_RENAME_6ARGS
2927
2928         # 3.16
2929         LC_DIRECTIO_USE_ITER
2930         LC_HAVE_IOV_ITER_INIT_DIRECTION
2931         LC_HAVE_IOV_ITER_TRUNCATE
2932         LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
2933
2934         # 3.17
2935         LC_HAVE_INTERVAL_BLK_INTEGRITY
2936         LC_KEY_MATCH_DATA
2937         LC_HAVE_BLK_INTEGRITY_ITER
2938
2939         # 3.18
2940         LC_PERCPU_COUNTER_INIT
2941         LC_NFS_FILLDIR_USE_CTX
2942
2943         # 3.19
2944         LC_KIOCB_HAS_NBYTES
2945         LC_HAVE_DQUOT_QC_DQBLK
2946         LC_HAVE_AIO_COMPLETE
2947         LC_HAVE_IS_ROOT_INODE
2948
2949         # 3.20
2950         LC_BACKING_DEV_INFO_REMOVAL
2951         LC_HAVE_BDI_CAP_MAP_COPY
2952
2953         # 4.1.0
2954         LC_IOV_ITER_RW
2955         LC_HAVE_SYNC_READ_WRITE
2956         LC_HAVE___BI_CNT
2957
2958         # 4.2
2959         LC_BIO_ENDIO_USES_ONE_ARG
2960         LC_SYMLINK_OPS_USE_NAMEIDATA
2961         LC_ACCOUNT_PAGE_DIRTIED_3ARGS
2962         LC_HAVE_CRYPTO_ALLOC_SKCIPHER
2963
2964         # 4.3
2965         LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
2966         LC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD
2967         LC_HAVE_CACHE_HEAD_HLIST
2968         LC_HAVE_XATTR_HANDLER_SIMPLIFIED
2969
2970         # 4.4
2971         LC_HAVE_LOCKS_LOCK_FILE_WAIT
2972         LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
2973         LC_HAVE_XATTR_HANDLER_NAME
2974         LC_HAVE_BI_OPF
2975         LC_HAVE_SUBMIT_BIO_2ARGS
2976         LC_HAVE_CLEAN_BDEV_ALIASES
2977
2978         # 4.5
2979         LC_HAVE_FILE_DENTRY
2980
2981         # 4.5
2982         LC_HAVE_INODE_LOCK
2983         LC_HAVE_IOP_GET_LINK
2984
2985         # 4.6
2986         LC_HAVE_IN_COMPAT_SYSCALL
2987         LC_HAVE_XATTR_HANDLER_INODE_PARAM
2988         LC_LOCK_PAGE_MEMCG
2989         LC_HAVE_DOWN_WRITE_KILLABLE
2990
2991         # 4.7
2992         LC_D_IN_LOOKUP
2993         LC_D_INIT
2994         LC_DIRECTIO_2ARGS
2995         LC_GENERIC_WRITE_SYNC_2ARGS
2996         LC_FOP_ITERATE_SHARED
2997
2998         # 4.8
2999         LC_EXPORT_DEFAULT_FILE_SPLICE_READ
3000         LC_HAVE_POSIX_ACL_VALID_USER_NS
3001         LC_D_COMPARE_4ARGS
3002         LC_FULL_NAME_HASH_3ARGS
3003         LC_STRUCT_POSIX_ACL_XATTR
3004         LC_IOP_XATTR
3005
3006         # 4.9
3007         LC_GROUP_INFO_GID
3008         LC_VFS_SETXATTR
3009         LC_POSIX_ACL_UPDATE_MODE
3010         LC_HAVE_BDI_IO_PAGES
3011
3012         # 4.10
3013         LC_IOP_GENERIC_READLINK
3014         LC_HAVE_VM_FAULT_ADDRESS
3015
3016         # 4.11
3017         LC_INODEOPS_ENHANCED_GETATTR
3018         LC_VM_OPERATIONS_REMOVE_VMF_ARG
3019         LC_HAVE_KEY_USAGE_REFCOUNT
3020         LC_HAVE_CRYPTO_MAX_ALG_NAME_128
3021
3022         # 4.12
3023         LC_CURRENT_TIME
3024         LC_SUPER_BLOCK_S_UUID
3025         LC_SUPER_SETUP_BDI_NAME
3026         LC_BI_STATUS
3027
3028         # 4.13
3029         LC_BIO_INTEGRITY_ENABLED
3030         LC_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL
3031         LC_HAVE_GET_INODE_USAGE
3032
3033         # 4.14
3034         LC_PAGEVEC_INIT_ONE_PARAM
3035         LC_BI_BDEV
3036         LC_INTERVAL_TREE_CACHED
3037
3038         # 4.17
3039         LC_VM_FAULT_T
3040         LC_VM_FAULT_RETRY
3041         LC_I_PAGES
3042
3043         # 4.18
3044         LC_ALLOC_FILE_PSEUDO
3045         LC_INODE_TIMESPEC64
3046
3047         # 4.20
3048         LC_RADIX_TREE_TAG_SET
3049         LC_UAPI_LINUX_MOUNT_H
3050         LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
3051
3052         # 5.1
3053         LB_HAVE_BVEC_ITER_ALL
3054
3055         # 5.2
3056         LC_ACCOUNT_PAGE_DIRTIED
3057         LC_KEYRING_SEARCH_4ARGS
3058
3059         # 5.3
3060         LC_BIO_BI_PHYS_SEGMENTS
3061         LC_LM_COMPARE_OWNER_EXISTS
3062
3063         # 5.5
3064         LC_FSCRYPT_DIGESTED_NAME
3065
3066         # 5.7
3067         LC_FSCRYPT_DUMMY_CONTEXT_ENABLED
3068
3069         # 5.9
3070         LC_HAVE_ITER_FILE_SPLICE_WRITE
3071
3072         # 5.10
3073         LC_FSCRYPT_IS_NOKEY_NAME
3074
3075         # 5.11
3076         LC_BIO_SET_DEV
3077
3078         # 5.12
3079         LC_HAVE_USER_NAMESPACE_ARG
3080
3081         # 5.15
3082         LC_HAVE_GET_ACL_RCU_ARG
3083
3084         # 5.16
3085         LC_HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG
3086         LC_HAVE_KIOCB_COMPLETE_2ARGS
3087
3088         # 5.17
3089         LC_HAVE_INVALIDATE_FOLIO
3090         LC_HAVE_DIRTY_FOLIO
3091
3092         # 5.18
3093         LC_HAVE_ALLOC_INODE_SB
3094
3095         # kernel patch to extend integrity interface
3096         LC_BIO_INTEGRITY_PREP_FN
3097
3098         #
3099         AS_IF([test "x$enable_server" != xno], [
3100                 LC_STACK_SIZE
3101                 LC_QUOTA_CONFIG
3102         ])
3103         LC_POSIX_ACL_CONFIG
3104 ]) # LC_PROG_LINUX
3105
3106 #
3107 # LC_CONFIG_CLIENT
3108 #
3109 # Check whether to build the client side of Lustre
3110 #
3111 AC_DEFUN([LC_CONFIG_CLIENT], [
3112 AC_MSG_CHECKING([whether to build Lustre client support])
3113 AC_ARG_ENABLE([client],
3114         AS_HELP_STRING([--disable-client],
3115                 [disable Lustre client support]),
3116         [], [enable_client="yes"])
3117 AC_MSG_RESULT([$enable_client])
3118 ]) # LC_CONFIG_CLIENT
3119
3120 #
3121 # --enable-mpitests
3122 #
3123 AC_DEFUN([LB_CONFIG_MPITESTS], [
3124 AC_ARG_ENABLE([mpitests],
3125         AS_HELP_STRING([--enable-mpitests=<yes|no|mpicc wrapper>],
3126                        [include mpi tests]), [
3127                 enable_mpitests="yes"
3128                 case $enableval in
3129                 yes)
3130                         MPICC_WRAPPER="mpicc"
3131                         MPI_BIN=$(eval which $MPICC_WRAPPER | xargs dirname)
3132                         ;;
3133                 no)
3134                         enable_mpitests="no"
3135                         MPI_BIN=""
3136                         ;;
3137                 *)
3138                         MPICC_WRAPPER=$enableval
3139                         MPI_BIN=$(eval echo $MPICC_WRAPPER | xargs dirname)
3140                         ;;
3141                 esac
3142         ], [
3143                 enable_mpitests="yes"
3144                 MPICC_WRAPPER="mpicc"
3145                 MPI_BIN=$(eval which $MPICC_WRAPPER | xargs dirname)
3146         ])
3147
3148         if test "x$enable_mpitests" != "xno"; then
3149                 oldcc=$CC
3150                 CC=$MPICC_WRAPPER
3151                 AC_CACHE_CHECK([whether mpitests can be built],
3152                 lb_cv_mpi_tests, [AC_COMPILE_IFELSE([AC_LANG_SOURCE([
3153                         #include <mpi.h>
3154                         int main(void) {
3155                                 int flag;
3156                                 MPI_Initialized(&flag);
3157                                 return 0;
3158                         }
3159                 ])], [lb_cv_mpi_tests="yes"], [lb_cv_mpi_tests="no"])
3160                 ])
3161                 enable_mpitests=$lb_cv_mpi_tests
3162                 CC=$oldcc
3163         fi
3164         AC_SUBST(MPI_BIN)
3165         AC_SUBST(MPICC_WRAPPER)
3166 ]) # LB_CONFIG_MPITESTS
3167
3168 #
3169 # LC_CONFIG_QUOTA
3170 #
3171 # whether to enable quota support global control
3172 #
3173 AC_DEFUN([LC_CONFIG_QUOTA], [
3174 AC_MSG_CHECKING([whether to enable quota support global control])
3175 AC_ARG_ENABLE([quota],
3176         AS_HELP_STRING([--enable-quota],
3177                 [enable quota support]),
3178         [], [enable_quota="yes"])
3179 AS_IF([test "x$enable_quota" = xyes],
3180         [AC_MSG_RESULT([yes])],
3181         [AC_MSG_RESULT([no])])
3182 ]) # LC_CONFIG_QUOTA
3183
3184 #
3185 # LC_QUOTA
3186 #
3187 AC_DEFUN([LC_QUOTA], [
3188 #check global
3189 LC_CONFIG_QUOTA
3190 #check for utils
3191 AS_IF([test "x$enable_quota" != xno -a "x$enable_utils" != xno], [
3192         AC_CHECK_HEADER([sys/quota.h],
3193                 [AC_DEFINE(HAVE_SYS_QUOTA_H, 1,
3194                         [Define to 1 if you have <sys/quota.h>.])],
3195                 [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
3196 ])
3197 ]) # LC_QUOTA
3198
3199 #
3200 # LC_OSD_ADDON
3201 #
3202 # configure support for optional OSD implementation
3203 #
3204 AC_DEFUN([LC_OSD_ADDON], [
3205 AC_MSG_CHECKING([whether to use OSD addon])
3206 AC_ARG_WITH([osd],
3207         AS_HELP_STRING([--with-osd=path],
3208                 [set path to optional osd]),
3209         [
3210         case "$with_osd" in
3211         no)
3212                 ENABLEOSDADDON=0
3213                 ;;
3214         *)
3215                 OSDADDON="$with_osd"
3216                 ENABLEOSDADDON=1
3217                 ;;
3218         esac
3219         ], [
3220                 ENABLEOSDADDON=0
3221         ])
3222 AS_IF([test $ENABLEOSDADDON -eq 0], [
3223         AC_MSG_RESULT([no])
3224         OSDADDON=""
3225 ], [
3226         OSDMODNAME=$(basename $OSDADDON)
3227         AS_IF([test -e $LUSTRE/$OSDMODNAME], [
3228                 AC_MSG_RESULT([can't link])
3229                 OSDADDON=""
3230         ], [ln -s $OSDADDON $LUSTRE/$OSDMODNAME], [
3231                 AC_MSG_RESULT([$OSDMODNAME])
3232                 OSDADDON="obj-m += $OSDMODNAME/"
3233         ], [
3234                 AC_MSG_RESULT([can't link])
3235                 OSDADDON=""
3236         ])
3237 ])
3238 AC_SUBST(OSDADDON)
3239 ]) # LC_OSD_ADDON
3240
3241 #
3242 # LC_CONFIG_CRYPTO
3243 #
3244 # Check whether to enable Lustre client crypto
3245 #
3246 AC_DEFUN([LC_CONFIG_CRYPTO], [
3247 AC_MSG_CHECKING([whether to enable Lustre client crypto])
3248 AC_ARG_ENABLE([crypto],
3249         AS_HELP_STRING([--enable-crypto=yes|no|in-kernel],
3250                 [enable Lustre client crypto (default is yes), use 'in-kernel' to force use of in-kernel fscrypt instead of embedded llcrypt]),
3251         [], [enable_crypto="auto"])
3252 AS_IF([test "x$enable_crypto" != xno -a "x$enable_dist" = xno], [
3253         AC_MSG_RESULT(
3254         )
3255         LC_IS_ENCRYPTED
3256         LC_FSCRYPT_SUPPORT])
3257 AS_IF([test "x$enable_crypto" = xin-kernel], [
3258         AS_IF([test "x$has_fscrypt_support" = xyes], [
3259               AC_DEFINE(HAVE_LUSTRE_CRYPTO, 1, [Enable Lustre client crypto via in-kernel fscrypt])], [
3260               AC_MSG_ERROR([Lustre client crypto cannot be enabled via in-kernel fscrypt.])
3261               enable_crypto=no])],
3262         [AS_IF([test "x$has_is_encrypted" = xyes], [
3263               AC_DEFINE(HAVE_LUSTRE_CRYPTO, 1, [Enable Lustre client crypto via embedded llcrypt])
3264               AC_DEFINE(CONFIG_LL_ENCRYPTION, 1, [embedded llcrypt])
3265               AC_DEFINE(HAVE_FSCRYPT_DUMMY_CONTEXT_ENABLED, 1, [embedded llcrypt uses llcrypt_dummy_context_enabled()])
3266               enable_crypto="embedded-llcrypt"
3267               enable_llcrypt=yes], [
3268               AS_IF([test "x$enable_crypto" = xyes],
3269                     [AC_MSG_ERROR([Lustre client crypto cannot be enabled because of lack of encryption support in your kernel.])])
3270               AS_IF([test "x$enable_crypto" != xno -a "x$enable_dist" = xno],
3271                     [AC_MSG_WARN(Lustre client crypto cannot be enabled because of lack of encryption support in your kernel.)])
3272               enable_crypto=no])])
3273 AS_IF([test "x$enable_dist" != xno], [
3274         enable_crypto=yes
3275         enable_llcrypt=yes])
3276 AC_MSG_RESULT([$enable_crypto])
3277 ]) # LC_CONFIG_CRYPTO
3278
3279 #
3280 # LC_CONFIGURE
3281 #
3282 # other configure checks
3283 #
3284 AC_DEFUN([LC_CONFIGURE], [
3285 AC_MSG_NOTICE([Lustre core checks
3286 ==============================================================================])
3287
3288 AS_IF([test $target_cpu == "i686" -o $target_cpu == "x86_64"],
3289         [CFLAGS="$CFLAGS -Wall -Werror"])
3290
3291 # maximum MDS thread count
3292 LC_MDS_MAX_THREADS
3293
3294 # lustre/utils/gss/gss_util.c
3295 # lustre/utils/gss/gssd_proc.c
3296 # lustre/utils/gss/krb5_util.c
3297 # lustre/utils/llog_reader.c
3298 # lustre/utils/create_iam.c
3299 # lustre/utils/libiam.c
3300 AC_CHECK_HEADERS([netdb.h endian.h])
3301 AC_CHECK_FUNCS([gethostbyname])
3302
3303 # lustre/utils/llverfs.c lustre/utils/libmount_utils_ldiskfs.c
3304 AC_CHECK_HEADERS([ext2fs/ext2fs.h], [], [
3305         AS_IF([test "x$enable_utils" = xyes -a "x$enable_ldiskfs" = xyes], [
3306                 AC_MSG_ERROR([
3307 ext2fs.h not found. Please install e2fsprogs development package.
3308                 ])
3309         ])
3310 ])
3311
3312 # lustre/tests/statx_test.c
3313 AC_CHECK_FUNCS([statx])
3314
3315 # lustre/utils/lfs.c
3316 AS_IF([test "$enable_dist" = "no"], [
3317                 AC_CHECK_LIB([z], [crc32], [
3318                                  AC_CHECK_HEADER([zlib.h], [], [
3319                                                  AC_MSG_ERROR([zlib.h not found.])])
3320                                  ], [
3321                                  AC_MSG_ERROR([
3322                 zlib library not found. Please install zlib development package.])
3323                 ])
3324 ])
3325
3326 SELINUX=""
3327
3328 AC_CHECK_LIB([selinux], [is_selinux_enabled],
3329         [AC_CHECK_HEADERS([selinux/selinux.h],
3330                         [SELINUX="-lselinux"
3331                         AC_DEFINE([HAVE_SELINUX], 1,
3332                                 [support for selinux ])],
3333                         [AC_MSG_WARN([
3334
3335 No libselinux-devel package found, unable to build selinux enabled tools
3336 ])
3337 ])],
3338         [AC_MSG_WARN([
3339
3340 No selinux package found, unable to build selinux enabled tools
3341 ])
3342 ])
3343 AC_SUBST(SELINUX)
3344
3345 AC_CHECK_LIB([keyutils], [add_key])
3346
3347 # Super safe df
3348 AC_MSG_CHECKING([whether to report minimum OST free space])
3349 AC_ARG_ENABLE([mindf],
3350         AS_HELP_STRING([--enable-mindf],
3351                 [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
3352         [], [enable_mindf="no"])
3353 AC_MSG_RESULT([$enable_mindf])
3354 AS_IF([test "$enable_mindf" = "yes"],
3355         [AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])])
3356
3357 AC_MSG_CHECKING([whether to randomly failing memory alloc])
3358 AC_ARG_ENABLE([fail_alloc],
3359         AS_HELP_STRING([--disable-fail-alloc],
3360                 [disable randomly alloc failure]),
3361         [], [enable_fail_alloc="yes"])
3362 AC_MSG_RESULT([$enable_fail_alloc])
3363 AS_IF([test "x$enable_fail_alloc" != xno],
3364         [AC_DEFINE([RANDOM_FAIL_ALLOC], 1,
3365                 [enable randomly alloc failure])])
3366
3367 AC_MSG_CHECKING([whether to check invariants (expensive cpu-wise)])
3368 AC_ARG_ENABLE([invariants],
3369         AS_HELP_STRING([--enable-invariants],
3370                 [enable invariant checking (cpu intensive)]),
3371         [], [enable_invariants="no"])
3372 AC_MSG_RESULT([$enable_invariants])
3373 AS_IF([test "x$enable_invariants" = xyes],
3374         [AC_DEFINE([CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK], 1,
3375                 [enable invariant checking])])
3376
3377 AC_MSG_CHECKING([whether to track references with lu_ref])
3378 AC_ARG_ENABLE([lu_ref],
3379         AS_HELP_STRING([--enable-lu_ref],
3380                 [enable lu_ref reference tracking code]),
3381         [], [enable_lu_ref="no"])
3382 AC_MSG_RESULT([$enable_lu_ref])
3383 AS_IF([test "x$enable_lu_ref" = xyes],
3384         [AC_DEFINE([CONFIG_LUSTRE_DEBUG_LU_REF], 1,
3385                 [enable lu_ref reference tracking code])])
3386
3387 AC_MSG_CHECKING([whether to enable page state tracking])
3388 AC_ARG_ENABLE([pgstate-track],
3389         AS_HELP_STRING([--enable-pgstate-track],
3390                 [enable page state tracking]),
3391         [], [enable_pgstat_track="no"])
3392 AC_MSG_RESULT([$enable_pgstat_track])
3393 AS_IF([test "x$enable_pgstat_track" = xyes],
3394         [AC_DEFINE([CONFIG_DEBUG_PAGESTATE_TRACKING], 1,
3395                 [enable page state tracking code])])
3396
3397 PKG_PROG_PKG_CONFIG
3398 AC_MSG_CHECKING([systemd unit file directory])
3399 AC_ARG_WITH([systemdsystemunitdir],
3400         [AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
3401                 [Directory for systemd service files])],
3402         [], [with_systemdsystemunitdir=auto])
3403 AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"],
3404         [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
3405         AS_IF([test "x$def_systemdsystemunitdir" = "x"],
3406                 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
3407                 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
3408                 with_systemdsystemunitdir=no],
3409         [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
3410 AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
3411         [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
3412 AC_MSG_RESULT([$with_systemdsystemunitdir])
3413
3414 AC_MSG_CHECKING([bash-completion directory])
3415 AC_ARG_WITH([bash-completion-dir],
3416         AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
3417                 [Install the bash auto-completion script in this directory.]),
3418         [],
3419         [with_bash_completion_dir=yes])
3420 AS_IF([test "x$with_bash_completion_dir" = "xyes"], [
3421         BASH_COMPLETION_DIR="`pkg-config --variable=completionsdir bash-completion`"
3422         AS_IF([test "x$BASH_COMPLETION_DIR" = "x"], [
3423                 [BASH_COMPLETION_DIR="/usr/share/bash-completion/completions"]
3424         ])
3425 ], [
3426         BASH_COMPLETION_DIR="$with_bash_completion_dir"
3427 ])
3428 AC_SUBST([BASH_COMPLETION_DIR])
3429 AC_MSG_RESULT([$BASH_COMPLETION_DIR])
3430 ]) # LC_CONFIGURE
3431
3432 #
3433 # LC_CONDITIONALS
3434 #
3435 # AM_CONDITIONALS for lustre
3436 #
3437 AC_DEFUN([LC_CONDITIONALS], [
3438 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
3439 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
3440 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
3441 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
3442 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
3443 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
3444 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
3445 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
3446 AM_CONDITIONAL(GSS_SSK, test x$enable_ssk = xyes)
3447 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
3448 AM_CONDITIONAL(HAVE_SYSTEMD, test "x$with_systemdsystemunitdir" != "xno")
3449 AM_CONDITIONAL(ENABLE_BASH_COMPLETION, test "x$with_bash_completion_dir" != "xno")
3450 AM_CONDITIONAL(XATTR_HANDLER, test "x$lb_cv_compile_xattr_handler_flags" = xyes)
3451 AM_CONDITIONAL(SELINUX, test "$SELINUX" = "-lselinux")
3452 AM_CONDITIONAL(GETSEPOL, test x$enable_getsepol = xyes)
3453 AM_CONDITIONAL(LLCRYPT, test x$enable_llcrypt = xyes)
3454 AM_CONDITIONAL(LIBAIO, test x$enable_libaio = xyes)
3455 ]) # LC_CONDITIONALS
3456
3457 #
3458 # LC_CONFIG_FILES
3459 #
3460 # files that should be generated with AC_OUTPUT
3461 #
3462 AC_DEFUN([LC_CONFIG_FILES],
3463 [AC_CONFIG_FILES([
3464 lustre/Makefile
3465 lustre/autoMakefile
3466 lustre/autoconf/Makefile
3467 lustre/conf/Makefile
3468 lustre/conf/resource/Makefile
3469 lustre/contrib/Makefile
3470 lustre/doc/Makefile
3471 lustre/include/Makefile
3472 lustre/include/lustre/Makefile
3473 lustre/include/uapi/linux/lustre/Makefile
3474 lustre/kernel_patches/targets/5.14-rhel9.0.target
3475 lustre/kernel_patches/targets/4.18-rhel8.7.target
3476 lustre/kernel_patches/targets/4.18-rhel8.6.target
3477 lustre/kernel_patches/targets/4.18-rhel8.5.target
3478 lustre/kernel_patches/targets/4.18-rhel8.4.target
3479 lustre/kernel_patches/targets/4.18-rhel8.3.target
3480 lustre/kernel_patches/targets/4.18-rhel8.2.target
3481 lustre/kernel_patches/targets/4.18-rhel8.1.target
3482 lustre/kernel_patches/targets/4.18-rhel8.target
3483 lustre/kernel_patches/targets/3.10-rhel7.9.target
3484 lustre/kernel_patches/targets/3.10-rhel7.8.target
3485 lustre/kernel_patches/targets/3.10-rhel7.7.target
3486 lustre/kernel_patches/targets/3.10-rhel7.6.target
3487 lustre/kernel_patches/targets/3.10-rhel7.5.target
3488 lustre/kernel_patches/targets/4.14-rhel7.5.target
3489 lustre/kernel_patches/targets/4.14-rhel7.6.target
3490 lustre/kernel_patches/targets/4.12-sles12sp4.target
3491 lustre/kernel_patches/targets/4.12-sles12sp5.target
3492 lustre/kernel_patches/targets/4.12-sles15sp1.target
3493 lustre/kernel_patches/targets/5.3-sles15sp2.target
3494 lustre/kernel_patches/targets/5.3-sles15sp3.target
3495 lustre/kernel_patches/targets/5.14-sles15sp4.target
3496 lustre/kernel_patches/targets/3.x-fc18.target
3497 lustre/kernel_patches/targets/5.10-oe2203.target
3498 lustre/ldlm/Makefile
3499 lustre/ldlm/autoMakefile
3500 lustre/ec/autoMakefile
3501 lustre/ec/Makefile
3502 lustre/fid/Makefile
3503 lustre/fid/autoMakefile
3504 lustre/llite/Makefile
3505 lustre/llite/autoMakefile
3506 lustre/lov/Makefile
3507 lustre/lov/autoMakefile
3508 lustre/mdc/Makefile
3509 lustre/mdc/autoMakefile
3510 lustre/lmv/Makefile
3511 lustre/lmv/autoMakefile
3512 lustre/lfsck/Makefile
3513 lustre/lfsck/autoMakefile
3514 lustre/mdt/Makefile
3515 lustre/mdt/autoMakefile
3516 lustre/mdd/Makefile
3517 lustre/mdd/autoMakefile
3518 lustre/fld/Makefile
3519 lustre/fld/autoMakefile
3520 lustre/obdclass/Makefile
3521 lustre/obdclass/autoMakefile
3522 lustre/obdecho/Makefile
3523 lustre/obdecho/autoMakefile
3524 lustre/ofd/Makefile
3525 lustre/ofd/autoMakefile
3526 lustre/osc/Makefile
3527 lustre/osc/autoMakefile
3528 lustre/ost/Makefile
3529 lustre/ost/autoMakefile
3530 lustre/osd-ldiskfs/Makefile
3531 lustre/osd-ldiskfs/autoMakefile
3532 lustre/osd-zfs/Makefile
3533 lustre/osd-zfs/autoMakefile
3534 lustre/mgc/Makefile
3535 lustre/mgc/autoMakefile
3536 lustre/mgs/Makefile
3537 lustre/mgs/autoMakefile
3538 lustre/target/Makefile
3539 lustre/target/autoMakefile
3540 lustre/ptlrpc/Makefile
3541 lustre/ptlrpc/autoMakefile
3542 lustre/ptlrpc/gss/Makefile
3543 lustre/ptlrpc/gss/autoMakefile
3544 lustre/quota/Makefile
3545 lustre/quota/autoMakefile
3546 lustre/scripts/Makefile
3547 lustre/scripts/systemd/Makefile
3548 lustre/tests/Makefile
3549 lustre/tests/mpi/Makefile
3550 lustre/tests/iabf/Makefile
3551 lustre/tests/lutf/Makefile
3552 lustre/tests/lutf/src/Makefile
3553 lustre/tests/kernel/Makefile
3554 lustre/tests/kernel/autoMakefile
3555 lustre/utils/Makefile
3556 lustre/utils/gss/Makefile
3557 lustre/osp/Makefile
3558 lustre/osp/autoMakefile
3559 lustre/lod/Makefile
3560 lustre/lod/autoMakefile
3561 ])
3562 ]) # LC_CONFIG_FILES