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