Whamcloud - gitweb
58184b75298bd7cb919669b5f8c8093923183f43
[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 #
642 # LC_D_COMPARE_7ARGS
643 #
644 # 2.6.38 dentry_operations.d_compare() taken 7 arguments.
645 #
646 AC_DEFUN([LC_D_COMPARE_7ARGS], [
647 LB_CHECK_COMPILE([if 'dentry_operations.d_compare()' taken 7 arguments],
648 dentry_ops_d_compare_7arg, [
649         #include <linux/dcache.h>
650 ],[
651         ((struct dentry_operations*)0)->d_compare(NULL,NULL,NULL,NULL,0,NULL,NULL);
652 ],[
653         AC_DEFINE(HAVE_D_COMPARE_7ARGS, 1, [d_compare need 7 arguments])
654 ])
655 ]) # LC_D_COMPARE_7ARGS
656
657 #
658 # LC_D_DELETE_CONST
659 #
660 # 2.6.38 dentry_operations.d_delete() defined 'const' for 1st parameter.
661 #
662 AC_DEFUN([LC_D_DELETE_CONST], [
663 tmp_flags="$EXTRA_KCFLAGS"
664 EXTRA_KCFLAGS="-Werror"
665 LB_CHECK_COMPILE([if 'dentry_operations.d_delete()' has const declare on first parameter],
666 dentry_ops_d_delete_1st_const, [
667         #include <linux/dcache.h>
668 ],[
669         const struct dentry *d = NULL;
670         ((struct dentry_operations*)0)->d_delete(d);
671 ],[
672         AC_DEFINE(HAVE_D_DELETE_CONST, const,
673                 [d_delete first parameter declared const])
674 ],[
675         AC_DEFINE(HAVE_D_DELETE_CONST, [],
676                 [d_delete first parameter declared is not const])
677 ])
678 EXTRA_KCFLAGS="$tmp_flags"
679 ]) # LC_D_DELETE_CONST
680
681 #
682 # LC_DCACHE_LOCK
683 #
684 # 2.6.38 dcache_lock removed. rcu-walk committed.
685 #
686 AC_DEFUN([LC_DCACHE_LOCK], [
687 LB_CHECK_COMPILE([if 'dcache_lock' is exist],
688 dcache_lock, [
689         #include <linux/dcache.h>
690 ],[
691         spin_lock(&dcache_lock);
692 ],[
693         AC_DEFINE(HAVE_DCACHE_LOCK, 1,
694                 [dcache_lock is exist])
695 ])
696 ]) # LC_DCACHE_LOCK
697
698 #
699 # LC_INODE_I_RCU
700 #
701 # 2.6.38 inode.i_rcu added.
702 #
703 AC_DEFUN([LC_INODE_I_RCU], [
704 LB_CHECK_COMPILE([if 'inode.i_rcu' exists],
705 inode_i_rcu, [
706         #include <linux/fs.h>
707 ],[
708         struct inode ino;
709         struct rcu_head rcu = {};
710         ino.i_rcu = rcu;
711 ],[
712         AC_DEFINE(HAVE_INODE_I_RCU, 1,
713                 [inode.i_rcu exists])
714 ])
715 ]) # LC_INODE_I_RCU
716
717 #
718 # LC_BLKDEV_GET_BY_DEV
719 #
720 # 2.6.38 export blkdev_get_by_dev
721 #
722 AC_DEFUN([LC_BLKDEV_GET_BY_DEV], [
723 LB_CHECK_EXPORT([blkdev_get_by_dev], [fs/block_dev.c],
724         [AC_DEFINE(HAVE_BLKDEV_GET_BY_DEV, 1,
725                 [blkdev_get_by_dev is exported by the kernel])])
726 ]) # LC_BLKDEV_GET_BY_DEV
727
728 #
729 # LC_EXPORT_SIMPLE_SETATTR
730 #
731 # 2.6.38 export simple_setattr
732 #
733 AC_DEFUN([LC_EXPORT_SIMPLE_SETATTR], [
734 LB_CHECK_EXPORT([simple_setattr], [fs/libfs.c],
735         [AC_DEFINE(HAVE_SIMPLE_SETATTR, 1,
736                 [simple_setattr is exported by the kernel])])
737 ]) # LC_EXPORT_SIMPLE_SETATTR
738
739 #
740 # LC_HAVE_BLK_PLUG
741 #
742 # 2.6.38 add struct blk_plug
743 #
744 AC_DEFUN([LC_HAVE_BLK_PLUG], [
745 LB_CHECK_COMPILE([if 'struct blk_plug' exists],
746 blk_plug, [
747         #include <linux/blkdev.h>
748 ],[
749         struct blk_plug plug;
750
751         blk_start_plug(&plug);
752         blk_finish_plug(&plug);
753 ],[
754         AC_DEFINE(HAVE_BLK_PLUG, 1,
755                 [blk_plug struct exists])
756 ])
757 ]) # LC_HAVE_BLK_PLUG
758
759 #
760 # LC_IOP_TRUNCATE
761 #
762 # truncate callback removed since 2.6.39
763 #
764 AC_DEFUN([LC_IOP_TRUNCATE], [
765 LB_CHECK_COMPILE([if 'inode_operations' has '.truncate' member function],
766 inode_ops_truncate, [
767         #include <linux/fs.h>
768 ],[
769         ((struct inode_operations *)0)->truncate(NULL);
770 ],[
771         AC_DEFINE(HAVE_INODEOPS_TRUNCATE, 1,
772                 [inode_operations has .truncate member function])
773 ])
774 ]) # LC_IOP_TRUNCATE
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 # LC_HAVE_MIGRATE_HEADER
1022 #
1023 # 3.3 introduces migrate_mode.h and migratepage has 4 args
1024 #
1025 AC_DEFUN([LC_HAVE_MIGRATE_HEADER], [
1026 LB_CHECK_FILE([$LINUX/include/linux/migrate.h], [
1027         AC_DEFINE(HAVE_MIGRATE_H, 1,
1028                 [kernel has include/linux/migrate.h])
1029 ],[
1030         LB_CHECK_FILE([$LINUX/include/linux/migrate_mode.h], [
1031                 AC_DEFINE(HAVE_MIGRATE_MODE_H, 1,
1032                         [kernel has include/linux/migrate_mode.h])
1033         ])
1034 ])
1035 ]) # LC_HAVE_MIGRATE_HEADER
1036
1037 #
1038 # LC_MIGRATEPAGE_4ARGS
1039 #
1040 AC_DEFUN([LC_MIGRATEPAGE_4ARGS], [
1041 LB_CHECK_COMPILE([if 'address_space_operations.migratepage' has 4 args],
1042 address_space_ops_migratepage_4args, [
1043         #include <linux/fs.h>
1044 #ifdef HAVE_MIGRATE_H
1045         #include <linux/migrate.h>
1046 #elif defined(HAVE_MIGRATE_MODE_H)
1047         #include <linux/migrate_mode.h>
1048 #endif
1049 ],[
1050         struct address_space_operations aops = { };
1051         aops.migratepage(NULL, NULL, NULL, MIGRATE_ASYNC);
1052 ],[
1053         AC_DEFINE(HAVE_MIGRATEPAGE_4ARGS, 1,
1054                 [address_space_operations.migratepage has 4 args])
1055 ])
1056 ]) # LC_MIGRATEPAGE_4ARGS
1057
1058 #
1059 # LC_SUPEROPS_USE_DENTRY
1060 #
1061 # 3.3 switchs super_operations to use dentry as parameter (but not vfsmount)
1062 # see kernel commit 34c80b1d93e6e20ca9dea0baf583a5b5510d92d4
1063 #
1064 AC_DEFUN([LC_SUPEROPS_USE_DENTRY], [
1065 tmp_flags="$EXTRA_KCFLAGS"
1066 EXTRA_KCFLAGS="-Werror"
1067 LB_CHECK_COMPILE([if 'super_operations' use 'dentry' as parameter],
1068 super_ops_dentry, [
1069         #include <linux/fs.h>
1070         int show_options(struct seq_file *seq, struct dentry *root) {
1071                 return 0;
1072         }
1073 ],[
1074         struct super_operations ops;
1075         ops.show_options = show_options;
1076 ],[
1077         AC_DEFINE(HAVE_SUPEROPS_USE_DENTRY, 1,
1078                 [super_operations use dentry as parameter])
1079 ])
1080 EXTRA_KCFLAGS="$tmp_flags"
1081 ]) # LC_SUPEROPS_USE_DENTRY
1082
1083 #
1084 # LC_INODEOPS_USE_UMODE_T
1085 #
1086 # 3.3 switchs inode_operations to use umode_t as parameter (but not int)
1087 # see kernel commit 1a67aafb5f72a436ca044293309fa7e6351d6a35
1088 #
1089 AC_DEFUN([LC_INODEOPS_USE_UMODE_T], [
1090 tmp_flags="$EXTRA_KCFLAGS"
1091 EXTRA_KCFLAGS="-Werror"
1092 LB_CHECK_COMPILE([if 'inode_operations' use 'umode_t' as parameter],
1093 inode_ops_umode_t, [
1094         #include <linux/fs.h>
1095         #include <linux/types.h>
1096         int my_mknod(struct inode *dir, struct dentry *dchild,
1097                      umode_t mode, dev_t dev)
1098         {
1099                 return 0;
1100         }
1101 ],[
1102         struct inode_operations ops;
1103         ops.mknod = my_mknod;
1104 ],[
1105         AC_DEFINE(HAVE_INODEOPS_USE_UMODE_T, 1,
1106                 [inode_operations use umode_t as parameter])
1107 ])
1108 EXTRA_KCFLAGS="$tmp_flags"
1109 ]) # LC_INODEOPS_USE_UMODE_T
1110
1111 #
1112 # LC_KMAP_ATOMIC_HAS_1ARG
1113 #
1114 # 3.4 kmap_atomic removes second argument
1115 # see kernel commit 1ec9c5ddc17aa398f05646abfcbaf315b544e62f
1116 #
1117 AC_DEFUN([LC_KMAP_ATOMIC_HAS_1ARG], [
1118 LB_CHECK_COMPILE([if 'kmap_atomic' has only 1 argument],
1119 kmap_atomic_1arg, [
1120         #include <linux/highmem.h>
1121 ],[
1122         kmap_atomic(NULL);
1123 ],[
1124         AC_DEFINE(HAVE_KMAP_ATOMIC_HAS_1ARG, 1,
1125                 [have kmap_atomic has only 1 argument])
1126 ])
1127 ]) # LC_KMAP_ATOMIC_HAS_1ARG
1128
1129 #
1130 # LC_HAVE_D_MAKE_ROOT
1131 #
1132 # 3.4 converts d_alloc_root to d_make_root
1133 # see kernel commit 32991ab305ace7017c62f8eecbe5eb36dc32e13b
1134 #
1135 AC_DEFUN([LC_HAVE_D_MAKE_ROOT], [
1136 LB_CHECK_COMPILE([if have 'd_make_root'],
1137 d_make_root, [
1138         #include <linux/fs.h>
1139 ],[
1140         d_make_root((struct inode *)NULL);
1141 ],[
1142         AC_DEFINE(HAVE_D_MAKE_ROOT, 1,
1143                 [have d_make_root])
1144 ])
1145 ]) # LC_HAVE_D_MAKE_ROOT
1146
1147 #
1148 # LC_HAVE_CACHE_REGISTER
1149 #
1150 # 3.4 cache_register/cache_unregister are removed
1151 # see kernel commit 2c5f846747526e2b83c5f1b8e69016be0e2e87c0
1152 # Note, since 2.6.37 cache_register_net/cache_unregister_net
1153 # are defined, but not exported.
1154 # 3.3 cache_register_net/cache_unregister_net are
1155 # exported and replacing cache_register/cache_unregister in 3.4
1156 #
1157 AC_DEFUN([LC_HAVE_CACHE_REGISTER], [
1158 LB_CHECK_COMPILE([if have 'cache_register'],
1159 cache_register, [
1160         #include <linux/sunrpc/cache.h>
1161 ],[
1162         cache_register(NULL);
1163 ],[
1164         AC_DEFINE(HAVE_CACHE_REGISTER, 1,
1165                 [have cache_register])
1166 ])
1167 ]) # LC_HAVE_CACHE_REGISTER
1168
1169 #
1170 # LC_HAVE_CLEAR_INODE
1171 #
1172 # 3.5 renames end_writeback() back to clear_inode()...
1173 # see kernel commit dbd5768f87ff6fb0a4fe09c4d7b6c4a24de99430
1174 #
1175 AC_DEFUN([LC_HAVE_CLEAR_INODE], [
1176 LB_CHECK_COMPILE([if have 'clear_inode'],
1177 clear_inode, [
1178         #include <linux/fs.h>
1179 ],[
1180         clear_inode((struct inode *)NULL);
1181 ],[
1182         AC_DEFINE(HAVE_CLEAR_INODE, 1,
1183                 [have clear_inode])
1184 ])
1185 ]) # LC_HAVE_CLEAR_INODE
1186
1187 #
1188 # LC_HAVE_ENCODE_FH_PARENT
1189 #
1190 # 3.5 encode_fh has parent inode passed in directly
1191 # see kernel commit b0b0382b
1192 #
1193 AC_DEFUN([LC_HAVE_ENCODE_FH_PARENT], [
1194 tmp_flags="$EXTRA_KCFLAGS"
1195 EXTRA_KCFLAGS="-Werror"
1196 LB_CHECK_COMPILE([if 'encode_fh' have parent inode as parameter],
1197 encode_fh_parent_inode, [
1198         #include <linux/exportfs.h>
1199         #include <linux/fs.h>
1200         #include <linux/types.h>
1201         int ll_encode_fh(struct inode *i, __u32 *a, int *b, struct inode *p)
1202         {
1203                 return 0;
1204         }
1205 ],[
1206         struct export_operations exp_op;
1207         exp_op.encode_fh = ll_encode_fh;
1208 ],[
1209         AC_DEFINE(HAVE_ENCODE_FH_PARENT, 1,
1210                 [have parent inode as parameter])
1211 ])
1212 EXTRA_KCFLAGS="$tmp_flags"
1213 ]) # LC_HAVE_ENCODE_FH_PARENT
1214
1215 #
1216 # LC_FILE_LLSEEK_SIZE_5ARG
1217 #
1218 # 3.5 has generic_file_llseek_size with 5 args
1219 #
1220 AC_DEFUN([LC_FILE_LLSEEK_SIZE_5ARG], [
1221 LB_CHECK_COMPILE([if Linux kernel has 'generic_file_llseek_size' with 5 args],
1222 generic_file_llseek_size_5args, [
1223         #include <linux/fs.h>
1224 ],[
1225         generic_file_llseek_size(NULL, 0, 0, 0, 0);
1226 ], [
1227         AC_DEFINE(HAVE_FILE_LLSEEK_SIZE_5ARGS, 1,
1228                 [kernel has generic_file_llseek_size with 5 args])
1229 ])
1230 ]) # LC_FILE_LLSEEK_SIZE_5ARG
1231
1232 #
1233 # LC_LLITE_DATA_IS_LIST
1234 #
1235 # 3.6 switch i_dentry/d_alias from list to hlist
1236 #
1237 # In the upstream kernels d_alias first changes
1238 # to a hlist and then in later version, 3.11, gets
1239 # moved to the union d_u. Due to some distros having
1240 # d_alias in the d_u union as a struct list, which
1241 # has never existed upstream stream, we can't test
1242 # if d_alias is a list or hlist directly. If ever
1243 # i_dentry and d_alias even up different combos then
1244 # the build will fail. In that case then we will need
1245 # to separate out the i_dentry and d_alias test below.
1246 #
1247 AC_DEFUN([LC_DATA_FOR_LLITE_IS_LIST], [
1248 tmp_flags="$EXTRA_KCFLAGS"
1249 EXTRA_KCFLAGS="-Werror"
1250 LB_CHECK_COMPILE([if 'i_dentry/d_alias' uses 'list'],
1251 i_dentry_d_alias_list, [
1252         #include <linux/fs.h>
1253 ],[
1254         struct inode inode;
1255         INIT_LIST_HEAD(&inode.i_dentry);
1256 ],[
1257         AC_DEFINE(DATA_FOR_LLITE_IS_LIST, 1,
1258                 [both i_dentry/d_alias uses list])
1259 ])
1260 EXTRA_KCFLAGS="$tmp_flags"
1261 ]) # LC_DATA_FOR_LLITE_IS_LIST
1262
1263 #
1264 # LC_DENTRY_OPEN_USE_PATH
1265 #
1266 # 3.6 dentry_open uses struct path as first argument
1267 # see kernel commit 765927b2
1268 #
1269 AC_DEFUN([LC_DENTRY_OPEN_USE_PATH], [
1270 tmp_flags="$EXTRA_KCFLAGS"
1271 EXTRA_KCFLAGS="-Werror"
1272 LB_CHECK_COMPILE([if 'dentry_open' uses 'struct path' as first argument],
1273 dentry_open_path, [
1274         #include <linux/fs.h>
1275         #include <linux/path.h>
1276 ],[
1277         struct path path;
1278         dentry_open(&path, 0, NULL);
1279 ],[
1280         AC_DEFINE(HAVE_DENTRY_OPEN_USE_PATH, 1,
1281                 [dentry_open uses struct path as first argument])
1282 ])
1283 EXTRA_KCFLAGS="$tmp_flags"
1284 ]) # LC_DENTRY_OPEN_USE_PATH
1285
1286 #
1287 # LC_HAVE_IOP_ATOMIC_OPEN
1288 #
1289 # 3.6 vfs adds iop->atomic_open
1290 #
1291 AC_DEFUN([LC_HAVE_IOP_ATOMIC_OPEN], [
1292 LB_CHECK_COMPILE([if 'iop' has 'atomic_open'],
1293 inode_ops_atomic_open, [
1294         #include <linux/fs.h>
1295 ],[
1296         struct inode_operations iop;
1297         iop.atomic_open = NULL;
1298 ],[
1299         AC_DEFINE(HAVE_IOP_ATOMIC_OPEN, 1,
1300                 [have iop atomic_open])
1301 ])
1302 ]) # LC_HAVE_IOP_ATOMIC_OPEN
1303
1304 #
1305 # LC_HAVE_SB_START_WRITE
1306 #
1307 # RHEL6 2.6.32, 3.6 or newer support wrapped FS freeze functions
1308 #
1309 AC_DEFUN([LC_HAVE_SB_START_WRITE], [
1310 LB_CHECK_COMPILE([if kernel supports wrapped FS freeze functions],
1311 sb_start_write, [
1312         #include <linux/fs.h>
1313 ],[
1314         sb_start_write(NULL);
1315 ],[
1316         AC_DEFINE(HAVE_SB_START_WRITE, 1,
1317                 [kernel supports wrapped FS freeze functions])
1318 ])
1319 ]) # LC_HAVE_SB_START_WRITE
1320
1321 #
1322 # LC_HAVE_POSIXACL_USER_NS
1323 #
1324 # 3.7 posix_acl_{to,from}_xattr take struct user_namespace
1325 #
1326 AC_DEFUN([LC_HAVE_POSIXACL_USER_NS], [
1327 LB_CHECK_COMPILE([if 'posix_acl_to_xattr' takes 'struct user_namespace'],
1328 posix_acl_to_xattr_user_namespace, [
1329         #include <linux/fs.h>
1330         #include <linux/posix_acl_xattr.h>
1331 ],[
1332         posix_acl_to_xattr((struct user_namespace *)NULL, NULL, NULL, 0);
1333 ],[
1334         AC_DEFINE(HAVE_POSIXACL_USER_NS, 1,
1335                 [posix_acl_to_xattr takes struct user_namespace])
1336 ])
1337 ]) # LC_HAVE_POSIXACL_USER_NS
1338
1339 #
1340 # LC_HAVE_FILE_F_INODE
1341 #
1342 # 3.8 struct file has new member f_inode
1343 #
1344 AC_DEFUN([LC_HAVE_FILE_F_INODE], [
1345 LB_CHECK_COMPILE([if 'struct file' has member 'f_inode'],
1346 file_f_inode, [
1347         #include <linux/fs.h>
1348 ],[
1349         ((struct file *)0)->f_inode = NULL;
1350 ],[
1351         AC_DEFINE(HAVE_FILE_F_INODE, 1,
1352                 [struct file has member f_inode])
1353 ])
1354 ]) # LC_HAVE_FILE_F_INODE
1355
1356 #
1357 # LC_HAVE_FILE_INODE
1358 #
1359 # 3.8 has introduced inline function file_inode
1360 #
1361 AC_DEFUN([LC_HAVE_FILE_INODE], [
1362 LB_CHECK_COMPILE([if file_inode() exists],
1363 file_inode, [
1364         #include <linux/fs.h>
1365 ],[
1366         file_inode(NULL);
1367 ],[
1368         AC_DEFINE(HAVE_FILE_INODE, 1,
1369                 [file_inode() has been defined])
1370 ])
1371 ]) # LC_HAVE_FILE_INODE
1372
1373 #
1374 # LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS
1375 #
1376 AC_DEFUN([LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS], [
1377 LB_CHECK_COMPILE([if 'sunrpc_cache_pipe_upcall' takes 3 args],
1378 sunrpc_cache_pipe_upcall_3args, [
1379         #include <linux/sunrpc/cache.h>
1380 ],[
1381         sunrpc_cache_pipe_upcall(NULL, NULL, NULL);
1382 ],[
1383         AC_DEFINE(HAVE_SUNRPC_UPCALL_HAS_3ARGS, 1,
1384                 [sunrpc_cache_pipe_upcall takes 3 args])
1385 ])
1386 ]) # LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS
1387
1388 #
1389 # LC_HAVE_HLIST_FOR_EACH_3ARG
1390 #
1391 # 3.9 uses hlist_for_each_entry with 3 args
1392 # b67bfe0d42cac56c512dd5da4b1b347a23f4b70a
1393 #
1394 AC_DEFUN([LC_HAVE_HLIST_FOR_EACH_3ARG], [
1395 LB_CHECK_COMPILE([if 'hlist_for_each_entry' has 3 args],
1396 hlist_for_each_entry_3args, [
1397         #include <linux/list.h>
1398         #include <linux/fs.h>
1399 ],[
1400         struct hlist_head *head = NULL;
1401         struct inode *inode;
1402
1403         hlist_for_each_entry(inode, head, i_hash) {
1404                 continue;
1405         }
1406 ],[
1407         AC_DEFINE(HAVE_HLIST_FOR_EACH_3ARG, 1,
1408                 [hlist_for_each_entry has 3 args])
1409 ])
1410 ]) # LC_HAVE_HLIST_FOR_EACH_3ARG
1411
1412 #
1413 # LC_HAVE_BIO_END_SECTOR
1414 #
1415 # 3.9 introduces bio_end_sector macro
1416 # f73a1c7d117d07a96d89475066188a2b79e53c48
1417 #
1418 AC_DEFUN([LC_HAVE_BIO_END_SECTOR], [
1419 LB_CHECK_COMPILE([if 'bio_end_sector' is defined],
1420 bio_end_sector, [
1421         #include <linux/bio.h>
1422 ],[
1423         struct bio bio = { };
1424         unsigned long long end;
1425
1426         end = bio_end_sector(&bio);
1427 ],[
1428         AC_DEFINE(HAVE_BIO_END_SECTOR, 1,
1429                   [bio_end_sector is defined])
1430 ])
1431 ]) # LC_HAVE_BIO_END_SECTOR
1432
1433 #
1434 # 3.9 created is_sxid
1435 #
1436 AC_DEFUN([LC_HAVE_IS_SXID], [
1437 LB_CHECK_COMPILE([if 'is_sxid' is defined],
1438 is_sxid, [
1439         #include <linux/fs.h>
1440 ],[
1441         struct inode inode = { };
1442
1443         is_sxid(inode.i_mode);
1444 ],[
1445         AC_DEFINE(HAVE_IS_SXID, 1, [is_sxid is defined])
1446 ])
1447 ]) # LC_HAVE_IS_SXID
1448
1449 #
1450 # LC_HAVE_REMOVE_PROC_SUBTREE
1451 #
1452 # 3.10 introduced remove_proc_subtree
1453 #
1454 AC_DEFUN([LC_HAVE_REMOVE_PROC_SUBTREE], [
1455 LB_CHECK_COMPILE([if 'remove_proc_subtree' is defined],
1456 remove_proc_subtree, [
1457         #include <linux/proc_fs.h>
1458 ],[
1459         remove_proc_subtree(NULL, NULL);
1460 ], [
1461         AC_DEFINE(HAVE_REMOVE_PROC_SUBTREE, 1,
1462                   [remove_proc_subtree is defined])
1463 ])
1464 ]) # LC_HAVE_REMOVE_PROC_SUBTREE
1465
1466 #
1467 # LC_HAVE_PROC_REMOVE
1468 #
1469 # 3.10 introduced proc_remove
1470 #
1471 AC_DEFUN([LC_HAVE_PROC_REMOVE], [
1472 LB_CHECK_COMPILE([if 'proc_remove' is defined],
1473 proc_remove, [
1474         #include <linux/proc_fs.h>
1475 ],[
1476         proc_remove(NULL);
1477 ], [
1478         AC_DEFINE(HAVE_PROC_REMOVE, 1,
1479                   [proc_remove is defined])
1480 ])
1481 ]) # LC_HAVE_PROC_REMOVE
1482
1483 AC_DEFUN([LC_HAVE_PROJECT_QUOTA], [
1484 LB_CHECK_COMPILE([if get_projid exists],
1485 get_projid, [
1486         struct inode;
1487         #include <linux/quota.h>
1488 ],[
1489         struct dquot_operations ops = { };
1490
1491         ops.get_projid(NULL, NULL);
1492 ],[
1493         AC_DEFINE(HAVE_PROJECT_QUOTA, 1,
1494                 [get_projid function exists])
1495 ])
1496 ]) # LC_HAVE_PROJECT_QUOTA
1497
1498
1499 #
1500 # LC_HAVE_SECURITY_DENTRY_INIT_SECURITY
1501 #
1502 # 3.10 introduced security_dentry_init_security()
1503 #
1504 AC_DEFUN([LC_HAVE_SECURITY_DENTRY_INIT_SECURITY], [
1505 LB_CHECK_COMPILE([if 'security_dentry_init_security' is defined],
1506 security_dentry_init_security, [
1507         #include <linux/security.h>
1508 ],[
1509         security_dentry_init_security(NULL, 0, NULL, NULL, NULL);
1510 ],[
1511         AC_DEFINE(HAVE_SECURITY_DENTRY_INIT_SECURITY, 1,
1512                 [security_dentry_init_security' is defined])
1513 ])
1514 ]) # LC_HAVE_SECURITY_DENTRY_INIT_SECURITY
1515
1516 #
1517 # LC_INVALIDATE_RANGE
1518 #
1519 # 3.11 invalidatepage requires the length of the range to invalidate
1520 #
1521 AC_DEFUN([LC_INVALIDATE_RANGE], [
1522 LB_CHECK_COMPILE([if 'address_space_operations.invalidatepage' requires 3 arguments],
1523 address_space_ops_invalidatepage_3args, [
1524         #include <linux/fs.h>
1525 ],[
1526         struct address_space_operations a_ops;
1527         a_ops.invalidatepage(NULL, 0, 0);
1528 ],[
1529         AC_DEFINE(HAVE_INVALIDATE_RANGE, 1,
1530                 [address_space_operations.invalidatepage needs 3 arguments])
1531 ])
1532 ]) # LC_INVALIDATE_RANGE
1533
1534 #
1535 # LC_HAVE_DIR_CONTEXT
1536 #
1537 # 3.11 readdir now takes the new struct dir_context
1538 #
1539 AC_DEFUN([LC_HAVE_DIR_CONTEXT], [
1540 LB_CHECK_COMPILE([if 'dir_context' exist],
1541 dir_context, [
1542         #include <linux/fs.h>
1543 ],[
1544 #ifdef FMODE_KABI_ITERATE
1545 #error "back to use readdir in kabi_extand mode"
1546 #else
1547         struct dir_context ctx;
1548
1549         ctx.pos = 0;
1550 #endif
1551 ],[
1552         AC_DEFINE(HAVE_DIR_CONTEXT, 1,
1553                 [dir_context exist])
1554 ])
1555 ]) # LC_HAVE_DIR_CONTEXT
1556
1557 #
1558 # LC_D_COMPARE_5ARGS
1559 #
1560 # 3.11 dentry_operations.d_compare() taken 5 arguments.
1561 #
1562 AC_DEFUN([LC_D_COMPARE_5ARGS], [
1563 LB_CHECK_COMPILE([if 'd_compare' taken 5 arguments],
1564 d_compare_5args, [
1565         #include <linux/dcache.h>
1566 ],[
1567         ((struct dentry_operations*)0)->d_compare(NULL,NULL,0,NULL,NULL);
1568 ],[
1569         AC_DEFINE(HAVE_D_COMPARE_5ARGS, 1,
1570                 [d_compare need 5 arguments])
1571 ])
1572 ]) # LC_D_COMPARE_5ARGS
1573
1574 #
1575 # LC_HAVE_DCOUNT
1576 #
1577 # 3.11 need to access d_count to get dentry reference count
1578 #
1579 AC_DEFUN([LC_HAVE_DCOUNT], [
1580 LB_CHECK_COMPILE([if 'd_count' exists],
1581 d_count, [
1582         #include <linux/dcache.h>
1583 ],[
1584         struct dentry de = { };
1585         int count;
1586
1587         count = d_count(&de);
1588 ],[
1589         AC_DEFINE(HAVE_D_COUNT, 1,
1590                 [d_count exist])
1591 ])
1592 ]) # LC_HAVE_DCOUNT
1593
1594 #
1595 # LC_PID_NS_FOR_CHILDREN
1596 #
1597 # 3.11 replaces pid_ns by pid_ns_for_children in struct nsproxy
1598 #
1599 AC_DEFUN([LC_PID_NS_FOR_CHILDREN], [
1600 LB_CHECK_COMPILE([if 'struct nsproxy' has 'pid_ns_for_children'],
1601 pid_ns_for_children, [
1602         #include <linux/nsproxy.h>
1603 ],[
1604         struct nsproxy ns;
1605         ns.pid_ns_for_children = NULL;
1606 ],[
1607         AC_DEFINE(HAVE_PID_NS_FOR_CHILDREN, 1,
1608                   ['struct nsproxy' has 'pid_ns_for_children'])
1609 ])
1610 ]) # LC_PID_NS_FOR_CHILDREN
1611
1612 #
1613 # LC_OLDSIZE_TRUNCATE_PAGECACHE
1614 #
1615 # 3.12 truncate_pagecache without oldsize parameter
1616 #
1617 AC_DEFUN([LC_OLDSIZE_TRUNCATE_PAGECACHE], [
1618 LB_CHECK_COMPILE([if 'truncate_pagecache' with 'old_size' parameter],
1619 truncate_pagecache_old_size, [
1620         #include <linux/mm.h>
1621 ],[
1622         truncate_pagecache(NULL, 0, 0);
1623 ],[
1624         AC_DEFINE(HAVE_OLDSIZE_TRUNCATE_PAGECACHE, 1,
1625                 [with oldsize])
1626 ])
1627 ]) # LC_OLDSIZE_TRUNCATE_PAGECACHE
1628
1629 #
1630 # LC_PTR_ERR_OR_ZERO
1631 #
1632 # For some reason SLES11SP4 is missing the PTR_ERR_OR_ZERO macro
1633 # It was added to linux kernel 3.12
1634 #
1635 AC_DEFUN([LC_PTR_ERR_OR_ZERO_MISSING], [
1636 LB_CHECK_COMPILE([if 'PTR_ERR_OR_ZERO' is missing],
1637 is_err_or_null, [
1638         #include <linux/err.h>
1639 ],[
1640         if (PTR_ERR_OR_ZERO(NULL)) return 0;
1641 ],[
1642         AC_DEFINE(HAVE_PTR_ERR_OR_ZERO, 1,
1643                 ['PTR_ERR_OR_ZERO' exist])
1644 ])
1645 ]) # LC_PTR_ERR_OR_ZERO_MISSING
1646
1647 #
1648 # LC_HAVE_DENTRY_D_U_D_ALIAS
1649 #
1650 # 3.11 kernel moved d_alias to the union d_u in struct dentry
1651 #
1652 # Some distros move d_alias to d_u but it is still a struct list
1653 #
1654 AC_DEFUN([LC_HAVE_DENTRY_D_U_D_ALIAS], [
1655 AS_IF([test "x$lb_cv_compile_i_dentry_d_alias_list" = xyes], [
1656         LB_CHECK_COMPILE([if list 'dentry.d_u.d_alias' exist],
1657         d_alias, [
1658                 #include <linux/list.h>
1659                 #include <linux/dcache.h>
1660         ],[
1661                 struct dentry de;
1662                 INIT_LIST_HEAD(&de.d_u.d_alias);
1663         ],[
1664                 AC_DEFINE(HAVE_DENTRY_D_U_D_ALIAS, 1,
1665                         [list dentry.d_u.d_alias exist])
1666         ])
1667 ],[
1668         LB_CHECK_COMPILE([if hlist 'dentry.d_u.d_alias' exist],
1669         d_alias, [
1670                 #include <linux/list.h>
1671                 #include <linux/dcache.h>
1672         ],[
1673                 struct dentry de;
1674                 INIT_HLIST_NODE(&de.d_u.d_alias);
1675         ],[
1676                 AC_DEFINE(HAVE_DENTRY_D_U_D_ALIAS, 1,
1677                         [hlist dentry.d_u.d_alias exist])
1678         ])
1679 ])
1680 ]) # LC_HAVE_DENTRY_D_U_D_ALIAS
1681
1682 #
1683 # LC_HAVE_DENTRY_D_CHILD
1684 #
1685 # 3.11 kernel d_child has been moved out of the union d_u
1686 # in struct dentry
1687 #
1688 AC_DEFUN([LC_HAVE_DENTRY_D_CHILD], [
1689 LB_CHECK_COMPILE([if 'dentry.d_child' exist],
1690 d_child, [
1691         #include <linux/list.h>
1692         #include <linux/dcache.h>
1693 ],[
1694         struct dentry de;
1695         INIT_LIST_HEAD(&de.d_child);
1696 ],[
1697         AC_DEFINE(HAVE_DENTRY_D_CHILD, 1,
1698                 [dentry.d_child exist])
1699 ])
1700 ]) # LC_HAVE_DENTRY_D_CHILD
1701
1702 #
1703 # LC_KIOCB_KI_LEFT
1704 #
1705 # 3.12 ki_left removed from struct kiocb
1706 #
1707 AC_DEFUN([LC_KIOCB_KI_LEFT], [
1708 LB_CHECK_COMPILE([if 'struct kiocb' with 'ki_left' member],
1709 kiocb_ki_left, [
1710         #include <linux/aio.h>
1711 ],[
1712         ((struct kiocb*)0)->ki_left = 0;
1713 ],[
1714         AC_DEFINE(HAVE_KIOCB_KI_LEFT, 1,
1715                 [ki_left exist])
1716 ])
1717 ]) # LC_KIOCB_KI_LEFT
1718
1719 #
1720 # LC_INIT_LIST_HEAD_RCU
1721 #
1722 # 3.12 added INIT_LIST_HEAD_RCU in commit 2a855b644c310d5db5
1723 # which is unfortunately an inline function and not a macro
1724 # that can be tested directly, so it needs a configure check.
1725 #
1726 AC_DEFUN([LC_INIT_LIST_HEAD_RCU], [
1727 LB_CHECK_COMPILE([if 'INIT_LIST_HEAD_RCU' exists],
1728 init_list_head_rcu, [
1729         #include <linux/list.h>
1730         #include <linux/rculist.h>
1731 ],[
1732         struct list_head list;
1733         INIT_LIST_HEAD_RCU(&list);
1734 ],[
1735         AC_DEFINE(HAVE_INIT_LIST_HEAD_RCU, 1,
1736                   [INIT_LIST_HEAD_RCU exists])
1737 ])
1738 ]) # LC_INIT_LIST_HEAD_RCU
1739
1740 #
1741 # LC_VFS_RENAME_5ARGS
1742 #
1743 # 3.13 has vfs_rename with 5 args
1744 #
1745 AC_DEFUN([LC_VFS_RENAME_5ARGS], [
1746 LB_CHECK_COMPILE([if Linux kernel has 'vfs_rename' with 5 args],
1747 vfs_rename_5args, [
1748         #include <linux/fs.h>
1749 ],[
1750         vfs_rename(NULL, NULL, NULL, NULL, NULL);
1751 ], [
1752         AC_DEFINE(HAVE_VFS_RENAME_5ARGS, 1,
1753                 [kernel has vfs_rename with 5 args])
1754 ])
1755 ]) # LC_VFS_RENAME_5ARGS
1756
1757 #
1758 # LC_VFS_UNLINK_3ARGS
1759 #
1760 # 3.13 has vfs_unlink with 3 args
1761 #
1762 AC_DEFUN([LC_VFS_UNLINK_3ARGS], [
1763 LB_CHECK_COMPILE([if Linux kernel has 'vfs_unlink' with 3 args],
1764 vfs_unlink_3args, [
1765         #include <linux/fs.h>
1766 ],[
1767         vfs_unlink(NULL, NULL, NULL);
1768 ], [
1769         AC_DEFINE(HAVE_VFS_UNLINK_3ARGS, 1,
1770                 [kernel has vfs_unlink with 3 args])
1771 ])
1772 ]) # LC_VFS_UNLINK_3ARGS
1773
1774 #
1775 # LC_HAVE_BVEC_ITER
1776 #
1777 # 3.14 move some of its data in struct bio into the new
1778 # struct bvec_iter
1779 #
1780 AC_DEFUN([LC_HAVE_BVEC_ITER], [
1781 LB_CHECK_COMPILE([if Linux kernel has struct bvec_iter],
1782 have_bvec_iter, [
1783         #include <linux/bio.h>
1784 ],[
1785         struct bvec_iter iter;
1786
1787         iter.bi_bvec_done = 0;
1788 ], [
1789         AC_DEFINE(HAVE_BVEC_ITER, 1,
1790                 [kernel has struct bvec_iter])
1791 ])
1792 ]) # LC_HAVE_BVEC_ITER
1793
1794 #
1795 # LC_IOP_SET_ACL
1796 #
1797 # 3.14 adds set_acl method to inode_operations
1798 # see kernel commit 893d46e443346370cd4ea81d9d35f72952c62a37
1799 #
1800 AC_DEFUN([LC_IOP_SET_ACL], [
1801 LB_CHECK_COMPILE([if 'inode_operations' has '.set_acl' member function],
1802 inode_ops_set_acl, [
1803         #include <linux/fs.h>
1804 ],[
1805         struct inode_operations iop;
1806         iop.set_acl = NULL;
1807 ],[
1808         AC_DEFINE(HAVE_IOP_SET_ACL, 1,
1809                 [inode_operations has .set_acl member function])
1810 ])
1811 ]) # LC_IOP_SET_ACL
1812
1813 #
1814 # LC_HAVE_BI_CNT
1815 #
1816 # 4.4 redefined bi_cnt as __bi_cnt
1817 #
1818 AC_DEFUN([LC_HAVE_BI_CNT], [
1819 LB_CHECK_COMPILE([if Linux kernel has bi_cnt in struct bio],
1820 have_bi_cnt, [
1821         #include <asm/atomic.h>
1822         #include <linux/bio.h>
1823 ],[
1824         struct bio bio = { };
1825         int cnt;
1826         cnt = atomic_read(&bio.bi_cnt);
1827 ], [
1828         AC_DEFINE(HAVE_BI_CNT, 1,
1829                 [struct bio has bi_cnt])
1830 ])
1831 ]) # LC_HAVE_BI_CNT
1832
1833 #
1834 # LC_HAVE_BI_RW
1835 #
1836 # 4.4 redefined bi_rw as bi_opf
1837 #
1838 AC_DEFUN([LC_HAVE_BI_RW], [
1839 LB_CHECK_COMPILE([if Linux kernel has bi_rw in struct bio],
1840 have_bi_rw, [
1841         #include <linux/bio.h>
1842 ],[
1843         struct bio bio;
1844
1845         bio.bi_rw = 0;
1846 ], [
1847         AC_DEFINE(HAVE_BI_RW, 1,
1848                 [struct bio has bi_rw])
1849 ])
1850 ]) # LC_HAVE_BI_RW
1851
1852 #
1853 # LC_HAVE_SUBMIT_BIO_2ARGS
1854 #
1855 # 4.4 removed an argument from submit_bio
1856 #
1857 AC_DEFUN([LC_HAVE_SUBMIT_BIO_2ARGS], [
1858 LB_CHECK_COMPILE([if submit_bio takes two arguments],
1859 have_submit_bio_2args, [
1860         #include <linux/bio.h>
1861 ],[
1862         struct bio bio;
1863         submit_bio(READ, &bio);
1864 ], [
1865         AC_DEFINE(HAVE_SUBMIT_BIO_2ARGS, 1,
1866                 [submit_bio takes two arguments])
1867 ])
1868 ]) # LC_HAVE_SUBMIT_BIO_2_ARGS
1869
1870 #
1871 # LC_HAVE_CLEAN_BDEV_ALIASES
1872 #
1873 # 4.4 unmap_underlying_metadata was replaced by clean_bdev_aliases
1874 #
1875 AC_DEFUN([LC_HAVE_CLEAN_BDEV_ALIASES], [
1876 LB_CHECK_COMPILE([if kernel has clean_bdev_aliases],
1877 have_clean_bdev_aliases, [
1878         #include <linux/buffer_head.h>
1879 ],[
1880         struct block_device bdev;
1881         clean_bdev_aliases(&bdev,1,1);
1882 ], [
1883         AC_DEFINE(HAVE_CLEAN_BDEV_ALIASES, 1,
1884                 [kernel has clean_bdev_aliases])
1885 ])
1886 ]) # LC_HAVE_CLEAN_BDEV_ALIASES
1887
1888 #
1889 # LC_HAVE_TRUNCATE_IPAGE_FINAL
1890 #
1891 # 3.14 bring truncate_inode_pages_final for evict_inode
1892 #
1893 AC_DEFUN([LC_HAVE_TRUNCATE_IPAGES_FINAL], [
1894 LB_CHECK_COMPILE([if Linux kernel has truncate_inode_pages_final],
1895 truncate_ipages_final, [
1896         #include <linux/mm.h>
1897 ],[
1898         truncate_inode_pages_final(NULL);
1899 ], [
1900         AC_DEFINE(HAVE_TRUNCATE_INODE_PAGES_FINAL, 1,
1901                 [kernel has truncate_inode_pages_final])
1902 ])
1903 ]) # LC_HAVE_TRUNCATE_IPAGES_FINAL
1904
1905 #
1906 # LC_IOPS_RENAME_WITH_FLAGS
1907 #
1908 # 3.14 has inode_operations->rename with 5 args
1909 # commit 520c8b16505236fc82daa352e6c5e73cd9870cff
1910 #
1911 AC_DEFUN([LC_IOPS_RENAME_WITH_FLAGS], [
1912 LB_CHECK_COMPILE([if 'inode_operations->rename' taken flags as argument],
1913 iops_rename_with_flags, [
1914         #include <linux/fs.h>
1915 ],[
1916         struct inode *i1 = NULL, *i2 = NULL;
1917         struct dentry *d1 = NULL, *d2 = NULL;
1918         int rc;
1919         rc = ((struct inode_operations *)0)->rename(i1, d1, i2, d2, 0);
1920 ], [
1921         AC_DEFINE(HAVE_IOPS_RENAME_WITH_FLAGS, 1,
1922                 [inode_operations->rename need flags as argument])
1923 ])
1924 ]) # LC_IOPS_RENAME_WITH_FLAGS
1925
1926 #
1927 # LC_VFS_RENAME_6ARGS
1928 #
1929 # 3.15 has vfs_rename with 6 args
1930 #
1931 AC_DEFUN([LC_VFS_RENAME_6ARGS], [
1932 LB_CHECK_COMPILE([if Linux kernel has 'vfs_rename' with 6 args],
1933 vfs_rename_6args, [
1934         #include <linux/fs.h>
1935 ],[
1936         vfs_rename(NULL, NULL, NULL, NULL, NULL, NULL);
1937 ], [
1938         AC_DEFINE(HAVE_VFS_RENAME_6ARGS, 1,
1939                 [kernel has vfs_rename with 6 args])
1940 ])
1941 ]) # LC_VFS_RENAME_6ARGS
1942
1943 #
1944 # LC_DIRECTIO_USE_ITER
1945 #
1946 # 3.16 kernel changes direct IO to use iov_iter
1947 #
1948 AC_DEFUN([LC_DIRECTIO_USE_ITER], [
1949 LB_CHECK_COMPILE([if direct IO uses iov_iter],
1950 direct_io_iter, [
1951         #include <linux/fs.h>
1952 ],[
1953         struct address_space_operations ops = { };
1954         struct iov_iter *iter = NULL;
1955         loff_t offset = 0;
1956
1957         ops.direct_IO(0, NULL, iter, offset);
1958 ],[
1959         AC_DEFINE(HAVE_DIRECTIO_ITER, 1,
1960                 [direct IO uses iov_iter])
1961 ])
1962 ]) # LC_DIRECTIO_USE_ITER
1963
1964 #
1965 # LC_HAVE_IOV_ITER_INIT_DIRECTION
1966 #
1967 #
1968 # 3.16 linux commit 71d8e532b1549a478e6a6a8a44f309d050294d00
1969 #      changed iov_iter_init api to start accepting a tag
1970 #      that defines if its a read or write operation
1971 #
1972 AC_DEFUN([LC_HAVE_IOV_ITER_INIT_DIRECTION], [
1973 tmp_flags="$EXTRA_KCFLAGS"
1974 EXTRA_KCFLAGS="-Werror"
1975 LB_CHECK_COMPILE([if 'iov_iter_init' takes a tag],
1976 iter_init, [
1977         #include <linux/uio.h>
1978         #include <linux/fs.h>
1979 ],[
1980         const struct iovec *iov = NULL;
1981
1982         iov_iter_init(NULL, READ, iov, 1, 0);
1983 ],[
1984         AC_DEFINE(HAVE_IOV_ITER_INIT_DIRECTION, 1,
1985                 [iov_iter_init handles directional tag])
1986 ])
1987 EXTRA_KCFLAGS="$tmp_flags"
1988 ]) # LC_HAVE_IOV_ITER_INIT_DIRECTION
1989
1990 #
1991 # LC_HAVE_IOV_ITER_TRUNCATE
1992 #
1993 #
1994 # 3.16 introduces a new API iov_iter_truncate()
1995 #
1996 AC_DEFUN([LC_HAVE_IOV_ITER_TRUNCATE], [
1997 tmp_flags="$EXTRA_KCFLAGS"
1998 EXTRA_KCFLAGS="-Werror"
1999 LB_CHECK_COMPILE([if 'iov_iter_truncate' exists ],
2000 iter_truncate, [
2001         #include <linux/uio.h>
2002         #include <linux/fs.h>
2003 ],[
2004         struct iov_iter *i = NULL;
2005
2006         iov_iter_truncate(i, 0);
2007 ],[
2008         AC_DEFINE(HAVE_IOV_ITER_TRUNCATE, 1, [iov_iter_truncate exists])
2009 ])
2010 EXTRA_KCFLAGS="$tmp_flags"
2011 ]) # LC_HAVE_IOV_ITER_TRUNCATE
2012
2013 #
2014 # LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
2015 #
2016 # 3.16 introduces [read|write]_iter to struct file_operations
2017 #
2018 AC_DEFUN([LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER], [
2019 LB_CHECK_COMPILE([if 'file_operations.[read|write]_iter' exist],
2020 file_function_iter, [
2021         #include <linux/fs.h>
2022 ],[
2023         ((struct file_operations *)NULL)->read_iter(NULL, NULL);
2024         ((struct file_operations *)NULL)->write_iter(NULL, NULL);
2025 ],[
2026         AC_DEFINE(HAVE_FILE_OPERATIONS_READ_WRITE_ITER, 1,
2027                 [file_operations.[read|write]_iter functions exist])
2028 ])
2029 ]) # LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
2030
2031 #
2032 # LC_HAVE_INTERVAL_BLK_INTEGRITY
2033 #
2034 # 3.17 replace sector_size with interval in struct blk_integrity
2035 #
2036 AC_DEFUN([LC_HAVE_INTERVAL_BLK_INTEGRITY], [
2037 LB_CHECK_COMPILE([if 'blk_integrity.interval' exist],
2038 interval_blk_integrity, [
2039         #include <linux/blkdev.h>
2040 ],[
2041         ((struct blk_integrity *)0)->interval = 0;
2042 ],[
2043         AC_DEFINE(HAVE_INTERVAL_BLK_INTEGRITY, 1,
2044                 [blk_integrity.interval exist])
2045 ])
2046 ]) # LC_HAVE_INTERVAL_BLK_INTEGRITY
2047
2048 #
2049 # LC_KEY_MATCH_DATA
2050 #
2051 # 3.17  replaces key_type::match with match_preparse
2052 #       and has new struct key_match_data
2053 #
2054 AC_DEFUN([LC_KEY_MATCH_DATA], [
2055 LB_CHECK_COMPILE([if struct key_match field exist],
2056 key_match, [
2057         #include <linux/key-type.h>
2058 ],[
2059         struct key_match_data data;
2060
2061         data.raw_data = NULL;
2062 ],[
2063         AC_DEFINE(HAVE_KEY_MATCH_DATA, 1,
2064                 [struct key_match_data exist])
2065 ])
2066 ]) # LC_KEY_MATCH_DATA
2067
2068 #
2069 # LC_NFS_FILLDIR_USE_CTX
2070 #
2071 # 3.18 kernel moved from void cookie to struct dir_context
2072 #
2073 AC_DEFUN([LC_NFS_FILLDIR_USE_CTX], [
2074 tmp_flags="$EXTRA_KCFLAGS"
2075 EXTRA_KCFLAGS="-Werror"
2076 LB_CHECK_COMPILE([if filldir_t uses struct dir_context],
2077 filldir_ctx, [
2078         #include <linux/fs.h>
2079 ],[
2080         int filldir(struct dir_context *ctx, const char* name,
2081                     int i, loff_t off, u64 tmp, unsigned temp)
2082         {
2083                 return 0;
2084         }
2085
2086         struct dir_context ctx = {
2087                 .actor = filldir,
2088         };
2089
2090         ctx.actor(NULL, "test", 0, (loff_t) 0, 0, 0);
2091 ],[
2092         AC_DEFINE(HAVE_FILLDIR_USE_CTX, 1,
2093                 [filldir_t needs struct dir_context as argument])
2094 ])
2095 EXTRA_KCFLAGS="$tmp_flags"
2096 ]) # LC_NFS_FILLDIR_USE_CTX
2097
2098 #
2099 # LC_PERCPU_COUNTER_INIT
2100 #
2101 # 3.18  For kernels 3.18 and after percpu_counter_init starts
2102 #       to pass a GFP_* memory allocation flag for internal
2103 #       memory allocation purposes.
2104 #
2105 AC_DEFUN([LC_PERCPU_COUNTER_INIT], [
2106 LB_CHECK_COMPILE([if percpu_counter_init uses GFP_* flag as argument],
2107 percpu_counter_init, [
2108         #include <linux/percpu_counter.h>
2109 ],[
2110         percpu_counter_init(NULL, 0, GFP_KERNEL);
2111 ],[
2112         AC_DEFINE(HAVE_PERCPU_COUNTER_INIT_GFP_FLAG, 1,
2113                 [percpu_counter_init uses GFP_* flag])
2114 ])
2115 ]) # LC_PERCPU_COUNTER_INIT
2116
2117 #
2118 # LC_KIOCB_HAS_NBYTES
2119 #
2120 # 3.19 kernel removed ki_nbytes from struct kiocb
2121 #
2122 AC_DEFUN([LC_KIOCB_HAS_NBYTES], [
2123 LB_CHECK_COMPILE([if struct kiocb has ki_nbytes field],
2124 ki_nbytes, [
2125         #include <linux/fs.h>
2126 ],[
2127         struct kiocb iocb = { };
2128
2129         iocb.ki_nbytes = 0;
2130 ],[
2131         AC_DEFINE(HAVE_KI_NBYTES, 1, [ki_nbytes field exist])
2132 ])
2133 ]) # LC_KIOCB_HAS_NBYTES
2134
2135 #
2136 # LC_HAVE_DQUOT_QC_DQBLK
2137 #
2138 # 3.19 has quotactl_ops->[sg]et_dqblk that take struct kqid and qc_dqblk
2139 # Added in commit 14bf61ffe
2140 #
2141 AC_DEFUN([LC_HAVE_DQUOT_QC_DQBLK], [
2142 tmp_flags="$EXTRA_KCFLAGS"
2143 EXTRA_KCFLAGS="-Werror"
2144 LB_CHECK_COMPILE([if 'quotactl_ops.set_dqblk' takes struct qc_dqblk],
2145 qc_dqblk, [
2146         #include <linux/fs.h>
2147         #include <linux/quota.h>
2148 ],[
2149         ((struct quotactl_ops *)0)->set_dqblk(NULL, *((struct kqid*)0), (struct qc_dqblk*)0);
2150 ],[
2151         AC_DEFINE(HAVE_DQUOT_QC_DQBLK, 1,
2152                 [quotactl_ops.set_dqblk takes struct qc_dqblk])
2153         AC_DEFINE(HAVE_DQUOT_KQID, 1,
2154                 [quotactl_ops.set_dqblk takes struct kqid])
2155 ])
2156 EXTRA_KCFLAGS="$tmp_flags"
2157 ]) # LC_HAVE_DQUOT_QC_DQBLK
2158
2159 #
2160 # LC_BACKING_DEV_INFO_REMOVAL
2161 #
2162 # 3.20 kernel removed backing_dev_info from address_space
2163 #
2164 AC_DEFUN([LC_BACKING_DEV_INFO_REMOVAL], [
2165 LB_CHECK_COMPILE([if struct address_space has backing_dev_info],
2166 backing_dev_info, [
2167         #include <linux/fs.h>
2168 ],[
2169         struct address_space mapping;
2170
2171         mapping.backing_dev_info = NULL;
2172 ],[
2173         AC_DEFINE(HAVE_BACKING_DEV_INFO, 1, [backing_dev_info exist])
2174 ])
2175 ]) # LC_BACKING_DEV_INFO_REMOVAL
2176
2177 #
2178 # LC_HAVE_BDI_CAP_MAP_COPY
2179 #
2180 # 3.20  removed mmap handling for backing devices since
2181 #       it breaks on non-MMU systems. See kernel commit
2182 #       b4caecd48005fbed3949dde6c1cb233142fd69e9
2183 #
2184 AC_DEFUN([LC_HAVE_BDI_CAP_MAP_COPY], [
2185 LB_CHECK_COMPILE([if have 'BDI_CAP_MAP_COPY'],
2186 bdi_cap_map_copy, [
2187         #include <linux/backing-dev.h>
2188 ],[
2189         struct backing_dev_info info;
2190
2191         info.capabilities = BDI_CAP_MAP_COPY;
2192 ],[
2193         AC_DEFINE(HAVE_BDI_CAP_MAP_COPY, 1,
2194                 [BDI_CAP_MAP_COPY exist])
2195 ])
2196 ]) # LC_HAVE_BDI_CAP_MAP_COPY
2197
2198 #
2199 # LC_CANCEL_DIRTY_PAGE
2200 #
2201 # 4.0.0 kernel removed cancel_dirty_page
2202 #
2203 AC_DEFUN([LC_CANCEL_DIRTY_PAGE], [
2204 LB_CHECK_COMPILE([if cancel_dirty_page still exist],
2205 cancel_dirty_page, [
2206         #include <linux/mm.h>
2207 ],[
2208         cancel_dirty_page(NULL, PAGE_SIZE);
2209 ],[
2210         AC_DEFINE(HAVE_CANCEL_DIRTY_PAGE, 1,
2211                 [cancel_dirty_page is still available])
2212 ])
2213 ]) # LC_CANCEL_DIRTY_PAGE
2214
2215 #
2216 # LC_IOV_ITER_RW
2217 #
2218 # 4.1 kernel has iov_iter_rw
2219 #
2220 AC_DEFUN([LC_IOV_ITER_RW], [
2221 LB_CHECK_COMPILE([if iov_iter_rw exist],
2222 iov_iter_rw, [
2223         #include <linux/fs.h>
2224         #include <linux/uio.h>
2225 ],[
2226         struct iov_iter *iter = NULL;
2227
2228         iov_iter_rw(iter);
2229 ],[
2230         AC_DEFINE(HAVE_IOV_ITER_RW, 1,
2231                 [iov_iter_rw exist])
2232 ])
2233 ]) # LC_IOV_ITER_RW
2234
2235 #
2236 # LC_HAVE_SYNC_READ_WRITE
2237 #
2238 # 4.1 new_sync_[read|write] no longer exported
2239 #
2240 AC_DEFUN([LC_HAVE_SYNC_READ_WRITE], [
2241 LB_CHECK_EXPORT([new_sync_read], [fs/read_write.c],
2242         [AC_DEFINE(HAVE_SYNC_READ_WRITE, 1,
2243                         [new_sync_[read|write] is exported by the kernel])])
2244 ]) # LC_HAVE_SYNC_READ_WRITE
2245
2246 #
2247 # LC_NEW_CANCEL_DIRTY_PAGE
2248 #
2249 # 4.2 kernel has new cancel_dirty_page
2250 #
2251 AC_DEFUN([LC_NEW_CANCEL_DIRTY_PAGE], [
2252 LB_CHECK_COMPILE([if cancel_dirty_page with one argument exist],
2253 new_cancel_dirty_page, [
2254         #include <linux/mm.h>
2255 ],[
2256         cancel_dirty_page(NULL);
2257 ],[
2258         AC_DEFINE(HAVE_NEW_CANCEL_DIRTY_PAGE, 1,
2259                 [cancel_dirty_page with one arguement is available])
2260 ])
2261 ]) # LC_NEW_CANCEL_DIRTY_PAGE
2262
2263 #
2264 # LC_SYMLINK_OPS_USE_NAMEIDATA
2265 #
2266 # For the 4.2+ kernels the file system internal symlink api no
2267 # longer uses struct nameidata as a argument
2268 #
2269 AC_DEFUN([LC_SYMLINK_OPS_USE_NAMEIDATA], [
2270 LB_CHECK_COMPILE([if symlink inode operations have struct nameidata argument],
2271 symlink_use_nameidata, [
2272         #include <linux/namei.h>
2273         #include <linux/fs.h>
2274 ],[
2275         struct nameidata *nd = NULL;
2276
2277         ((struct inode_operations *)0)->follow_link(NULL, nd);
2278         ((struct inode_operations *)0)->put_link(NULL, nd, NULL);
2279 ],[
2280         AC_DEFINE(HAVE_SYMLINK_OPS_USE_NAMEIDATA, 1,
2281                 [symlink inode operations need struct nameidata argument])
2282 ])
2283 ]) # LC_SYMLINK_OPS_USE_NAMEIDATA
2284
2285 #
2286 # LC_BIO_ENDIO_USES_ONE_ARG
2287 #
2288 # 4.2 kernel bio_endio now only takes one argument
2289 #
2290 AC_DEFUN([LC_BIO_ENDIO_USES_ONE_ARG], [
2291 LB_CHECK_COMPILE([if 'bio_endio' with one argument exist],
2292 bio_endio, [
2293         #include <linux/bio.h>
2294 ],[
2295         bio_endio(NULL);
2296 ],[
2297         AC_DEFINE(HAVE_BIO_ENDIO_USES_ONE_ARG, 1,
2298                 [bio_endio takes only one argument])
2299 ])
2300 ]) # LC_BIO_ENDIO_USES_ONE_ARG
2301
2302 #
2303 # LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
2304 #
2305 # 4.3 replace interval with interval_exp in 'struct blk_integrity'
2306 # 'struct blk_integrity_profile' is also added in this version,
2307 # thus use this to determine whether 'struct blk_integrity' has profile
2308 #
2309 AC_DEFUN([LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY], [
2310 LB_CHECK_COMPILE([if 'blk_integrity.interval_exp' exist],
2311 blk_integrity_interval_exp, [
2312         #include <linux/blkdev.h>
2313 ],[
2314         ((struct blk_integrity *)0)->interval_exp = 0;
2315 ],[
2316         AC_DEFINE(HAVE_INTERVAL_EXP_BLK_INTEGRITY, 1,
2317                 [blk_integrity.interval_exp exist])
2318 ])
2319 ]) # LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
2320
2321 #
2322 # LC_HAVE_LOOP_CTL_GET_FREE
2323 #
2324 # 4.x kernel have moved userspace APIs to
2325 # the separate directory and all of them
2326 # support LOOP_CTL_GET_FREE
2327 #
2328 AC_DEFUN([LC_HAVE_LOOP_CTL_GET_FREE], [
2329 LB_CHECK_FILE([$LINUX/include/linux/loop.h], [
2330         LB_CHECK_COMPILE([if have 'HAVE_LOOP_CTL_GET_FREE'],
2331         LOOP_CTL_GET_FREE, [
2332                 #include <linux/loop.h>
2333         ],[
2334                 int i;
2335
2336                 i = LOOP_CTL_GET_FREE;
2337         ],[
2338                 AC_DEFINE(HAVE_LOOP_CTL_GET_FREE, 1,
2339                         [LOOP_CTL_GET_FREE exist])
2340         ])
2341 ],[
2342         AC_DEFINE(HAVE_LOOP_CTL_GET_FREE, 1,
2343                 [kernel has LOOP_CTL_GET_FREE])
2344 ])
2345 ]) # LC_HAVE_LOOP_CTL_GET_FREE
2346
2347 #
2348 # LC_HAVE_CACHE_HEAD_HLIST
2349 #
2350 # 4.3 kernel swiched to hlist for cache_head
2351 #
2352 AC_DEFUN([LC_HAVE_CACHE_HEAD_HLIST], [
2353 LB_CHECK_COMPILE([if 'struct cache_head' has 'cache_list' field],
2354 cache_head_has_hlist, [
2355         #include <linux/sunrpc/cache.h>
2356 ],[
2357         do {} while(sizeof(((struct cache_head *)0)->cache_list));
2358 ],[
2359         AC_DEFINE(HAVE_CACHE_HEAD_HLIST, 1,
2360                 [cache_head has hlist cache_list])
2361 ])
2362 ]) # LC_HAVE_CACHE_HEAD_HLIST
2363
2364 #
2365 # LC_HAVE_XATTR_HANDLER_SIMPLIFIED
2366 #
2367 # Kernel version 4.3 commit e409de992e3ea3674393465f07cc71c948edd87a
2368 # simplified xattr_handler handling by passing in the handler pointer
2369 #
2370 AC_DEFUN([LC_HAVE_XATTR_HANDLER_SIMPLIFIED], [
2371 tmp_flags="$EXTRA_KCFLAGS"
2372 EXTRA_KCFLAGS="-Werror"
2373 LB_CHECK_COMPILE([if 'struct xattr_handler' functions pass in handler pointer],
2374 xattr_handler_simplified, [
2375         #include <linux/xattr.h>
2376 ],[
2377         struct xattr_handler handler;
2378
2379         ((struct xattr_handler *)0)->get(&handler, NULL, NULL, NULL, 0);
2380         ((struct xattr_handler *)0)->set(&handler, NULL, NULL, NULL, 0, 0);
2381 ],[
2382         AC_DEFINE(HAVE_XATTR_HANDLER_SIMPLIFIED, 1, [handler pointer is parameter])
2383 ])
2384 EXTRA_KCFLAGS="$tmp_flags"
2385 ]) # LC_HAVE_XATTR_HANDLER_SIMPLIFIED
2386
2387 #
2388 # LC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD
2389 #
2390 # 4.3 replace interval with interval_exp in 'struct blk_integrity'.
2391 #
2392 AC_DEFUN([LC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD], [
2393 LB_CHECK_COMPILE([if 'bio_integrity_payload.bip_iter' exist],
2394 bio_integrity_payload_bip_iter, [
2395         #include <linux/bio.h>
2396 ],[
2397         ((struct bio_integrity_payload *)0)->bip_iter.bi_size = 0;
2398 ],[
2399         AC_DEFINE(HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD, 1,
2400                 [bio_integrity_payload.bip_iter exist])
2401 ])
2402 ]) # LC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD
2403
2404 #
2405 # LC_BIO_INTEGRITY_PREP_FN
2406 #
2407 # Lustre kernel patch extents bio_integrity_prep to accept optional
2408 # generate/verify_fn as extra args.
2409 #
2410 AC_DEFUN([LC_BIO_INTEGRITY_PREP_FN], [
2411 LB_CHECK_COMPILE([if 'bio_integrity_prep_fn' exists],
2412 bio_integrity_prep_fn, [
2413         #include <linux/bio.h>
2414 ],[
2415         bio_integrity_prep_fn(NULL, NULL, NULL);
2416 ],[
2417         AC_DEFINE(HAVE_BIO_INTEGRITY_PREP_FN, 1,
2418                 [kernel has bio_integrity_prep_fn])
2419         AC_SUBST(PATCHED_INTEGRITY_INTF)
2420 ],[
2421         AC_SUBST(PATCHED_INTEGRITY_INTF, [#])
2422 ])
2423 ]) # LC_BIO_INTEGRITY_PREP_FN
2424
2425 #
2426 # LC_HAVE_LOCKS_LOCK_FILE_WAIT
2427 #
2428 # 4.4 kernel have moved locks API users to
2429 # locks_lock_inode_wait()
2430 #
2431 AC_DEFUN([LC_HAVE_LOCKS_LOCK_FILE_WAIT], [
2432 LB_CHECK_COMPILE([if 'locks_lock_file_wait' exists],
2433 locks_lock_file_wait, [
2434         #include <linux/fs.h>
2435 ],[
2436         locks_lock_file_wait(NULL, NULL);
2437 ],[
2438         AC_DEFINE(HAVE_LOCKS_LOCK_FILE_WAIT, 1,
2439                 [kernel has locks_lock_file_wait])
2440 ])
2441 ]) # LC_HAVE_LOCKS_LOCK_FILE_WAIT
2442
2443 #
2444 # LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
2445 #
2446 # 4.4 kernel merged type-specific data with the payload data for keys
2447 #
2448 AC_DEFUN([LC_HAVE_KEY_PAYLOAD_DATA_ARRAY], [
2449 LB_CHECK_COMPILE([if 'struct key' has 'payload.data' as an array],
2450 key_payload_data_array, [
2451         #include <linux/key.h>
2452 ],[
2453         struct key key = { };
2454
2455         key.payload.data[0] = NULL;
2456 ],[
2457         AC_DEFINE(HAVE_KEY_PAYLOAD_DATA_ARRAY, 1, [payload.data is an array])
2458 ])
2459 ]) #LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
2460
2461 #
2462 # LC_HAVE_XATTR_HANDLER_NAME
2463 #
2464 # Kernel version 4.4 commit 98e9cb5711c68223f0e4d5201b9a6add255ec550
2465 # add a name member to struct xattr_handler
2466 #
2467 AC_DEFUN([LC_HAVE_XATTR_HANDLER_NAME], [
2468 tmp_flags="$EXTRA_KCFLAGS"
2469 EXTRA_KCFLAGS="-Werror"
2470 LB_CHECK_COMPILE([if 'struct xattr_handler' has a name member],
2471 xattr_handler_name, [
2472         #include <linux/xattr.h>
2473 ],[
2474         ((struct xattr_handler *)NULL)->name = NULL;
2475 ],[
2476         AC_DEFINE(HAVE_XATTR_HANDLER_NAME, 1, [xattr_handler has a name member])
2477 ])
2478 EXTRA_KCFLAGS="$tmp_flags"
2479 ]) # LC_HAVE_XATTR_HANDLER_NAME
2480
2481 #
2482 # LC_HAVE_FILE_DENTRY
2483 #
2484 # 4.5 adds wrapper file_dentry
2485 #
2486 AC_DEFUN([LC_HAVE_FILE_DENTRY], [
2487 LB_CHECK_COMPILE([if Linux kernel has 'file_dentry'],
2488 file_dentry, [
2489         #include <linux/fs.h>
2490 ],[
2491         file_dentry(NULL);
2492 ], [
2493         AC_DEFINE(HAVE_FILE_DENTRY, 1,
2494                 [kernel has file_dentry])
2495 ])
2496 ]) # LC_HAVE_FILE_DENTRY
2497
2498 #
2499 # LC_HAVE_INODE_LOCK
2500 #
2501 # 4.5 introduced inode_lock
2502 #
2503 AC_DEFUN([LC_HAVE_INODE_LOCK], [
2504 LB_CHECK_COMPILE([if 'inode_lock' is defined],
2505 inode_lock, [
2506         #include <linux/fs.h>
2507 ],[
2508         inode_lock(NULL);
2509 ], [
2510         AC_DEFINE(HAVE_INODE_LOCK, 1,
2511                   [inode_lock is defined])
2512 ])
2513 ]) # LC_HAVE_INODE_LOCK
2514
2515 #
2516 # LC_HAVE_IOP_GET_LINK
2517 #
2518 # 4.5 vfs replaced iop->follow_link with
2519 # iop->get_link
2520 #
2521 AC_DEFUN([LC_HAVE_IOP_GET_LINK], [
2522 LB_CHECK_COMPILE([if 'iop' has 'get_link'],
2523 inode_ops_get_link, [
2524         #include <linux/fs.h>
2525 ],[
2526         struct inode_operations iop;
2527         iop.get_link = NULL;
2528 ],[
2529         AC_DEFINE(HAVE_IOP_GET_LINK, 1,
2530                 [have iop get_link])
2531 ])
2532 ]) # LC_HAVE_IOP_GET_LINK
2533
2534 #
2535 # LC_HAVE_IN_COMPAT_SYSCALL
2536 #
2537 # 4.6 renamed is_compat_task to in_compat_syscall
2538 #
2539 AC_DEFUN([LC_HAVE_IN_COMPAT_SYSCALL], [
2540 LB_CHECK_COMPILE([if 'in_compat_syscall' is defined],
2541 in_compat_syscall, [
2542         #include <linux/compat.h>
2543 ],[
2544         in_compat_syscall();
2545 ],[
2546         AC_DEFINE(HAVE_IN_COMPAT_SYSCALL, 1,
2547                 [have in_compat_syscall])
2548 ])
2549 ]) # LC_HAVE_IN_COMPAT_SYSCALL
2550
2551 #
2552 # LC_HAVE_XATTR_HANDLER_INODE_PARAM
2553 #
2554 # Kernel version 4.6 commit b296821a7c42fa58baa17513b2b7b30ae66f3336
2555 # and commit 5930122683dff58f0846b0f0405b4bd598a3ba6a added inode parameter
2556 # to xattr_handler functions
2557 #
2558 AC_DEFUN([LC_HAVE_XATTR_HANDLER_INODE_PARAM], [
2559 tmp_flags="$EXTRA_KCFLAGS"
2560 EXTRA_KCFLAGS="-Werror"
2561 LB_CHECK_COMPILE([if 'struct xattr_handler' functions have inode parameter],
2562 xattr_handler_inode_param, [
2563         #include <linux/xattr.h>
2564 ],[
2565         const struct xattr_handler handler;
2566
2567         ((struct xattr_handler *)0)->get(&handler, NULL, NULL, NULL, NULL, 0);
2568         ((struct xattr_handler *)0)->set(&handler, NULL, NULL, NULL, NULL, 0, 0);
2569 ],[
2570         AC_DEFINE(HAVE_XATTR_HANDLER_INODE_PARAM, 1, [needs inode parameter])
2571 ])
2572 EXTRA_KCFLAGS="$tmp_flags"
2573 ]) # LC_HAVE_XATTR_HANDLER_INODE_PARAM
2574
2575 #
2576 # LC_DIRECTIO_2ARGS
2577 #
2578 # Kernel version 4.7 commit c8b8e32d700fe943a935e435ae251364d016c497
2579 # direct-io: eliminate the offset argument to ->direct_IO
2580 #
2581 AC_DEFUN([LC_DIRECTIO_2ARGS], [
2582 LB_CHECK_COMPILE([if '->direct_IO()' taken 2 arguments],
2583 direct_io_2args, [
2584         #include <linux/fs.h>
2585 ],[
2586         struct address_space_operations ops = { };
2587         struct iov_iter *iter = NULL;
2588         struct kiocb *iocb = NULL;
2589         int rc;
2590
2591         rc = ops.direct_IO(iocb, iter);
2592 ],[
2593         AC_DEFINE(HAVE_DIRECTIO_2ARGS, 1,
2594                 [direct_IO need 2 arguments])
2595 ])
2596 ]) # LC_DIRECTIO_2ARGS
2597
2598 #
2599 # LC_GENERIC_WRITE_SYNC_2ARGS
2600 #
2601 # Kernel version 4.7 commit c8b8e32d700fe943a935e435ae251364d016c497
2602 # direct-io: eliminate the offset argument to ->direct_IO
2603 #
2604 AC_DEFUN([LC_GENERIC_WRITE_SYNC_2ARGS], [
2605 LB_CHECK_COMPILE([if 'generic_write_sync()' taken 2 arguments],
2606 generic_write_sync_2args, [
2607         #include <linux/fs.h>
2608 ],[
2609         struct kiocb *iocb = NULL;
2610         ssize_t rc;
2611
2612         rc = generic_write_sync(iocb, 0);
2613 ],[
2614         AC_DEFINE(HAVE_GENERIC_WRITE_SYNC_2ARGS, 1,
2615                 [generic_write_sync need 2 arguments])
2616 ])
2617 ]) # LC_GENERIC_WRITE_SYNC_2ARGS
2618
2619 #
2620 # LC_FOP_ITERATE_SHARED
2621 #
2622 # Kernel version 4.7 adds iterate_shared method to file_operations
2623 #
2624 AC_DEFUN([LC_FOP_ITERATE_SHARED], [
2625 LB_CHECK_COMPILE([if 'file_operations' has 'iterate_shared'],
2626 fop_iterate_shared, [
2627         #include <linux/fs.h>
2628 ],[
2629         struct file_operations fop;
2630         fop.iterate_shared = NULL;
2631 ],[
2632         AC_DEFINE(HAVE_FOP_ITERATE_SHARED, 1,
2633                 [file_operations has iterate_shared])
2634 ])
2635 ]) # LC_FOP_ITERATE_SHARED
2636
2637 #
2638 # LC_FOPS_ITERATE_SHARED
2639 #
2640 # 4.7 commit ae05327a00fd47c34dfe25294b359a3f3fef96e8
2641 # ext4: switch to ->iterate_shared()
2642 # this replaces ext4_dir_operations iterate with iterate_shared.
2643 # dir_relaxed_shared() was also added in this commit, so we can
2644 # use that function to verify that the ext4_dir_operations is using
2645 # iterate_shared.
2646 #
2647 AC_DEFUN([LC_FOPS_ITERATE_SHARED], [
2648 LB_CHECK_COMPILE([if ext4_dir_operations uses iterate_shared],
2649 iterate_shared, [
2650         #include <linux/fs.h>
2651 ],[
2652         ((struct file_operations *)0)->iterate_shared(NULL, NULL);
2653         dir_relax_shared(NULL);
2654 ],[
2655         AC_DEFINE(HAVE_ITERATE_SHARED, 1,
2656                 ['iterate_shared' is available])
2657 ])
2658 ]) # LC_FOPS_ITERATE_SHARED
2659
2660 #
2661 # LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
2662 #
2663 # kernel 4.20 commit 1863d77f15da0addcd293a1719fa5d3ef8cde3ca
2664 # SUNRPC: Replace the cache_detail->hash_lock with a regular spinlock
2665 #
2666 # Now that the reader functions are all RCU protected, use a regular
2667 # spinlock rather than a reader/writer lock.
2668 #
2669 AC_DEFUN([LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK], [
2670 tmp_flags="$EXTRA_KCFLAGS"
2671 EXTRA_KCFLAGS="-Werror"
2672 LB_CHECK_COMPILE([if cache_detail->hash_lock is a spinlock],
2673 hash_lock_isa_spinlock_t, [
2674         #include <linux/sunrpc/cache.h>
2675 ],[
2676         spinlock_t *lock = &(((struct cache_detail *)0)->hash_lock);
2677         spin_lock(lock);
2678 ],[
2679         AC_DEFINE(HAVE_CACHE_HASH_SPINLOCK, 1,
2680                 [if cache_detail->hash_lock is a spinlock])
2681 ])
2682 EXTRA_KCFLAGS="$tmp_flags"
2683 ]) # LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
2684
2685 #
2686 # LC_HAVE_POSIX_ACL_VALID_USER_NS
2687 #
2688 # 4.8 posix_acl_valid takes struct user_namespace
2689 #
2690 AC_DEFUN([LC_HAVE_POSIX_ACL_VALID_USER_NS], [
2691 LB_CHECK_COMPILE([if 'posix_acl_valid' takes 'struct user_namespace'],
2692 posix_acl_valid, [
2693         #include <linux/fs.h>
2694         #include <linux/posix_acl.h>
2695 ],[
2696         posix_acl_valid((struct user_namespace*)NULL, (const struct posix_acl*)NULL);
2697 ],[
2698         AC_DEFINE(HAVE_POSIX_ACL_VALID_USER_NS, 1,
2699                 [posix_acl_valid takes struct user_namespace])
2700 ])
2701 ]) # LC_HAVE_POSIX_ACL_VALID_USER_NS
2702
2703 #
2704 # LC_D_COMPARE_4ARGS
2705 #
2706 # Kernel version 4.8 commit 6fa67e707559303e086303aeecc9e8b91ef497d5
2707 # get rid of 'parent' argument of ->d_compare()
2708 #
2709 AC_DEFUN([LC_D_COMPARE_4ARGS], [
2710 LB_CHECK_COMPILE([if 'd_compare' taken 4 arguments],
2711 d_compare_4args, [
2712         #include <linux/dcache.h>
2713 ],[
2714         ((struct dentry_operations*)0)->d_compare(NULL,0,NULL,NULL);
2715 ],[
2716         AC_DEFINE(HAVE_D_COMPARE_4ARGS, 1,
2717                 [d_compare need 4 arguments])
2718 ])
2719 ]) # LC_D_COMPARE_4ARGS
2720
2721 #
2722 # LC_FULL_NAME_HASH_3ARGS
2723 #
2724 # Kernel version 4.8 commit 8387ff2577eb9ed245df9a39947f66976c6bcd02
2725 # vfs: make the string hashes salt the hash
2726 #
2727 AC_DEFUN([LC_FULL_NAME_HASH_3ARGS], [
2728 LB_CHECK_COMPILE([if 'full_name_hash' taken 3 arguments],
2729 full_name_hash_3args, [
2730         #include <linux/stringhash.h>
2731 ],[
2732         unsigned int hash;
2733         hash = full_name_hash(NULL,NULL,0);
2734 ],[
2735         AC_DEFINE(HAVE_FULL_NAME_HASH_3ARGS, 1,
2736                 [full_name_hash need 3 arguments])
2737 ])
2738 ]) # LC_FULL_NAME_HASH_3ARGS
2739
2740 #
2741 # LC_STRUCT_POSIX_ACL_XATTR
2742 #
2743 # Kernel version 4.8 commit 2211d5ba5c6c4e972ba6dbc912b2897425ea6621
2744 # posix_acl: xattr representation cleanups
2745 #
2746 AC_DEFUN([LC_STRUCT_POSIX_ACL_XATTR], [
2747 LB_CHECK_COMPILE([if 'struct posix_acl_xattr_{header,entry}' defined],
2748 struct_posix_acl_xattr, [
2749         #include <linux/fs.h>
2750         #include <linux/posix_acl_xattr.h>
2751 ],[
2752         struct posix_acl_xattr_header *h = NULL;
2753         struct posix_acl_xattr_entry  *e;
2754         e = (void *)(h + 1);
2755 ],[
2756         AC_DEFINE(HAVE_STRUCT_POSIX_ACL_XATTR, 1,
2757                 [struct posix_acl_xattr_{header,entry} defined])
2758 ])
2759 ]) # LC_STRUCT_POSIX_ACL_XATTR
2760
2761 #
2762 # LC_IOP_XATTR
2763 #
2764 # Kernel version 4.8 commit fd50ecaddf8372a1d96e0daeaac0f93cf04e4d42
2765 # removed {get,set,remove}xattr inode operations
2766 #
2767 AC_DEFUN([LC_IOP_XATTR], [
2768 LB_CHECK_COMPILE([if 'inode_operations' has {get,set,remove}xattr members],
2769 inode_ops_xattr, [
2770         #include <linux/fs.h>
2771 ],[
2772         struct inode_operations iop;
2773         iop.setxattr = NULL;
2774         iop.getxattr = NULL;
2775         iop.removexattr = NULL;
2776 ],[
2777         AC_DEFINE(HAVE_IOP_XATTR, 1,
2778                 [inode_operations has {get,set,remove}xattr members])
2779 ])
2780 ]) # LC_IOP_XATTR
2781
2782 #
2783 # LC_GROUP_INFO_GID
2784 #
2785 # Kernel version 4.9 commit 81243eacfa400f5f7b89f4c2323d0de9982bb0fb
2786 # cred: simpler, 1D supplementary groups
2787 #
2788 AC_DEFUN([LC_GROUP_INFO_GID], [
2789 LB_CHECK_COMPILE([if 'struct group_info' has member 'gid'],
2790 group_info_gid, [
2791         #include <linux/cred.h>
2792 ],[
2793         kgid_t *p;
2794         p = ((struct group_info *)0)->gid;
2795 ],[
2796         AC_DEFINE(HAVE_GROUP_INFO_GID, 1,
2797                 [struct group_info has member gid])
2798 ])
2799 ]) # LC_GROUP_INFO_GID
2800
2801 #
2802 # LC_XA_IS_VALUE
2803 # kernel 4.19-rc6 commit 3159f943aafdbacb2f94c38fdaadabf2bbde2a14
2804 # xarray: Replace exceptional entries
2805 # adds xa_is_value
2806 #
2807 AC_DEFUN([LC_XA_IS_VALUE], [
2808 LB_CHECK_COMPILE([xa_is_value exist],
2809 xa_is_value, [
2810         #include <linux/xarray.h>
2811 ],[
2812         xa_is_value(NULL);
2813 ],[
2814         AC_DEFINE(HAVE_XA_IS_VALUE, 1, [xa_is_value exist])
2815 ])
2816 ]) # LC_XA_IS_VALUE
2817
2818 #
2819 # LC_VFS_SETXATTR
2820 #
2821 # Kernel version 4.9 commit 5d6c31910bc0713e37628dc0ce677dcb13c8ccf4
2822 # added __vfs_{get,set,remove}xattr helpers
2823 #
2824 AC_DEFUN([LC_VFS_SETXATTR], [
2825 LB_CHECK_COMPILE([if '__vfs_setxattr' helper is available],
2826 vfs_setxattr, [
2827         #include <linux/xattr.h>
2828 ],[
2829         __vfs_setxattr(NULL, NULL, NULL, NULL, 0, 0);
2830 ],[
2831         AC_DEFINE(HAVE_VFS_SETXATTR, 1,
2832                 ['__vfs_setxattr is available])
2833 ])
2834 ]) # LC_VFS_SETXATTR
2835
2836 #
2837 # LC_POSIX_ACL_UPDATE_MODE
2838 #
2839 # Kernel version 4.9 commit 073931017b49d9458aa351605b43a7e34598caef
2840 # posix_acl: Clear SGID bit when setting file permissions
2841 #
2842 AC_DEFUN([LC_POSIX_ACL_UPDATE_MODE], [
2843 LB_CHECK_COMPILE([if 'posix_acl_update_mode' exists],
2844 posix_acl_update_mode, [
2845         #include <linux/fs.h>
2846         #include <linux/posix_acl.h>
2847 ],[
2848         posix_acl_update_mode(NULL, NULL, NULL);
2849 ],[
2850         AC_DEFINE(HAVE_POSIX_ACL_UPDATE_MODE, 1,
2851                 ['posix_acl_update_mode' is available])
2852 ])
2853 ]) # LC_POSIX_ACL_UPDATE_MODE
2854
2855 #
2856 # LC_IOP_GENERIC_READLINK
2857 #
2858 # Kernel version 4.10 commit dfeef68862edd7d4bafe68ef7aeb5f658ef24bb5
2859 # removed generic_readlink from individual file systems
2860 #
2861 AC_DEFUN([LC_IOP_GENERIC_READLINK], [
2862 LB_CHECK_COMPILE([if 'generic_readlink' still exist],
2863 inode_ops_readlink, [
2864         #include <linux/fs.h>
2865 ],[
2866         struct inode_operations iop;
2867         iop.readlink = generic_readlink;
2868 ],[
2869         AC_DEFINE(HAVE_IOP_GENERIC_READLINK, 1,
2870                 [generic_readlink has been removed])
2871 ])
2872 ]) # LC_IOP_GENERIC_READLINK
2873
2874 #
2875 # LC_HAVE_VM_FAULT_ADDRESS
2876 #
2877 # Kernel version 4.10 commit 1a29d85eb0f19b7d8271923d8917d7b4f5540b3e
2878 # removed virtual_address field. Need to use address field instead
2879 #
2880 AC_DEFUN([LC_HAVE_VM_FAULT_ADDRESS], [
2881 LB_CHECK_COMPILE([if 'struct vm_fault' replaced virtual_address with address field],
2882 vm_fault_address, [
2883         #include <linux/mm.h>
2884 ],[
2885         struct vm_fault vmf;
2886         vmf.address = NULL;
2887 ],[
2888         AC_DEFINE(HAVE_VM_FAULT_ADDRESS, 1,
2889                 [virtual_address has been replaced by address field])
2890 ])
2891 ]) # LC_HAVE_VM_FAULT_ADDRESS
2892
2893 #
2894 # LC_INODEOPS_ENHANCED_GETATTR
2895 #
2896 # Kernel version 4.11 commit a528d35e8bfcc521d7cb70aaf03e1bd296c8493f
2897 # expanded getattr to be able to get more stat information.
2898 #
2899 AC_DEFUN([LC_INODEOPS_ENHANCED_GETATTR], [
2900 LB_CHECK_COMPILE([if 'inode_operations' getattr member can gather advance stats],
2901 getattr_path, [
2902         #include <linux/fs.h>
2903 ],[
2904         struct path path;
2905
2906         ((struct inode_operations *)1)->getattr(&path, NULL, 0, 0);
2907 ],[
2908         AC_DEFINE(HAVE_INODEOPS_ENHANCED_GETATTR, 1,
2909                 [inode_operations .getattr member function can gather advance stats])
2910 ])
2911 ]) # LC_INODEOPS_ENHANCED_GETATTR
2912
2913 #
2914 # LC_VM_OPERATIONS_REMOVE_VMF_ARG
2915 #
2916 # Kernel version 4.11 commit 11bac80004499ea59f361ef2a5516c84b6eab675
2917 # removed struct vm_area_struct as an argument for vm_operations since
2918 # in the same kernel version struct vma_area_struct was folded into
2919 # struct vm_fault.
2920 #
2921 AC_DEFUN([LC_VM_OPERATIONS_REMOVE_VMF_ARG], [
2922 LB_CHECK_COMPILE([if 'struct vm_operations' removed struct vm_area_struct],
2923 vm_operations_no_vm_area_struct, [
2924         #include <linux/mm.h>
2925 ],[
2926         struct vm_fault vmf;
2927
2928         ((struct vm_operations_struct *)0)->fault(&vmf);
2929         ((struct vm_operations_struct *)0)->page_mkwrite(&vmf);
2930 ],[
2931         AC_DEFINE(HAVE_VM_OPS_USE_VM_FAULT_ONLY, 1,
2932                 ['struct vm_operations' remove struct vm_area_struct argument])
2933 ])
2934 ]) # LC_VM_OPERATIONS_REMOVE_VMF_ARG
2935
2936 #
2937 # LC_HAVE_KEY_USAGE_REFCOUNT
2938 #
2939 # Kernel version 4.11 commit fff292914d3a2f1efd05ca71c2ba72a3c663201e
2940 # converted key.usage from atomic_t to refcount_t.
2941 #
2942 AC_DEFUN([LC_HAVE_KEY_USAGE_REFCOUNT], [
2943 LB_CHECK_COMPILE([if 'key.usage' is refcount_t],
2944 key_usage_refcount, [
2945         #include <linux/key.h>
2946 ],[
2947         struct key key = { };
2948
2949         refcount_read(&key.usage);
2950 ],[
2951         AC_DEFINE(HAVE_KEY_USAGE_REFCOUNT, 1, [key.usage is of type refcount_t])
2952 ])
2953 ]) #LC_HAVE_KEY_USAGE_REFCOUNT
2954
2955 #
2956 # LC_HAVE_CRYPTO_MAX_ALG_NAME_128
2957 #
2958 # Kernel version 4.11 commit f437a3f477cce402dbec6537b29e9e33962c9f73
2959 # switched CRYPTO_MAX_ALG_NAME from 64 to 128.
2960 #
2961 AC_DEFUN([LC_HAVE_CRYPTO_MAX_ALG_NAME_128], [
2962 LB_CHECK_COMPILE([if 'CRYPTO_MAX_ALG_NAME' is 128],
2963 crypto_max_alg_name, [
2964         #include <linux/crypto.h>
2965 ],[
2966         #if CRYPTO_MAX_ALG_NAME != 128
2967         exit(1);
2968         #endif
2969 ],[
2970         AC_DEFINE(HAVE_CRYPTO_MAX_ALG_NAME_128, 1,
2971                 ['CRYPTO_MAX_ALG_NAME' is 128])
2972 ])
2973 ]) # LC_HAVE_CRYPTO_MAX_ALG_NAME_128
2974
2975 #
2976 # Kernel version 4.12 commit 47f38c539e9a42344ff5a664942075bd4df93876
2977 # CURRENT_TIME is not 64 bit time safe so it was replaced with
2978 # current_time()
2979 #
2980 AC_DEFUN([LC_CURRENT_TIME], [
2981 LB_CHECK_COMPILE([if CURRENT_TIME has been replaced with current_time],
2982 current_time, [
2983         #include <linux/fs.h>
2984 ],[
2985         struct iattr attr;
2986
2987         attr.ia_atime = current_time(NULL);
2988 ],[
2989         AC_DEFINE(HAVE_CURRENT_TIME, 1,
2990                 [current_time() has replaced CURRENT_TIME])
2991 ])
2992 ]) # LIBCFS_CURRENT_TIME
2993
2994 #
2995 # LC_SUPER_SETUP_BDI_NAME
2996 #
2997 # Kernel version 4.12 commit 9594caf216dc0fe3e318b34af0127276db661241
2998 # unified bdi handling
2999 #
3000 AC_DEFUN([LC_SUPER_SETUP_BDI_NAME], [
3001 LB_CHECK_COMPILE([if 'super_setup_bdi_name' exist],
3002 super_setup_bdi_name, [
3003         #include <linux/fs.h>
3004 ],[
3005         super_setup_bdi_name(NULL, "lustre");
3006 ],[
3007         AC_DEFINE(HAVE_SUPER_SETUP_BDI_NAME, 1,
3008                 ['super_setup_bdi_name' is available])
3009 ])
3010 ]) # LC_SUPER_SETUP_BDI_NAME
3011
3012 #
3013 # LC_BI_STATUS
3014 #
3015 # 4.12 replace bi_error to bi_status
3016 #
3017 AC_DEFUN([LC_BI_STATUS], [
3018 LB_CHECK_COMPILE([if 'bi_status' exist],
3019 bi_status, [
3020         #include <linux/blk_types.h>
3021 ],[
3022         ((struct bio *)0)->bi_status = 0;
3023 ],[
3024         AC_DEFINE(HAVE_BI_STATUS, 1,
3025                 ['bi_status' is available])
3026 ])
3027 ]) # LC_BI_STATUS
3028
3029 #
3030 # LC_BIO_INTEGRITY_ENABLED
3031 #
3032 # 4.13 removed bio_integrity_enabled
3033 #
3034 AC_DEFUN([LC_BIO_INTEGRITY_ENABLED], [
3035 LB_CHECK_COMPILE([if 'bio_integrity_enabled' exist],
3036 bio_integrity_enabled, [
3037         #include <linux/bio.h>
3038 ],[
3039         bio_integrity_enabled(NULL);
3040 ],[
3041         AC_DEFINE(HAVE_BIO_INTEGRITY_ENABLED, 1,
3042                 ['bio_integrity_enabled' is available])
3043 ])
3044 ]) # LC_BIO_INTEGRITY_ENABLED
3045
3046 #
3047 # LC_PAGEVEC_INIT_ONE_PARAM
3048 #
3049 # 4.14 pagevec_init takes one parameter
3050 #
3051 AC_DEFUN([LC_PAGEVEC_INIT_ONE_PARAM], [
3052 LB_CHECK_COMPILE([if 'pagevec_init' takes one parameter],
3053 pagevec_init, [
3054         #include <linux/pagevec.h>
3055 ],[
3056         pagevec_init(NULL);
3057 ],[
3058         AC_DEFINE(HAVE_PAGEVEC_INIT_ONE_PARAM, 1,
3059                 ['pagevec_init' takes one parameter])
3060 ])
3061 ]) # LC_PAGEVEC_INIT_ONE_PARAM
3062
3063 #
3064 # LC_BI_BDEV
3065 #
3066 # 4.14 replaced bi_bdev to bi_disk
3067 #
3068 AC_DEFUN([LC_BI_BDEV], [
3069 LB_CHECK_COMPILE([if 'bi_bdev' exist],
3070 bi_bdev, [
3071         #include <linux/bio.h>
3072 ],[
3073         ((struct bio *)0)->bi_bdev = NULL;
3074 ],[
3075         AC_DEFINE(HAVE_BI_BDEV, 1,
3076                 ['bi_bdev' is available])
3077 ])
3078 ]) # LC_BI_BDEV
3079
3080 #
3081 # LC_I_PAGES
3082 #
3083 # kernel 4.17 commit b93b016313b3ba8003c3b8bb71f569af91f19fc7
3084 #
3085 AC_DEFUN([LC_I_PAGES], [
3086 LB_CHECK_COMPILE([if struct address_space has i_pages],
3087 i_pages, [
3088         #include <linux/fs.h>
3089 ],[
3090         struct address_space mapping = {};
3091         void *i_pages;
3092
3093         i_pages = &mapping.i_pages;
3094 ],[
3095         AC_DEFINE(HAVE_I_PAGES, 1,
3096                 [struct address_space has i_pages])
3097 ])
3098 ]) # LC_I_PAGES
3099
3100 #
3101 # LC_VM_FAULT_T
3102 #
3103 # kernel 4.17 commit 3d3539018d2cbd12e5af4a132636ee7fd8d43ef0
3104 # mm: create the new vm_fault_t type
3105 #
3106 AC_DEFUN([LC_VM_FAULT_T], [
3107 LB_CHECK_COMPILE([if vm_fault_t type exists],
3108 vm_fault_t, [
3109         #include <linux/mm_types.h>
3110 ],[
3111         vm_fault_t x = VM_FAULT_SIGBUS;
3112         (void)x
3113 ],[
3114         AC_DEFINE(HAVE_VM_FAULT_T, 1,
3115                 [if vm_fault_t type exists])
3116 ])
3117 ]) # LC_VM_FAULT_T
3118
3119 #
3120 # LC_INODE_TIMESPEC64
3121 #
3122 # kernel 4.18 commit 95582b00838837fc07e042979320caf917ce3fe6
3123 # inode timestamps switched to timespec64
3124 #
3125 AC_DEFUN([LC_INODE_TIMESPEC64], [
3126 LB_CHECK_COMPILE([if inode timestamps are struct timespec64],
3127 inode_timespec64, [
3128         #include <linux/fs.h>
3129 ],[
3130         struct inode inode = {};
3131         struct timespec64 ts = {};
3132
3133         inode.i_atime = ts;
3134 ],[
3135         AC_DEFINE(HAVE_INODE_TIMESPEC64, 1,
3136                 [inode times are using timespec64])
3137 ])
3138 ]) # LC_INODE_TIMESPEC64
3139
3140 #
3141 # LC_HAS_LINUX_SELINUX_ENABLED
3142 #
3143 # kernel 5.1 commit 3d252529480c68bfd6a6774652df7c8968b28e41
3144 # SELinux: Remove unused selinux_is_enabled
3145 #
3146 AC_DEFUN([LC_HAS_LINUX_SELINUX_ENABLED], [
3147 tmp_flags="$EXTRA_KCFLAGS"
3148 EXTRA_KCFLAGS="-Werror"
3149 LB_CHECK_COMPILE([if linux/selinux.h exists],
3150 selinux_is_enabled, [
3151         #include <linux/selinux.h>
3152 ],[
3153         bool has_selinux = selinux_is_enabled();
3154         (void)has_selinux;
3155 ],[
3156         AC_DEFINE(HAVE_LINUX_SELINUX_IS_ENABLED, 1,
3157                 [if linux/selinux.h exists])
3158 ])
3159 EXTRA_KCFLAGS="$tmp_flags"
3160 ]) # LC_HAS_LINUX_SELINUX_ENABLED
3161
3162 #
3163 # LC_PROG_LINUX
3164 #
3165 # Lustre linux kernel checks
3166 #
3167 AC_DEFUN([LC_PROG_LINUX], [
3168         AC_MSG_NOTICE([Lustre kernel checks
3169 ==============================================================================])
3170
3171         LC_CONFIG_PINGER
3172         LC_CONFIG_CHECKSUM
3173         LC_CONFIG_FLOCK
3174         LC_CONFIG_HEALTH_CHECK_WRITE
3175         LC_CONFIG_LRU_RESIZE
3176
3177         LC_GLIBC_SUPPORT_FHANDLES
3178         LC_CONFIG_GSS
3179         LC_OPENSSL_SSK
3180         LC_OPENSSL_GETSEPOL
3181
3182         # 2.6.32
3183         LC_BLK_QUEUE_MAX_SEGMENTS
3184
3185         # 2.6.33
3186         LC_HAVE_XATTR_HANDLER_FLAGS
3187
3188         # 2.6.34
3189         LC_HAVE_DQUOT_FS_DISK_QUOTA
3190         LC_HAVE_DQUOT_SUSPEND
3191         LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE
3192
3193         # 2.6.35, 3.0.0
3194         LC_FILE_FSYNC
3195         LC_EXPORT_SIMPLE_SETATTR
3196         LC_EXPORT_TRUNCATE_COMPLETE_PAGE
3197
3198         # 2.6.36
3199         LC_FS_STRUCT_RWLOCK
3200         LC_SBOPS_EVICT_INODE
3201
3202         # 2.6.37
3203         LC_KERNEL_LOCKED
3204         LC_FS_STRUCT_SEQCOUNT
3205
3206         # 2.6.38
3207         LC_BLKDEV_GET_BY_DEV
3208         LC_GENERIC_PERMISSION
3209         LC_DCACHE_LOCK
3210         LC_INODE_I_RCU
3211         LC_D_COMPARE_7ARGS
3212         LC_D_DELETE_CONST
3213         LC_HAVE_BLK_PLUG
3214
3215         # 2.6.39
3216         LC_HAVE_FHANDLE_SYSCALLS
3217         LC_HAVE_FSTYPE_MOUNT
3218         LC_IOP_TRUNCATE
3219         LC_HAVE_INODE_OWNER_OR_CAPABLE
3220         LC_HAVE_SECURITY_IINITSEC
3221
3222         # 3.0
3223         LC_DIRTY_INODE_WITH_FLAG
3224         LC_SETNS
3225
3226         # 3.1
3227         LC_LM_XXX_LOCK_MANAGER_OPS
3228         LC_INODE_DIO_WAIT
3229         LC_IOP_GET_ACL
3230         LC_FILE_LLSEEK_SIZE
3231         LC_INODE_PERMISION_2ARGS
3232         LC_RADIX_EXCEPTION_ENTRY
3233         LC_HAVE_LOOP_CTL_GET_FREE
3234
3235         # 3.2
3236         LC_HAVE_PROTECT_I_NLINK
3237
3238         # 3.3
3239         LC_HAVE_MIGRATE_HEADER
3240         LC_MIGRATEPAGE_4ARGS
3241         LC_SUPEROPS_USE_DENTRY
3242         LC_INODEOPS_USE_UMODE_T
3243         LC_HAVE_CACHE_REGISTER
3244
3245         # 3.4
3246         LC_HAVE_D_MAKE_ROOT
3247         LC_KMAP_ATOMIC_HAS_1ARG
3248
3249         # 3.5
3250         LC_HAVE_CLEAR_INODE
3251         LC_HAVE_ENCODE_FH_PARENT
3252         LC_FILE_LLSEEK_SIZE_5ARG
3253
3254         # 3.6
3255         LC_DATA_FOR_LLITE_IS_LIST
3256         LC_DENTRY_OPEN_USE_PATH
3257         LC_HAVE_IOP_ATOMIC_OPEN
3258         LC_HAVE_SB_START_WRITE
3259
3260         # 3.7
3261         LC_HAVE_POSIXACL_USER_NS
3262
3263         # 3.8
3264         LC_HAVE_FILE_F_INODE
3265         LC_HAVE_FILE_INODE
3266         LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS
3267
3268         # 3.9
3269         LC_HAVE_HLIST_FOR_EACH_3ARG
3270         LC_HAVE_BIO_END_SECTOR
3271         LC_HAVE_IS_SXID
3272
3273         # 3.10
3274         LC_HAVE_REMOVE_PROC_SUBTREE
3275         LC_HAVE_PROC_REMOVE
3276         LC_HAVE_PROJECT_QUOTA
3277         LC_HAVE_SECURITY_DENTRY_INIT_SECURITY
3278
3279         # 3.11
3280         LC_INVALIDATE_RANGE
3281         LC_HAVE_DIR_CONTEXT
3282         LC_D_COMPARE_5ARGS
3283         LC_HAVE_DCOUNT
3284         LC_HAVE_DENTRY_D_U_D_ALIAS
3285         LC_HAVE_DENTRY_D_CHILD
3286         LC_PID_NS_FOR_CHILDREN
3287
3288         # 3.12
3289         LC_OLDSIZE_TRUNCATE_PAGECACHE
3290         LC_PTR_ERR_OR_ZERO_MISSING
3291         LC_KIOCB_KI_LEFT
3292         LC_INIT_LIST_HEAD_RCU
3293
3294         # 3.13
3295         LC_VFS_RENAME_5ARGS
3296         LC_VFS_UNLINK_3ARGS
3297
3298         # 3.14
3299         LC_HAVE_BVEC_ITER
3300         LC_HAVE_TRUNCATE_IPAGES_FINAL
3301         LC_IOPS_RENAME_WITH_FLAGS
3302         LC_IOP_SET_ACL
3303
3304         # 3.15
3305         LC_VFS_RENAME_6ARGS
3306
3307         # 3.16
3308         LC_DIRECTIO_USE_ITER
3309         LC_HAVE_IOV_ITER_INIT_DIRECTION
3310         LC_HAVE_IOV_ITER_TRUNCATE
3311         LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
3312
3313         # 3.17
3314         LC_HAVE_INTERVAL_BLK_INTEGRITY
3315         LC_KEY_MATCH_DATA
3316
3317         # 3.18
3318         LC_PERCPU_COUNTER_INIT
3319         LC_NFS_FILLDIR_USE_CTX
3320
3321         # 3.19
3322         LC_KIOCB_HAS_NBYTES
3323         LC_HAVE_DQUOT_QC_DQBLK
3324
3325         # 3.20
3326         LC_BACKING_DEV_INFO_REMOVAL
3327         LC_HAVE_BDI_CAP_MAP_COPY
3328
3329         # 4.0.0
3330         LC_CANCEL_DIRTY_PAGE
3331
3332         # 4.1.0
3333         LC_IOV_ITER_RW
3334         LC_HAVE_SYNC_READ_WRITE
3335
3336         # 4.2
3337         LC_NEW_CANCEL_DIRTY_PAGE
3338         LC_BIO_ENDIO_USES_ONE_ARG
3339         LC_SYMLINK_OPS_USE_NAMEIDATA
3340
3341         # 4.3
3342         LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
3343         LC_HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD
3344         LC_HAVE_CACHE_HEAD_HLIST
3345         LC_HAVE_XATTR_HANDLER_SIMPLIFIED
3346
3347         # 4.4
3348         LC_HAVE_LOCKS_LOCK_FILE_WAIT
3349         LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
3350         LC_HAVE_XATTR_HANDLER_NAME
3351         LC_HAVE_BI_CNT
3352         LC_HAVE_BI_RW
3353         LC_HAVE_SUBMIT_BIO_2ARGS
3354         LC_HAVE_CLEAN_BDEV_ALIASES
3355
3356         # 4.5
3357         LC_HAVE_FILE_DENTRY
3358
3359         # 4.5
3360         LC_HAVE_INODE_LOCK
3361         LC_HAVE_IOP_GET_LINK
3362
3363         # 4.6
3364         LC_HAVE_IN_COMPAT_SYSCALL
3365         LC_HAVE_XATTR_HANDLER_INODE_PARAM
3366
3367         # 4.7
3368         LC_DIRECTIO_2ARGS
3369         LC_GENERIC_WRITE_SYNC_2ARGS
3370         LC_FOPS_ITERATE_SHARED
3371
3372         # 4.8
3373         LC_HAVE_POSIX_ACL_VALID_USER_NS
3374         LC_D_COMPARE_4ARGS
3375         LC_FULL_NAME_HASH_3ARGS
3376         LC_STRUCT_POSIX_ACL_XATTR
3377         LC_IOP_XATTR
3378
3379         # 4.9
3380         LC_GROUP_INFO_GID
3381         LC_VFS_SETXATTR
3382         LC_POSIX_ACL_UPDATE_MODE
3383
3384         # 4.10
3385         LC_IOP_GENERIC_READLINK
3386         LC_HAVE_VM_FAULT_ADDRESS
3387
3388         # 4.11
3389         LC_INODEOPS_ENHANCED_GETATTR
3390         LC_VM_OPERATIONS_REMOVE_VMF_ARG
3391         LC_HAVE_KEY_USAGE_REFCOUNT
3392         LC_HAVE_CRYPTO_MAX_ALG_NAME_128
3393
3394         # 4.12
3395         LC_CURRENT_TIME
3396         LC_SUPER_SETUP_BDI_NAME
3397         LC_BI_STATUS
3398
3399         # 4.13
3400         LC_BIO_INTEGRITY_ENABLED
3401
3402         # 4.14
3403         LC_PAGEVEC_INIT_ONE_PARAM
3404         LC_BI_BDEV
3405
3406         # 4.17
3407         LC_VM_FAULT_T
3408         LC_I_PAGES
3409
3410         # 4.18
3411         LC_INODE_TIMESPEC64
3412         LC_XA_IS_VALUE
3413
3414         # 4.20
3415         LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
3416
3417         # 5.1
3418         LC_HAS_LINUX_SELINUX_ENABLED
3419
3420         # kernel patch to extend integrity interface
3421         LC_BIO_INTEGRITY_PREP_FN
3422
3423         #
3424         AS_IF([test "x$enable_server" != xno], [
3425                 LC_STACK_SIZE
3426                 LC_QUOTA64
3427                 LC_QUOTA_CONFIG
3428         ])
3429 ]) # LC_PROG_LINUX
3430
3431 #
3432 # LC_CONFIG_CLIENT
3433 #
3434 # Check whether to build the client side of Lustre
3435 #
3436 AC_DEFUN([LC_CONFIG_CLIENT], [
3437 AC_MSG_CHECKING([whether to build Lustre client support])
3438 AC_ARG_ENABLE([client],
3439         AC_HELP_STRING([--disable-client],
3440                 [disable Lustre client support]),
3441         [], [enable_client="yes"])
3442 AC_MSG_RESULT([$enable_client])
3443 ]) # LC_CONFIG_CLIENT
3444
3445 #
3446 # --enable-mpitests
3447 #
3448 AC_DEFUN([LB_CONFIG_MPITESTS], [
3449 AC_ARG_ENABLE([mpitests],
3450         AC_HELP_STRING([--enable-mpitests=<yes|no|mpicc wrapper>],
3451                        [include mpi tests]), [
3452                 enable_mpitests="yes"
3453                 case $enableval in
3454                 yes)
3455                         MPICC_WRAPPER="mpicc"
3456                         MPI_BIN=$(eval which $MPICC_WRAPPER | xargs dirname)
3457                         ;;
3458                 no)
3459                         enable_mpitests="no"
3460                         MPI_BIN=""
3461                         ;;
3462                 *)
3463                         MPICC_WRAPPER=$enableval
3464                         MPI_BIN=$(eval echo $MPICC_WRAPPER | xargs dirname)
3465                         ;;
3466                 esac
3467         ], [
3468                 enable_mpitests="yes"
3469                 MPICC_WRAPPER="mpicc"
3470                 MPI_BIN=$(eval which $MPICC_WRAPPER | xargs dirname)
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(MPI_BIN)
3490         AC_SUBST(MPICC_WRAPPER)
3491 ]) # LB_CONFIG_MPITESTS
3492
3493 #
3494 # LC_CONFIG_QUOTA
3495 #
3496 # whether to enable quota support global control
3497 #
3498 AC_DEFUN([LC_CONFIG_QUOTA], [
3499 AC_MSG_CHECKING([whether to enable quota support global control])
3500 AC_ARG_ENABLE([quota],
3501         AC_HELP_STRING([--enable-quota],
3502                 [enable quota support]),
3503         [], [enable_quota="yes"])
3504 AS_IF([test "x$enable_quota" = xyes],
3505         [AC_MSG_RESULT([yes])],
3506         [AC_MSG_RESULT([no])])
3507 ]) # LC_CONFIG_QUOTA
3508
3509 #
3510 # LC_QUOTA
3511 #
3512 AC_DEFUN([LC_QUOTA], [
3513 #check global
3514 LC_CONFIG_QUOTA
3515 #check for utils
3516 AS_IF([test "x$enable_quota" != xno -a "x$enable_utils" != xno], [
3517         AC_CHECK_HEADER([sys/quota.h],
3518                 [AC_DEFINE(HAVE_SYS_QUOTA_H, 1,
3519                         [Define to 1 if you have <sys/quota.h>.])],
3520                 [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
3521 ])
3522 ]) # LC_QUOTA
3523
3524 #
3525 # LC_CONFIG_NODEMAP_PROC_DEBUG
3526 #
3527 # enable nodemap proc file debugging
3528 #
3529 AC_DEFUN([LC_NODEMAP_PROC_DEBUG], [
3530 AC_MSG_CHECKING([whether to enable nodemap proc debug])
3531 AC_ARG_ENABLE([nodemap_proc_debug],
3532         AC_HELP_STRING([--enable-nodemap-proc-debug],
3533                 [enable nodemap proc debug]),
3534         [], [enable_nodemap_proc_debug="no"])
3535 AC_MSG_RESULT([$enable_nodemap_proc_debug])
3536 AS_IF([test "x$enable_nodemap_proc_debug" != xno],
3537         [AC_DEFINE(NODEMAP_PROC_DEBUG, 1,
3538                 [enable nodemap proc debug support])])
3539 ]) # LC_NODEMAP_PROC_DEBUG
3540
3541 #
3542 # LC_OSD_ADDON
3543 #
3544 # configure support for optional OSD implementation
3545 #
3546 AC_DEFUN([LC_OSD_ADDON], [
3547 AC_MSG_CHECKING([whether to use OSD addon])
3548 AC_ARG_WITH([osd],
3549         AC_HELP_STRING([--with-osd=path],
3550                 [set path to optional osd]),
3551         [
3552         case "$with_osd" in
3553         no)
3554                 ENABLEOSDADDON=0
3555                 ;;
3556         *)
3557                 OSDADDON="$with_osd"
3558                 ENABLEOSDADDON=1
3559                 ;;
3560         esac
3561         ], [
3562                 ENABLEOSDADDON=0
3563         ])
3564 AS_IF([test $ENABLEOSDADDON -eq 0], [
3565         AC_MSG_RESULT([no])
3566         OSDADDON=""
3567 ], [
3568         OSDMODNAME=$(basename $OSDADDON)
3569         AS_IF([test -e $LUSTRE/$OSDMODNAME], [
3570                 AC_MSG_RESULT([can't link])
3571                 OSDADDON=""
3572         ], [ln -s $OSDADDON $LUSTRE/$OSDMODNAME], [
3573                 AC_MSG_RESULT([$OSDMODNAME])
3574                 OSDADDON="subdir-m += $OSDMODNAME"
3575         ], [
3576                 AC_MSG_RESULT([can't link])
3577                 OSDADDON=""
3578         ])
3579 ])
3580 AC_SUBST(OSDADDON)
3581 ]) # LC_OSD_ADDON
3582
3583 #
3584 # LC_CONFIGURE
3585 #
3586 # other configure checks
3587 #
3588 AC_DEFUN([LC_CONFIGURE], [
3589 AC_MSG_NOTICE([Lustre core checks
3590 ==============================================================================])
3591
3592 AS_IF([test $target_cpu == "i686" -o $target_cpu == "x86_64"],
3593         [CFLAGS="$CFLAGS -Wall -Werror"])
3594
3595 # maximum MDS thread count
3596 LC_MDS_MAX_THREADS
3597
3598 # lustre/utils/gss/gss_util.c
3599 # lustre/utils/gss/gssd_proc.c
3600 # lustre/utils/gss/krb5_util.c
3601 # lustre/utils/llog_reader.c
3602 # lustre/utils/create_iam.c
3603 # lustre/utils/libiam.c
3604 AC_CHECK_HEADERS([netdb.h endian.h])
3605 AC_CHECK_FUNCS([gethostbyname])
3606
3607 # lustre/utils/llverdev.c
3608 AC_CHECK_HEADERS([blkid/blkid.h])
3609
3610 # lustre/utils/llverfs.c
3611 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
3612
3613 # lustre/utils/lfs.c
3614 AS_IF([test "$enable_dist" = "no"], [
3615                 AC_CHECK_LIB([z], [crc32], [
3616                                  AC_CHECK_HEADER([zlib.h], [], [
3617                                                  AC_MSG_ERROR([zlib.h not found.])])
3618                                  ], [
3619                                  AC_MSG_ERROR([
3620                 zlib library not found. Please install zlib development package.])
3621                 ])
3622 ])
3623
3624 SELINUX=""
3625 AC_CHECK_LIB([selinux], [is_selinux_enabled],
3626         [AC_CHECK_HEADERS([selinux/selinux.h],
3627                         [SELINUX="-lselinux"
3628                         AC_DEFINE([HAVE_SELINUX], 1,
3629                                 [support for selinux ])],
3630                         [AC_MSG_WARN([
3631
3632 No libselinux-devel package found, unable to build selinux enabled tools
3633 ])
3634 ])],
3635         [AC_MSG_WARN([
3636
3637 No selinux package found, unable to build selinux enabled tools
3638 ])
3639 ])
3640 AC_SUBST(SELINUX)
3641
3642 # Super safe df
3643 AC_MSG_CHECKING([whether to report minimum OST free space])
3644 AC_ARG_ENABLE([mindf],
3645         AC_HELP_STRING([--enable-mindf],
3646                 [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
3647         [], [enable_mindf="no"])
3648 AC_MSG_RESULT([$enable_mindf])
3649 AS_IF([test "$enable_mindf" = "yes"],
3650         [AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])])
3651
3652 AC_MSG_CHECKING([whether to randomly failing memory alloc])
3653 AC_ARG_ENABLE([fail_alloc],
3654         AC_HELP_STRING([--disable-fail-alloc],
3655                 [disable randomly alloc failure]),
3656         [], [enable_fail_alloc="yes"])
3657 AC_MSG_RESULT([$enable_fail_alloc])
3658 AS_IF([test "x$enable_fail_alloc" != xno],
3659         [AC_DEFINE([RANDOM_FAIL_ALLOC], 1,
3660                 [enable randomly alloc failure])])
3661
3662 AC_MSG_CHECKING([whether to check invariants (expensive cpu-wise)])
3663 AC_ARG_ENABLE([invariants],
3664         AC_HELP_STRING([--enable-invariants],
3665                 [enable invariant checking (cpu intensive)]),
3666         [], [enable_invariants="no"])
3667 AC_MSG_RESULT([$enable_invariants])
3668 AS_IF([test "x$enable_invariants" = xyes],
3669         [AC_DEFINE([CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK], 1,
3670                 [enable invariant checking])])
3671
3672 AC_MSG_CHECKING([whether to track references with lu_ref])
3673 AC_ARG_ENABLE([lu_ref],
3674         AC_HELP_STRING([--enable-lu_ref],
3675                 [enable lu_ref reference tracking code]),
3676         [], [enable_lu_ref="no"])
3677 AC_MSG_RESULT([$enable_lu_ref])
3678 AS_IF([test "x$enable_lu_ref" = xyes],
3679         [AC_DEFINE([USE_LU_REF], 1,
3680                 [enable lu_ref reference tracking code])])
3681
3682 AC_MSG_CHECKING([whether to enable page state tracking])
3683 AC_ARG_ENABLE([pgstate-track],
3684         AC_HELP_STRING([--enable-pgstate-track],
3685                 [enable page state tracking]),
3686         [], [enable_pgstat_track="no"])
3687 AC_MSG_RESULT([$enable_pgstat_track])
3688 AS_IF([test "x$enable_pgstat_track" = xyes],
3689         [AC_DEFINE([CONFIG_DEBUG_PAGESTATE_TRACKING], 1,
3690                 [enable page state tracking code])])
3691
3692 PKG_PROG_PKG_CONFIG
3693 AC_MSG_CHECKING([systemd unit file directory])
3694 AC_ARG_WITH([systemdsystemunitdir],
3695         [AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
3696                 [Directory for systemd service files])],
3697         [], [with_systemdsystemunitdir=auto])
3698 AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"],
3699         [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
3700         AS_IF([test "x$def_systemdsystemunitdir" = "x"],
3701                 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
3702                 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
3703                 with_systemdsystemunitdir=no],
3704         [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
3705 AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
3706         [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
3707 AC_MSG_RESULT([$with_systemdsystemunitdir])
3708
3709 AC_MSG_CHECKING([bash-completion directory])
3710 AC_ARG_WITH([bash-completion-dir],
3711         AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
3712                 [Install the bash auto-completion script in this directory.]),
3713         [],
3714         [with_bash_completion_dir=yes])
3715 AS_IF([test "x$with_bash_completion_dir" = "xyes"], [
3716         BASH_COMPLETION_DIR="`pkg-config --variable=completionsdir bash-completion`"
3717         AS_IF([test "x$BASH_COMPLETION_DIR" = "x"], [
3718                 [BASH_COMPLETION_DIR="$datadir/bash-completion/completions"]
3719         ])
3720 ], [
3721         BASH_COMPLETION_DIR="$with_bash_completion_dir"
3722 ])
3723 AC_SUBST([BASH_COMPLETION_DIR])
3724 AC_MSG_RESULT([$BASH_COMPLETION_DIR])
3725 ]) # LC_CONFIGURE
3726
3727 #
3728 # LC_CONDITIONALS
3729 #
3730 # AM_CONDITIONALS for lustre
3731 #
3732 AC_DEFUN([LC_CONDITIONALS], [
3733 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
3734 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
3735 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
3736 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
3737 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
3738 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
3739 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
3740 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
3741 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
3742 AM_CONDITIONAL(GSS_SSK, test x$enable_ssk = xyes)
3743 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
3744 AM_CONDITIONAL(HAVE_SYSTEMD, test "x$with_systemdsystemunitdir" != "xno")
3745 AM_CONDITIONAL(ENABLE_BASH_COMPLETION, test "x$with_bash_completion_dir" != "xno")
3746 AM_CONDITIONAL(XATTR_HANDLER, test "x$lb_cv_compile_xattr_handler_flags" = xyes)
3747 AM_CONDITIONAL(SELINUX, test "$SELINUX" = "-lselinux")
3748 AM_CONDITIONAL(GETSEPOL, test x$enable_getsepol = xyes)
3749 ]) # LC_CONDITIONALS
3750
3751 #
3752 # LC_CONFIG_FILES
3753 #
3754 # files that should be generated with AC_OUTPUT
3755 #
3756 AC_DEFUN([LC_CONFIG_FILES],
3757 [AC_CONFIG_FILES([
3758 lustre/Makefile
3759 lustre/autoMakefile
3760 lustre/autoconf/Makefile
3761 lustre/conf/Makefile
3762 lustre/conf/resource/Makefile
3763 lustre/contrib/Makefile
3764 lustre/doc/Makefile
3765 lustre/include/Makefile
3766 lustre/include/lustre/Makefile
3767 lustre/include/uapi/linux/lustre/Makefile
3768 lustre/kernel_patches/targets/4.18-rhel8.1.target
3769 lustre/kernel_patches/targets/4.18-rhel8.target
3770 lustre/kernel_patches/targets/3.10-rhel7.8.target
3771 lustre/kernel_patches/targets/3.10-rhel7.7.target
3772 lustre/kernel_patches/targets/3.10-rhel7.6.target
3773 lustre/kernel_patches/targets/3.10-rhel7.5.target
3774 lustre/kernel_patches/targets/4.14-rhel7.5.target
3775 lustre/kernel_patches/targets/4.14-rhel7.6.target
3776 lustre/kernel_patches/targets/2.6-rhel6.9.target
3777 lustre/kernel_patches/targets/2.6-rhel6.8.target
3778 lustre/kernel_patches/targets/2.6-rhel6.7.target
3779 lustre/kernel_patches/targets/2.6-rhel6.6.target
3780 lustre/kernel_patches/targets/2.6-rhel6.target
3781 lustre/kernel_patches/targets/2.6-rhel5.target
3782 lustre/kernel_patches/targets/2.6-sles11.target
3783 lustre/kernel_patches/targets/3.0-sles11.target
3784 lustre/kernel_patches/targets/3.0-sles11sp3.target
3785 lustre/kernel_patches/targets/3.0-sles11sp4.target
3786 lustre/kernel_patches/targets/3.12-sles12.target
3787 lustre/kernel_patches/targets/4.4-sles12.target
3788 lustre/kernel_patches/targets/4.4-sles12sp3.target
3789 lustre/kernel_patches/targets/4.12-sles12sp4.target
3790 lustre/kernel_patches/targets/2.6-fc11.target
3791 lustre/kernel_patches/targets/2.6-fc12.target
3792 lustre/kernel_patches/targets/2.6-fc15.target
3793 lustre/kernel_patches/targets/3.x-fc18.target
3794 lustre/ldlm/Makefile
3795 lustre/fid/Makefile
3796 lustre/fid/autoMakefile
3797 lustre/llite/Makefile
3798 lustre/llite/autoMakefile
3799 lustre/lov/Makefile
3800 lustre/lov/autoMakefile
3801 lustre/mdc/Makefile
3802 lustre/mdc/autoMakefile
3803 lustre/lmv/Makefile
3804 lustre/lmv/autoMakefile
3805 lustre/lfsck/Makefile
3806 lustre/lfsck/autoMakefile
3807 lustre/mdt/Makefile
3808 lustre/mdt/autoMakefile
3809 lustre/mdd/Makefile
3810 lustre/mdd/autoMakefile
3811 lustre/fld/Makefile
3812 lustre/fld/autoMakefile
3813 lustre/obdclass/Makefile
3814 lustre/obdclass/autoMakefile
3815 lustre/obdecho/Makefile
3816 lustre/obdecho/autoMakefile
3817 lustre/ofd/Makefile
3818 lustre/ofd/autoMakefile
3819 lustre/osc/Makefile
3820 lustre/osc/autoMakefile
3821 lustre/ost/Makefile
3822 lustre/ost/autoMakefile
3823 lustre/osd-ldiskfs/Makefile
3824 lustre/osd-ldiskfs/autoMakefile
3825 lustre/osd-zfs/Makefile
3826 lustre/osd-zfs/autoMakefile
3827 lustre/mgc/Makefile
3828 lustre/mgc/autoMakefile
3829 lustre/mgs/Makefile
3830 lustre/mgs/autoMakefile
3831 lustre/target/Makefile
3832 lustre/ptlrpc/Makefile
3833 lustre/ptlrpc/autoMakefile
3834 lustre/ptlrpc/gss/Makefile
3835 lustre/ptlrpc/gss/autoMakefile
3836 lustre/quota/Makefile
3837 lustre/quota/autoMakefile
3838 lustre/scripts/Makefile
3839 lustre/scripts/systemd/Makefile
3840 lustre/tests/Makefile
3841 lustre/tests/mpi/Makefile
3842 lustre/tests/kernel/Makefile
3843 lustre/tests/kernel/autoMakefile
3844 lustre/utils/Makefile
3845 lustre/utils/gss/Makefile
3846 lustre/osp/Makefile
3847 lustre/osp/autoMakefile
3848 lustre/lod/Makefile
3849 lustre/lod/autoMakefile
3850 ])
3851 ]) # LC_CONFIG_FILES