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