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