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