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