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