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