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