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