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