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