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