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