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