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