Whamcloud - gitweb
8e04313220a24b71bdc09186ce72082fdbdab9b4
[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_RMTCLIENT
219 #
220 dnl FIXME
221 dnl the AES symbol usually tied with arch, e.g. CRYPTO_AES_586
222 dnl FIXME
223 AC_DEFUN([LC_CONFIG_RMTCLIENT], [
224 LB_CHECK_CONFIG_IM([CRYPTO_AES], [],
225         [AC_MSG_WARN([
226
227 Lustre remote client require that CONFIG_CRYPTO_AES is enabled in your kernel.
228 ])])
229 ]) # LC_CONFIG_RMTCLIENT
230
231 #
232 # LC_CONFIG_GSS_KEYRING
233 #
234 # default 'auto', tests for dependencies, if found, enables;
235 # only called if gss is enabled
236 #
237 AC_DEFUN([LC_CONFIG_GSS_KEYRING], [
238 AC_MSG_CHECKING([whether to enable gss keyring backend])
239 AC_ARG_ENABLE([gss_keyring],
240         [AC_HELP_STRING([--disable-gss-keyring],
241                 [disable gss keyring backend])],
242         [], [enable_gss_keyring="auto"])
243 AC_MSG_RESULT([$enable_gss_keyring])
244 AS_IF([test "x$enable_gss_keyring" != xno], [
245         LB_CHECK_CONFIG_IM([KEYS], [], [
246                 gss_keyring_conf_test="fail"
247                 AC_MSG_WARN([GSS keyring backend requires that CONFIG_KEYS be enabled in your kernel.])])
248
249         AC_CHECK_LIB([keyutils], [keyctl_search], [], [
250                 gss_keyring_conf_test="fail"
251                 AC_MSG_WARN([GSS keyring backend requires libkeyutils])])
252
253         AS_IF([test "x$gss_keyring_conf_test" != xfail], [
254                 AC_DEFINE([HAVE_GSS_KEYRING], [1],
255                         [Define this if you enable gss keyring backend])
256                 enable_gss_keyring="yes"
257         ], [
258                 AS_IF([test "x$enable_gss_keyring" = xyes], [
259                         AC_MSG_ERROR([Cannot enable gss_keyring. See above for details.])
260                 ])
261         ])
262 ])
263 ]) # LC_CONFIG_GSS_KEYRING
264
265 #
266 # LC_HAVE_CRED_TGCRED
267 #
268 # rhel7 struct cred has no member tgcred
269 #
270 AC_DEFUN([LC_HAVE_CRED_TGCRED], [
271 LB_CHECK_COMPILE([if 'struct cred' has member 'tgcred'],
272 cred_tgcred, [
273         #include <linux/cred.h>
274 ],[
275         ((struct cred *)0)->tgcred = NULL;
276 ],[
277         AC_DEFINE(HAVE_CRED_TGCRED, 1,
278                 [struct cred has member tgcred])
279 ])
280 ]) # LC_HAVE_CRED_TGCRED
281
282 #
283 # LC_KEY_TYPE_INSTANTIATE_2ARGS
284 #
285 # rhel7 key_type->instantiate takes 2 args (struct key, struct key_preparsed_payload)
286 #
287 AC_DEFUN([LC_KEY_TYPE_INSTANTIATE_2ARGS], [
288 LB_CHECK_COMPILE([if 'key_type->instantiate' has two args],
289 key_type_instantiate_2args, [
290         #include <linux/key-type.h>
291 ],[
292         ((struct key_type *)0)->instantiate(0, NULL);
293 ],[
294         AC_DEFINE(HAVE_KEY_TYPE_INSTANTIATE_2ARGS, 1,
295                 [key_type->instantiate has two args])
296 ])
297 ]) # LC_KEY_TYPE_INSTANTIATE_2ARGS
298
299 #
300 # LC_CONFIG_SUNRPC
301 #
302 AC_DEFUN([LC_CONFIG_SUNRPC], [
303 LB_CHECK_CONFIG_IM([SUNRPC], [], [
304         AS_IF([test "x$sunrpc_required" = xyes], [
305                 AC_MSG_ERROR([
306
307 kernel SUNRPC support is required by using GSS.
308 ])
309         ])])
310 ]) # LC_CONFIG_SUNRPC
311
312 #
313 # LC_CONFIG_GSS (default 'auto' (tests for dependencies, if found, enables))
314 #
315 # Build gss and related tools of Lustre. Currently both kernel and user space
316 # parts are depend on linux platform.
317 #
318 AC_DEFUN([LC_CONFIG_GSS], [
319 AC_MSG_CHECKING([whether to enable gss/krb5 support])
320 AC_ARG_ENABLE([gss],
321         [AC_HELP_STRING([--enable-gss], [enable gss/krb5 support])],
322         [], [enable_gss="auto"])
323 AC_MSG_RESULT([$enable_gss])
324
325 AS_IF([test "x$enable_gss" != xno], [
326         LC_CONFIG_GSS_KEYRING
327         LC_HAVE_CRED_TGCRED
328         LC_KEY_TYPE_INSTANTIATE_2ARGS
329         sunrpc_required=$enable_gss
330         LC_CONFIG_SUNRPC
331         sunrpc_required="no"
332
333         LB_CHECK_CONFIG_IM([CRYPTO_MD5], [],
334                 [AC_MSG_WARN([kernel MD5 support is recommended by using GSS.])])
335         LB_CHECK_CONFIG_IM([CRYPTO_SHA1], [],
336                 [AC_MSG_WARN([kernel SHA1 support is recommended by using GSS.])])
337         LB_CHECK_CONFIG_IM([CRYPTO_SHA256], [],
338                 [AC_MSG_WARN([kernel SHA256 support is recommended by using GSS.])])
339         LB_CHECK_CONFIG_IM([CRYPTO_SHA512], [],
340                 [AC_MSG_WARN([kernel SHA512 support is recommended by using GSS.])])
341
342         require_krb5=$enable_gss
343         AC_KERBEROS_V5
344         require_krb5="no"
345
346         AS_IF([test -n "$KRBDIR"], [
347                 gss_conf_test="success"
348         ], [
349                 gss_conf_test="failure"
350         ])
351
352         AS_IF([test "x$gss_conf_test" = xsuccess], [
353                 AC_DEFINE([HAVE_GSS], [1], [Define this is if you enable gss])
354                 enable_gss="yes"
355         ], [
356                 enable_gss="no"
357         ])
358 ])
359 ]) # LC_CONFIG_GSS
360
361 #
362 # LC_INODE_PERMISION_2ARGS
363 #
364 # up to v2.6.27 had a 3 arg version (inode, mask, nameidata)
365 # v2.6.27->v2.6.37 had a 2 arg version (inode, mask)
366 # v2.6.37->v3.0 had a 3 arg version (inode, mask, nameidata)
367 # v3.1 onward have a 2 arg version (inode, mask)
368 #
369 AC_DEFUN([LC_INODE_PERMISION_2ARGS], [
370 LB_CHECK_COMPILE([if 'inode_operations->permission' has two args],
371 inode_ops_permission_2args, [
372         #include <linux/fs.h>
373 ],[
374         struct inode *inode __attribute__ ((unused));
375
376         inode = NULL;
377         inode->i_op->permission(NULL, 0);
378 ],[
379         AC_DEFINE(HAVE_INODE_PERMISION_2ARGS, 1,
380                 [inode_operations->permission has two args])
381 ])
382 ]) # LC_INODE_PERMISION_2ARGS
383
384 #
385 # LC_BLK_QUEUE_MAX_SEGMENTS
386 #
387 # 2.6.32 replaces 2 functions blk_queue_max_phys_segments and blk_queue_max_hw_segments by blk_queue_max_segments
388 #
389 AC_DEFUN([LC_BLK_QUEUE_MAX_SEGMENTS], [
390 LB_CHECK_COMPILE([if 'blk_queue_max_segments' is defined],
391 blk_queue_max_segments, [
392         #include <linux/blkdev.h>
393 ],[
394         blk_queue_max_segments(NULL, 0);
395 ],[
396         AC_DEFINE(HAVE_BLK_QUEUE_MAX_SEGMENTS, 1,
397                 [blk_queue_max_segments is defined])
398 ])
399 ]) # LC_BLK_QUEUE_MAX_SEGMENTS
400
401 #
402 # LC_HAVE_DQUOT_FS_DISK_QUOTA
403 #
404 # 2.6.34 has quotactl_ops->[sg]et_dqblk that take struct fs_disk_quota
405 #
406 AC_DEFUN([LC_HAVE_DQUOT_FS_DISK_QUOTA], [
407 tmp_flags="$EXTRA_KCFLAGS"
408 EXTRA_KCFLAGS="-Werror"
409 LB_CHECK_COMPILE([if 'quotactl_ops.set_dqblk' takes struct fs_disk_quota],
410 fs_disk_quota, [
411         #include <linux/fs.h>
412         #include <linux/quota.h>
413 ],[
414         ((struct quotactl_ops *)0)->set_dqblk(NULL, 0, 0, (struct fs_disk_quota*)0);
415 ],[
416         AC_DEFINE(HAVE_DQUOT_FS_DISK_QUOTA, 1,
417                 [quotactl_ops.set_dqblk takes struct fs_disk_quota])
418 ],[
419         LB_CHECK_COMPILE([if 'quotactl_ops.set_dqblk' takes struct kqid & fs_disk_quota],
420         kqid_fs_disk_quota, [
421                 #include <linux/fs.h>
422                 #include <linux/quota.h>
423         ],[
424                 ((struct quotactl_ops *)0)->set_dqblk((struct super_block*)0, *((struct kqid*)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                 AC_DEFINE(HAVE_DQUOT_KQID, 1,
429                         [quotactl_ops.set_dqblk takes struct kqid])
430         ])
431 ])
432 EXTRA_KCFLAGS="$tmp_flags"
433 ]) # LC_HAVE_DQUOT_FS_DISK_QUOTA
434
435 #
436 # LC_HAVE_DQUOT_SUSPEND
437 #
438 # 2.6.34 has renamed dquot options to dquot_*, check for dquot_suspend
439 #
440 AC_DEFUN([LC_HAVE_DQUOT_SUSPEND], [
441 LB_CHECK_COMPILE([if 'dquot_suspend' is defined],
442 dquot_suspend, [
443         #include <linux/quotaops.h>
444 ],[
445         dquot_suspend(NULL, -1);
446 ],[
447         AC_DEFINE(HAVE_DQUOT_SUSPEND, 1, [dquot_suspend is defined])
448 ])
449 ]) # LC_HAVE_DQUOT_SUSPEND
450
451 #
452 # LC_QUOTA64
453 #
454 # Check if kernel has been patched for 64-bit quota limits support.
455 # The upstream version of this patch in RHEL6 2.6.32 kernels introduces
456 # the constant QFMT_VFS_V1 in include/linux/quota.h, so we can check for
457 # that in the absence of quotaio_v1.h in the kernel headers.
458 #
459 AC_DEFUN([LC_QUOTA64], [
460 tmp_flags="$EXTRA_KCFLAGS"
461 EXTRA_KCFLAGS="-I$LINUX/fs"
462 LB_CHECK_COMPILE([if kernel has 64-bit quota limits support],
463 quota64, [
464         #include <linux/kernel.h>
465         #include <linux/fs.h>
466         #if defined(HAVE_FS_QUOTA_QUOTAIO_H)
467         #include <quota/quotaio_v2.h>
468         struct v2r1_disk_dqblk dqblk_r1;
469         #else
470         #include <linux/quota.h>
471         int ver = QFMT_VFS_V1;
472         #endif
473 ], [], [
474         AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
475 ],[
476         LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],
477                 [AC_MSG_ERROR([You have got no 64-bit kernel quota support.])])
478 ])
479 EXTRA_KCFLAGS=$tmp_flags
480 ]) # LC_QUOTA64
481
482 #
483 # LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE
484 #
485 # 2.6.34 adds __add_wait_queue_exclusive
486 #
487 AC_DEFUN([LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE], [
488 LB_CHECK_COMPILE([if '__add_wait_queue_exclusive' exists],
489 __add_wait_queue_exclusive, [
490         #include <linux/wait.h>
491 ],[
492         wait_queue_head_t queue;
493         wait_queue_t      wait;
494         __add_wait_queue_exclusive(&queue, &wait);
495 ],[
496         AC_DEFINE(HAVE___ADD_WAIT_QUEUE_EXCLUSIVE, 1,
497                   [__add_wait_queue_exclusive exists])
498 ])
499 ]) # LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE
500
501 #
502 # LC_FS_STRUCT_RWLOCK
503 #
504 # 2.6.36 fs_struct.lock use spinlock instead of rwlock.
505 #
506 AC_DEFUN([LC_FS_STRUCT_RWLOCK], [
507 LB_CHECK_COMPILE([if 'fs_struct.lock' use rwlock],
508 fs_struct_rwlock, [
509         #include <asm/atomic.h>
510         #include <linux/spinlock.h>
511         #include <linux/fs_struct.h>
512 ],[
513         ((struct fs_struct *)0)->lock = (rwlock_t){ 0 };
514 ],[
515         AC_DEFINE(HAVE_FS_STRUCT_RWLOCK, 1, [fs_struct.lock use rwlock])
516 ])
517 ]) # LC_FS_STRUCT_RWLOCK
518
519 #
520 # LC_SBOPS_EVICT_INODE
521 #
522 # 2.6.36 super_operations add evict_inode method. it hybird of
523 # delete_inode & clear_inode.
524 #
525 AC_DEFUN([LC_SBOPS_EVICT_INODE], [
526 LB_CHECK_COMPILE([if 'super_operations.evict_inode' exist],
527 super_ops_evict_inode, [
528         #include <linux/fs.h>
529 ],[
530         ((struct super_operations *)0)->evict_inode(NULL);
531 ],[
532         AC_DEFINE(HAVE_SBOPS_EVICT_INODE, 1,
533                 [super_operations.evict_inode() is exist in kernel])
534 ])
535 ]) # LC_SBOPS_EVICT_INODE
536
537 #
538 # LC_FILE_FSYNC
539 #
540 # 2.6.35 file_operations.fsync taken 2 arguments.
541 # 3.0.0 file_operations.fsync takes 4 arguments.
542 #
543 AC_DEFUN([LC_FILE_FSYNC], [
544 LB_CHECK_COMPILE([if 'file_operations.fsync' takes 4 arguments],
545 file_ops_fsync_4args, [
546         #include <linux/fs.h>
547 ],[
548         ((struct file_operations *)0)->fsync(NULL, 0, 0, 0);
549 ],[
550         AC_DEFINE(HAVE_FILE_FSYNC_4ARGS, 1,
551                 [file_operations.fsync takes 4 arguments])
552 ],[
553         LB_CHECK_COMPILE([if 'file_operations.fsync' takes 2 arguments],
554         file_ops_fsync_2args, [
555                 #include <linux/fs.h>
556         ],[
557                 ((struct file_operations *)0)->fsync(NULL, 0);
558         ],[
559                 AC_DEFINE(HAVE_FILE_FSYNC_2ARGS, 1,
560                         [file_operations.fsync takes 2 arguments])
561         ])
562 ])
563 ]) # LC_FILE_FSYNC
564
565 #
566 # LC_KERNEL_LOCKED
567 #
568 # 2.6.37 remove kernel_locked
569 #
570 AC_DEFUN([LC_KERNEL_LOCKED], [
571 LB_CHECK_COMPILE([if 'kernel_locked' is defined],
572 kernel_locked, [
573         #include <linux/smp_lock.h>
574 ],[
575         kernel_locked();
576 ],[
577         AC_DEFINE(HAVE_KERNEL_LOCKED, 1, [kernel_locked is defined])
578 ])
579 ]) # LC_KERNEL_LOCKED
580
581 #
582 # LC_D_COMPARE_7ARGS
583 #
584 # 2.6.38 dentry_operations.d_compare() taken 7 arguments.
585 #
586 AC_DEFUN([LC_D_COMPARE_7ARGS], [
587 LB_CHECK_COMPILE([if 'dentry_operations.d_compare()' taken 7 arguments],
588 dentry_ops_d_compare_7arg, [
589         #include <linux/dcache.h>
590 ],[
591         ((struct dentry_operations*)0)->d_compare(NULL,NULL,NULL,NULL,0,NULL,NULL);
592 ],[
593         AC_DEFINE(HAVE_D_COMPARE_7ARGS, 1, [d_compare need 7 arguments])
594 ])
595 ]) # LC_D_COMPARE_7ARGS
596
597 #
598 # LC_D_DELETE_CONST
599 #
600 # 2.6.38 dentry_operations.d_delete() defined 'const' for 1st parameter.
601 #
602 AC_DEFUN([LC_D_DELETE_CONST], [
603 tmp_flags="$EXTRA_KCFLAGS"
604 EXTRA_KCFLAGS="-Werror"
605 LB_CHECK_COMPILE([if 'dentry_operations.d_delete()' has const declare on first parameter],
606 dentry_ops_d_delete_1st_const, [
607         #include <linux/dcache.h>
608 ],[
609         const struct dentry *d = NULL;
610         ((struct dentry_operations*)0)->d_delete(d);
611 ],[
612         AC_DEFINE(HAVE_D_DELETE_CONST, const,
613                 [d_delete first parameter declared const])
614 ],[
615         AC_DEFINE(HAVE_D_DELETE_CONST, [],
616                 [d_delete first parameter declared is not const])
617 ])
618 EXTRA_KCFLAGS="$tmp_flags"
619 ]) # LC_D_DELETE_CONST
620
621 #
622 # LC_DCACHE_LOCK
623 #
624 # 2.6.38 dcache_lock removed. rcu-walk committed.
625 #
626 AC_DEFUN([LC_DCACHE_LOCK], [
627 LB_CHECK_COMPILE([if 'dcache_lock' is exist],
628 dcache_lock, [
629         #include <linux/dcache.h>
630 ],[
631         spin_lock(&dcache_lock);
632 ],[
633         AC_DEFINE(HAVE_DCACHE_LOCK, 1,
634                 [dcache_lock is exist])
635 ])
636 ]) # LC_DCACHE_LOCK
637
638 #
639 # LC_INODE_I_RCU
640 #
641 # 2.6.38 inode.i_rcu added.
642 #
643 AC_DEFUN([LC_INODE_I_RCU], [
644 LB_CHECK_COMPILE([if 'inode.i_rcu' exists],
645 inode_i_rcu, [
646         #include <linux/fs.h>
647 ],[
648         struct inode ino;
649         struct rcu_head rcu = {};
650         ino.i_rcu = rcu;
651 ],[
652         AC_DEFINE(HAVE_INODE_I_RCU, 1,
653                 [inode.i_rcu exists])
654 ])
655 ]) # LC_INODE_I_RCU
656
657 #
658 # LC_BLKDEV_GET_BY_DEV
659 #
660 # 2.6.38 export blkdev_get_by_dev
661 #
662 AC_DEFUN([LC_BLKDEV_GET_BY_DEV], [
663 LB_CHECK_EXPORT([blkdev_get_by_dev], [fs/block_dev.c],
664         [AC_DEFINE(HAVE_BLKDEV_GET_BY_DEV, 1,
665                 [blkdev_get_by_dev is exported by the kernel])])
666 ]) # LC_BLKDEV_GET_BY_DEV
667
668 #
669 # LC_EXPORT_SIMPLE_SETATTR
670 #
671 # 2.6.38 export simple_setattr
672 #
673 AC_DEFUN([LC_EXPORT_SIMPLE_SETATTR], [
674 LB_CHECK_EXPORT([simple_setattr], [fs/libfs.c],
675         [AC_DEFINE(HAVE_SIMPLE_SETATTR, 1,
676                 [simple_setattr is exported by the kernel])])
677 ]) # LC_EXPORT_SIMPLE_SETATTR
678
679 #
680 # LC_IOP_TRUNCATE
681 #
682 # truncate callback removed since 2.6.39
683 #
684 AC_DEFUN([LC_IOP_TRUNCATE], [
685 LB_CHECK_COMPILE([if 'inode_operations' has '.truncate' member function],
686 inode_ops_truncate, [
687         #include <linux/fs.h>
688 ],[
689         ((struct inode_operations *)0)->truncate(NULL);
690 ],[
691         AC_DEFINE(HAVE_INODEOPS_TRUNCATE, 1,
692                 [inode_operations has .truncate member function])
693 ])
694 ]) # LC_IOP_TRUNCATE
695
696 #
697 # LC_REQUEST_QUEUE_UNPLUG_FN
698 #
699 # 2.6.39 remove unplug_fn from request_queue.
700 #
701 AC_DEFUN([LC_REQUEST_QUEUE_UNPLUG_FN], [
702 LB_CHECK_COMPILE([if 'request_queue' has 'unplug_fn' field],
703 request_queue_unplug_fn, [
704         #include <linux/blkdev.h>
705 ],[
706         do {} while(sizeof(((struct request_queue *)0)->unplug_fn));
707 ],[
708         AC_DEFINE(HAVE_REQUEST_QUEUE_UNPLUG_FN, 1,
709                 [request_queue has unplug_fn field])
710 ])
711 ]) # LC_REQUEST_QUEUE_UNPLUG_FN
712
713 #
714 # LC_HAVE_FSTYPE_MOUNT
715 #
716 # 2.6.39 replace get_sb with mount in struct file_system_type
717 #
718 AC_DEFUN([LC_HAVE_FSTYPE_MOUNT], [
719 LB_CHECK_COMPILE([if 'file_system_type' has 'mount' field],
720 file_system_type_mount, [
721         #include <linux/fs.h>
722 ],[
723         struct file_system_type fst;
724         void *i = (void *) fst.mount;
725 ],[
726         AC_DEFINE(HAVE_FSTYPE_MOUNT, 1,
727                 [struct file_system_type has mount field])
728 ])
729 ]) # LC_HAVE_FSTYPE_MOUNT
730
731 #
732 # LC_HAVE_FHANDLE_SYSCALLS
733 #
734 # 2.6.39 The open_by_handle_at() and name_to_handle_at() system calls were
735 # added to Linux kernel 2.6.39.
736 # Check if client supports these functions
737 #
738 AC_DEFUN([LC_HAVE_FHANDLE_SYSCALLS], [
739 LB_CHECK_CONFIG_IM([FHANDLE],[
740         AC_DEFINE(HAVE_FHANDLE_SYSCALLS, 1,
741                 [kernel supports fhandles and related syscalls])
742         ])
743 ]) # LC_HAVE_FHANDLE_SYSCALLS
744
745 #
746 # LC_HAVE_INODE_OWNER_OR_CAPABLE
747 #
748 # 2.6.39 renames is_owner_or_cap to inode_owner_or_capable
749 #
750 AC_DEFUN([LC_HAVE_INODE_OWNER_OR_CAPABLE], [
751 LB_CHECK_COMPILE([if 'inode_owner_or_capable' exist],
752 inode_owner_or_capable, [
753         #include <linux/fs.h>
754 ],[
755         inode_owner_or_capable(NULL);
756 ],[
757         AC_DEFINE(HAVE_INODE_OWNER_OR_CAPABLE, 1,
758                 [inode_owner_or_capable exist])
759 ])
760 ]) # LC_HAVE_INODE_OWNER_OR_CAPABLE
761
762 #
763 # LC_DIRTY_INODE_WITH_FLAG
764 #
765 # 3.0 dirty_inode() has a flag parameter
766 # see kernel commit aa38572954ade525817fe88c54faebf85e5a61c0
767 #
768 AC_DEFUN([LC_DIRTY_INODE_WITH_FLAG], [
769 LB_CHECK_COMPILE([if 'dirty_inode' super_operation takes flag],
770 dirty_inode_super_operation_flag, [
771         #include <linux/fs.h>
772 ],[
773         struct inode *inode;
774         inode->i_sb->s_op->dirty_inode(NULL, 0);
775 ],[
776         AC_DEFINE(HAVE_DIRTY_INODE_HAS_FLAG, 1,
777                 [dirty_inode super_operation takes flag])
778 ])
779 ]) # LC_DIRTY_INODE_WITH_FLAG
780
781 #
782 # LC_GENERIC_PERMISSION
783 #
784 # 2.6.38 generic_permission taken 4 parameters.
785 # in fact, it means rcu-walk aware permission bring.
786 #
787 # 3.1 generic_permission taken 2 parameters.
788 # see kernel commit 2830ba7f34ebb27c4e5b8b6ef408cd6d74860890
789 #
790 AC_DEFUN([LC_GENERIC_PERMISSION], [
791 LB_CHECK_COMPILE([if 'generic_permission' take 2 arguments],
792 generic_permission_2args, [
793         #include <linux/fs.h>
794 ],[
795         generic_permission(NULL, 0);
796 ],[
797         AC_DEFINE(HAVE_GENERIC_PERMISSION_2ARGS, 1,
798                 [generic_permission taken 2 arguments])
799 ],[
800         LB_CHECK_COMPILE([if 'generic_permission' take 4 arguments],
801         generic_permission_4args, [
802                 #include <linux/fs.h>
803         ],[
804                 generic_permission(NULL, 0, 0, NULL);
805         ],[
806                 AC_DEFINE(HAVE_GENERIC_PERMISSION_4ARGS, 1,
807                         [generic_permission taken 4 arguments])
808         ])
809 ])
810 ]) # LC_GENERIC_PERMISSION
811
812 #
813 # LC_LM_XXX_LOCK_MANAGER_OPS
814 #
815 # 3.1 renames lock-manager ops(lock_manager_operations) from fl_xxx to lm_xxx
816 # see kernel commit 8fb47a4fbf858a164e973b8ea8ef5e83e61f2e50
817 #
818 AC_DEFUN([LC_LM_XXX_LOCK_MANAGER_OPS], [
819 LB_CHECK_COMPILE([if 'lock-manager' ops renamed to 'lm_xxx'],
820 lock_manager_ops_lm_xxx, [
821         #include <linux/fs.h>
822 ],[
823         struct lock_manager_operations lm_ops;
824         lm_ops.lm_compare_owner = NULL;
825 ],[
826         AC_DEFINE(HAVE_LM_XXX_LOCK_MANAGER_OPS, 1,
827                 [lock-manager ops renamed to lm_xxx])
828 ])
829 ]) # LC_LM_XXX_LOCK_MANAGER_OPS
830
831 #
832 # LC_INODE_DIO_WAIT
833 #
834 # 3.1 kills inode->i_alloc_sem, use i_dio_count and inode_dio_wait
835 #     instead.
836 # see kernel commit bd5fe6c5eb9c548d7f07fe8f89a150bb6705e8e3
837 #
838 AC_DEFUN([LC_INODE_DIO_WAIT], [
839 LB_CHECK_COMPILE([if 'inode->i_alloc_sem' is killed and use inode_dio_wait],
840 inode_dio_wait, [
841         #include <linux/fs.h>
842 ],[
843         inode_dio_wait((struct inode *)0);
844 ],[
845         AC_DEFINE(HAVE_INODE_DIO_WAIT, 1,
846                 [inode->i_alloc_sem is killed and use inode_dio_wait])
847 ])
848 ]) # LC_INODE_DIO_WAIT
849
850 #
851 # LC_IOP_GET_ACL
852 #
853 # 3.1 adds get_acl method to inode_operations to read ACL from disk.
854 # see kernel commit 4e34e719e457f2e031297175410fc0bd4016a085
855 #
856 AC_DEFUN([LC_IOP_GET_ACL], [
857 LB_CHECK_COMPILE([if 'inode_operations' has '.get_acl' member function],
858 inode_ops_get_acl, [
859         #include <linux/fs.h>
860 ],[
861         struct inode_operations iop;
862         iop.get_acl = NULL;
863 ],[
864         AC_DEFINE(HAVE_IOP_GET_ACL, 1,
865                 [inode_operations has .get_acl member function])
866 ])
867 ]) # LC_IOP_GET_ACL
868
869 #
870 # LC_FILE_LLSEEK_SIZE
871 #
872 # 3.1 introduced generic_file_llseek_size()
873 #
874 AC_DEFUN([LC_FILE_LLSEEK_SIZE], [
875 LB_CHECK_EXPORT([generic_file_llseek_size], [fs/read_write.c],
876         [AC_DEFINE(HAVE_FILE_LLSEEK_SIZE, 1,
877                 [generic_file_llseek_size is exported by the kernel])])
878 ]) # LC_FILE_LLSEEK_SIZE
879
880 #
881 # LC_RADIX_EXCEPTION_ENTRY
882 # 3.1 adds radix_tree_exception_entry.
883 #
884 AC_DEFUN([LC_RADIX_EXCEPTION_ENTRY], [
885 LB_CHECK_COMPILE([radix_tree_exceptional_entry exist],
886 radix_tree_exceptional_entry, [
887         #include <linux/radix-tree.h>
888 ],[
889         radix_tree_exceptional_entry(NULL);
890 ],[
891         AC_DEFINE(HAVE_RADIX_EXCEPTION_ENTRY, 1,
892                 [radix_tree_exceptional_entry exist])
893 ])
894 ]) # LC_RADIX_EXCEPTION_ENTRY
895
896 #
897 # LC_HAVE_VOID_MAKE_REQUEST_FN
898 #
899 # 3.2 request_queue.make_request_fn defined as function returns with void
900 # see kernel commit 5a7bbad27a410350e64a2d7f5ec18fc73836c14f
901 #
902 AC_DEFUN([LC_HAVE_VOID_MAKE_REQUEST_FN], [
903 LB_CHECK_COMPILE([if 'request_queue.make_request_fn' returns void but not int],
904 make_request_fn_void, [
905         #include <linux/blkdev.h>
906 ],[
907         int ret;
908         make_request_fn *mrf;
909         ret = mrf(NULL, NULL);
910 ],[],[
911         AC_DEFINE(HAVE_VOID_MAKE_REQUEST_FN, 1,
912                 [request_queue.make_request_fn returns void but not int])
913 ])
914 ]) # LC_HAVE_VOID_MAKE_REQUEST_FN
915
916 #
917 # LC_HAVE_PROTECT_I_NLINK
918 #
919 # 3.2 protects inode->i_nlink from direct modification
920 # see kernel commit a78ef704a8dd430225955f0709b22d4a6ba21deb
921 # at the same time adds set_nlink(), so checks set_nlink() for it.
922 #
923 AC_DEFUN([LC_HAVE_PROTECT_I_NLINK], [
924 LB_CHECK_COMPILE([if 'inode->i_nlink' is protected from direct modification],
925 inode_i_nlink_protected, [
926         #include <linux/fs.h>
927 ],[
928         struct inode i;
929         set_nlink(&i, 1);
930 ],[
931         AC_DEFINE(HAVE_PROTECT_I_NLINK, 1,
932                 [inode->i_nlink is protected from direct modification])
933 ])
934 ]) # LC_HAVE_PROTECT_I_NLINK
935
936 #
937 # 2.6.39 security_inode_init_security takes a 'struct qstr' parameter
938 #
939 # 3.2 security_inode_init_security takes a callback to set xattrs
940 #
941 AC_DEFUN([LC_HAVE_SECURITY_IINITSEC], [
942 LB_CHECK_COMPILE([if security_inode_init_security takes a callback],
943 security_inode_init_security_callback, [
944         #include <linux/security.h>
945 ],[
946         security_inode_init_security(NULL, NULL, NULL, (const initxattrs)NULL, NULL);
947 ],[
948         AC_DEFINE(HAVE_SECURITY_IINITSEC_CALLBACK, 1,
949                   [security_inode_init_security takes a callback to set xattrs])
950 ],[
951         LB_CHECK_COMPILE([if security_inode_init_security takes a 'struct qstr' parameter],
952         security_inode_init_security_qstr, [
953                 #include <linux/security.h>
954         ],[
955                 security_inode_init_security(NULL, NULL, (struct qstr *)NULL, NULL, NULL, NULL);
956         ],[
957                 AC_DEFINE(HAVE_SECURITY_IINITSEC_QSTR, 1,
958                           [security_inode_init_security takes a 'struct qstr' parameter])
959         ])
960 ])
961 ]) # LC_HAVE_SECURITY_IINITSEC
962
963 #
964 # LC_HAVE_MIGRATE_HEADER
965 #
966 # 3.3 introduces migrate_mode.h and migratepage has 4 args
967 #
968 AC_DEFUN([LC_HAVE_MIGRATE_HEADER], [
969 LB_CHECK_FILE([$LINUX/include/linux/migrate.h], [
970         AC_DEFINE(HAVE_MIGRATE_H, 1,
971                 [kernel has include/linux/migrate.h])
972 ],[
973         LB_CHECK_FILE([$LINUX/include/linux/migrate_mode.h], [
974                 AC_DEFINE(HAVE_MIGRATE_MODE_H, 1,
975                         [kernel has include/linux/migrate_mode.h])
976         ])
977 ])
978 ]) # LC_HAVE_MIGRATE_HEADER
979
980 #
981 # LC_MIGRATEPAGE_4ARGS
982 #
983 AC_DEFUN([LC_MIGRATEPAGE_4ARGS], [
984 LB_CHECK_COMPILE([if 'address_space_operations.migratepage' has 4 args],
985 address_space_ops_migratepage_4args, [
986         #include <linux/fs.h>
987 #ifdef HAVE_MIGRATE_H
988         #include <linux/migrate.h>
989 #elif defined(HAVE_MIGRATE_MODE_H)
990         #include <linux/migrate_mode.h>
991 #endif
992 ],[
993         struct address_space_operations aops;
994         aops.migratepage(NULL, NULL, NULL, MIGRATE_ASYNC);
995 ],[
996         AC_DEFINE(HAVE_MIGRATEPAGE_4ARGS, 1,
997                 [address_space_operations.migratepage has 4 args])
998 ])
999 ]) # LC_MIGRATEPAGE_4ARGS
1000
1001 #
1002 # LC_SUPEROPS_USE_DENTRY
1003 #
1004 # 3.3 switchs super_operations to use dentry as parameter (but not vfsmount)
1005 # see kernel commit 34c80b1d93e6e20ca9dea0baf583a5b5510d92d4
1006 #
1007 AC_DEFUN([LC_SUPEROPS_USE_DENTRY], [
1008 tmp_flags="$EXTRA_KCFLAGS"
1009 EXTRA_KCFLAGS="-Werror"
1010 LB_CHECK_COMPILE([if 'super_operations' use 'dentry' as parameter],
1011 super_ops_dentry, [
1012         #include <linux/fs.h>
1013         int show_options(struct seq_file *seq, struct dentry *root) {
1014                 return 0;
1015         }
1016 ],[
1017         struct super_operations ops;
1018         ops.show_options = show_options;
1019 ],[
1020         AC_DEFINE(HAVE_SUPEROPS_USE_DENTRY, 1,
1021                 [super_operations use dentry as parameter])
1022 ])
1023 EXTRA_KCFLAGS="$tmp_flags"
1024 ]) # LC_SUPEROPS_USE_DENTRY
1025
1026 #
1027 # LC_INODEOPS_USE_UMODE_T
1028 #
1029 # 3.3 switchs inode_operations to use umode_t as parameter (but not int)
1030 # see kernel commit 1a67aafb5f72a436ca044293309fa7e6351d6a35
1031 #
1032 AC_DEFUN([LC_INODEOPS_USE_UMODE_T], [
1033 tmp_flags="$EXTRA_KCFLAGS"
1034 EXTRA_KCFLAGS="-Werror"
1035 LB_CHECK_COMPILE([if 'inode_operations' use 'umode_t' as parameter],
1036 inode_ops_umode_t, [
1037         #include <linux/fs.h>
1038         #include <linux/types.h>
1039         int my_mknod(struct inode *dir, struct dentry *dchild,
1040                      umode_t mode, dev_t dev)
1041         {
1042                 return 0;
1043         }
1044 ],[
1045         struct inode_operations ops;
1046         ops.mknod = my_mknod;
1047 ],[
1048         AC_DEFINE(HAVE_INODEOPS_USE_UMODE_T, 1,
1049                 [inode_operations use umode_t as parameter])
1050 ])
1051 EXTRA_KCFLAGS="$tmp_flags"
1052 ]) # LC_INODEOPS_USE_UMODE_T
1053
1054 #
1055 # LC_KMAP_ATOMIC_HAS_1ARG
1056 #
1057 # 3.4 kmap_atomic removes second argument
1058 # see kernel commit 1ec9c5ddc17aa398f05646abfcbaf315b544e62f
1059 #
1060 AC_DEFUN([LC_KMAP_ATOMIC_HAS_1ARG], [
1061 LB_CHECK_COMPILE([if 'kmap_atomic' has only 1 argument],
1062 kmap_atomic_1arg, [
1063         #include <linux/highmem.h>
1064 ],[
1065         kmap_atomic(NULL);
1066 ],[
1067         AC_DEFINE(HAVE_KMAP_ATOMIC_HAS_1ARG, 1,
1068                 [have kmap_atomic has only 1 argument])
1069 ])
1070 ]) # LC_KMAP_ATOMIC_HAS_1ARG
1071
1072 #
1073 # LC_HAVE_D_MAKE_ROOT
1074 #
1075 # 3.4 converts d_alloc_root to d_make_root
1076 # see kernel commit 32991ab305ace7017c62f8eecbe5eb36dc32e13b
1077 #
1078 AC_DEFUN([LC_HAVE_D_MAKE_ROOT], [
1079 LB_CHECK_COMPILE([if have 'd_make_root'],
1080 d_make_root, [
1081         #include <linux/fs.h>
1082 ],[
1083         d_make_root((struct inode *)NULL);
1084 ],[
1085         AC_DEFINE(HAVE_D_MAKE_ROOT, 1,
1086                 [have d_make_root])
1087 ])
1088 ]) # LC_HAVE_D_MAKE_ROOT
1089
1090 #
1091 # LC_HAVE_CACHE_REGISTER
1092 #
1093 # 3.4 cache_register/cache_unregister are removed
1094 # see kernel commit 2c5f846747526e2b83c5f1b8e69016be0e2e87c0
1095 # Note, since 2.6.37 cache_register_net/cache_unregister_net
1096 # are defined, but not exported.
1097 # 3.3 cache_register_net/cache_unregister_net are
1098 # exported and replacing cache_register/cache_unregister in 3.4
1099 #
1100 AC_DEFUN([LC_HAVE_CACHE_REGISTER], [
1101 LB_CHECK_COMPILE([if have 'cache_register'],
1102 cache_register, [
1103         #include <linux/sunrpc/cache.h>
1104 ],[
1105         cache_register(NULL);
1106 ],[
1107         AC_DEFINE(HAVE_CACHE_REGISTER, 1,
1108                 [have cache_register])
1109 ])
1110 ]) # LC_HAVE_CACHE_REGISTER
1111
1112 #
1113 # LC_HAVE_CLEAR_INODE
1114 #
1115 # 3.5 renames end_writeback() back to clear_inode()...
1116 # see kernel commit dbd5768f87ff6fb0a4fe09c4d7b6c4a24de99430
1117 #
1118 AC_DEFUN([LC_HAVE_CLEAR_INODE], [
1119 LB_CHECK_COMPILE([if have 'clear_inode'],
1120 clear_inode, [
1121         #include <linux/fs.h>
1122 ],[
1123         clear_inode((struct inode *)NULL);
1124 ],[
1125         AC_DEFINE(HAVE_CLEAR_INODE, 1,
1126                 [have clear_inode])
1127 ])
1128 ]) # LC_HAVE_CLEAR_INODE
1129
1130 #
1131 # LC_HAVE_ENCODE_FH_PARENT
1132 #
1133 # 3.5 encode_fh has parent inode passed in directly
1134 # see kernel commit b0b0382b
1135 #
1136 AC_DEFUN([LC_HAVE_ENCODE_FH_PARENT], [
1137 tmp_flags="$EXTRA_KCFLAGS"
1138 EXTRA_KCFLAGS="-Werror"
1139 LB_CHECK_COMPILE([if 'encode_fh' have parent inode as parameter],
1140 encode_fh_parent_inode, [
1141         #include <linux/exportfs.h>
1142         #include <linux/fs.h>
1143         #include <linux/types.h>
1144         int ll_encode_fh(struct inode *i, __u32 *a, int *b, struct inode *p)
1145         {
1146                 return 0;
1147         }
1148 ],[
1149         struct export_operations exp_op;
1150         exp_op.encode_fh = ll_encode_fh;
1151 ],[
1152         AC_DEFINE(HAVE_ENCODE_FH_PARENT, 1,
1153                 [have parent inode as parameter])
1154 ])
1155 EXTRA_KCFLAGS="$tmp_flags"
1156 ]) # LC_HAVE_ENCODE_FH_PARENT
1157
1158 #
1159 # LC_FILE_LLSEEK_SIZE_5ARG
1160 #
1161 # 3.5 has generic_file_llseek_size with 5 args
1162 #
1163 AC_DEFUN([LC_FILE_LLSEEK_SIZE_5ARG], [
1164 LB_CHECK_COMPILE([if Linux kernel has 'generic_file_llseek_size' with 5 args],
1165 generic_file_llseek_size_5args, [
1166         #include <linux/fs.h>
1167 ],[
1168         generic_file_llseek_size(NULL, 0, 0, 0, 0);
1169 ], [
1170         AC_DEFINE(HAVE_FILE_LLSEEK_SIZE_5ARGS, 1,
1171                 [kernel has generic_file_llseek_size with 5 args])
1172 ])
1173 ]) # LC_FILE_LLSEEK_SIZE_5ARG
1174
1175 #
1176 # LC_LLITE_DATA_IS_LIST
1177 #
1178 # 3.6 switch i_dentry/d_alias from list to hlist
1179 #
1180 # In the upstream kernels d_alias first changes
1181 # to a hlist and then in later version, 3.11, gets
1182 # moved to the union d_u. Due to some distros having
1183 # d_alias in the d_u union as a struct list, which
1184 # has never existed upstream stream, we can't test
1185 # if d_alias is a list or hlist directly. If ever
1186 # i_dentry and d_alias even up different combos then
1187 # the build will fail. In that case then we will need
1188 # to separate out the i_dentry and d_alias test below.
1189 #
1190 AC_DEFUN([LC_DATA_FOR_LLITE_IS_LIST], [
1191 tmp_flags="$EXTRA_KCFLAGS"
1192 EXTRA_KCFLAGS="-Werror"
1193 LB_CHECK_COMPILE([if 'i_dentry/d_alias' uses 'list'],
1194 i_dentry_d_alias_list, [
1195         #include <linux/fs.h>
1196 ],[
1197         struct inode inode;
1198         INIT_LIST_HEAD(&inode.i_dentry);
1199 ],[
1200         AC_DEFINE(DATA_FOR_LLITE_IS_LIST, 1,
1201                 [both i_dentry/d_alias uses list])
1202 ])
1203 EXTRA_KCFLAGS="$tmp_flags"
1204 ]) # LC_DATA_FOR_LLITE_IS_LIST
1205
1206 #
1207 # LC_DENTRY_OPEN_USE_PATH
1208 #
1209 # 3.6 dentry_open uses struct path as first argument
1210 # see kernel commit 765927b2
1211 #
1212 AC_DEFUN([LC_DENTRY_OPEN_USE_PATH], [
1213 tmp_flags="$EXTRA_KCFLAGS"
1214 EXTRA_KCFLAGS="-Werror"
1215 LB_CHECK_COMPILE([if 'dentry_open' uses 'struct path' as first argument],
1216 dentry_open_path, [
1217         #include <linux/fs.h>
1218         #include <linux/path.h>
1219 ],[
1220         struct path path;
1221         dentry_open(&path, 0, NULL);
1222 ],[
1223         AC_DEFINE(HAVE_DENTRY_OPEN_USE_PATH, 1,
1224                 [dentry_open uses struct path as first argument])
1225 ])
1226 EXTRA_KCFLAGS="$tmp_flags"
1227 ]) # LC_DENTRY_OPEN_USE_PATH
1228
1229 #
1230 # LC_HAVE_IOP_ATOMIC_OPEN
1231 #
1232 # 3.6 vfs adds iop->atomic_open
1233 #
1234 AC_DEFUN([LC_HAVE_IOP_ATOMIC_OPEN], [
1235 LB_CHECK_COMPILE([if 'iop' has 'atomic_open'],
1236 inode_ops_atomic_open, [
1237         #include <linux/fs.h>
1238 ],[
1239         struct inode_operations iop;
1240         iop.atomic_open = NULL;
1241 ],[
1242         AC_DEFINE(HAVE_IOP_ATOMIC_OPEN, 1,
1243                 [have iop atomic_open])
1244 ])
1245 ]) # LC_HAVE_IOP_ATOMIC_OPEN
1246
1247 #
1248 # LC_HAVE_SB_START_WRITE
1249 #
1250 # RHEL6 2.6.32, 3.6 or newer support wrapped FS freeze functions
1251 #
1252 AC_DEFUN([LC_HAVE_SB_START_WRITE], [
1253 LB_CHECK_COMPILE([if kernel supports wrapped FS freeze functions],
1254 sb_start_write, [
1255         #include <linux/fs.h>
1256 ],[
1257         sb_start_write(NULL);
1258 ],[
1259         AC_DEFINE(HAVE_SB_START_WRITE, 1,
1260                 [kernel supports wrapped FS freeze functions])
1261 ])
1262 ]) # LC_HAVE_SB_START_WRITE
1263
1264 #
1265 # LC_HAVE_POSIXACL_USER_NS
1266 #
1267 # 3.7 posix_acl_{to,from}_xattr take struct user_namespace
1268 #
1269 AC_DEFUN([LC_HAVE_POSIXACL_USER_NS], [
1270 LB_CHECK_COMPILE([if 'posix_acl_to_xattr' takes 'struct user_namespace'],
1271 posix_acl_to_xattr_user_namespace, [
1272         #include <linux/fs.h>
1273         #include <linux/posix_acl_xattr.h>
1274 ],[
1275         posix_acl_to_xattr((struct user_namespace *)NULL, NULL, NULL, 0);
1276 ],[
1277         AC_DEFINE(HAVE_POSIXACL_USER_NS, 1,
1278                 [posix_acl_to_xattr takes struct user_namespace])
1279 ])
1280 ]) # LC_HAVE_POSIXACL_USER_NS
1281
1282 #
1283 # LC_HAVE_FILE_F_INODE
1284 #
1285 # 3.8 struct file has new member f_inode
1286 #
1287 AC_DEFUN([LC_HAVE_FILE_F_INODE], [
1288 LB_CHECK_COMPILE([if 'struct file' has member 'f_inode'],
1289 file_f_inode, [
1290         #include <linux/fs.h>
1291 ],[
1292         ((struct file *)0)->f_inode = NULL;
1293 ],[
1294         AC_DEFINE(HAVE_FILE_F_INODE, 1,
1295                 [struct file has member f_inode])
1296 ])
1297 ]) # LC_HAVE_FILE_F_INODE
1298
1299 #
1300 # LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS
1301 #
1302 AC_DEFUN([LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS], [
1303 LB_CHECK_COMPILE([if 'sunrpc_cache_pipe_upcall' takes 3 args],
1304 sunrpc_cache_pipe_upcall_3args, [
1305         #include <linux/sunrpc/cache.h>
1306 ],[
1307         sunrpc_cache_pipe_upcall(NULL, NULL, NULL);
1308 ],[
1309         AC_DEFINE(HAVE_SUNRPC_UPCALL_HAS_3ARGS, 1,
1310                 [sunrpc_cache_pipe_upcall takes 3 args])
1311 ])
1312 ]) # LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS
1313
1314 #
1315 # LC_HAVE_HLIST_FOR_EACH_3ARG
1316 #
1317 # 3.9 uses hlist_for_each_entry with 3 args
1318 # b67bfe0d42cac56c512dd5da4b1b347a23f4b70a
1319 #
1320 AC_DEFUN([LC_HAVE_HLIST_FOR_EACH_3ARG], [
1321 LB_CHECK_COMPILE([if 'hlist_for_each_entry' has 3 args],
1322 hlist_for_each_entry_3args, [
1323         #include <linux/list.h>
1324         #include <linux/fs.h>
1325 ],[
1326         struct hlist_head *head = NULL;
1327         struct inode *inode;
1328
1329         hlist_for_each_entry(inode, head, i_hash) {
1330                 continue;
1331         }
1332 ],[
1333         AC_DEFINE(HAVE_HLIST_FOR_EACH_3ARG, 1,
1334                 [hlist_for_each_entry has 3 args])
1335 ])
1336 ]) # LC_HAVE_HLIST_FOR_EACH_3ARG
1337
1338 #
1339 # LC_HAVE_BIO_END_SECTOR
1340 #
1341 # 3.9 introduces bio_end_sector macro
1342 # f73a1c7d117d07a96d89475066188a2b79e53c48
1343 #
1344 AC_DEFUN([LC_HAVE_BIO_END_SECTOR], [
1345 LB_CHECK_COMPILE([if 'bio_end_sector' is defined],
1346 bio_end_sector, [
1347         #include <linux/bio.h>
1348 ],[
1349         struct bio bio;
1350
1351         bio_end_sector(&bio);
1352 ],[
1353         AC_DEFINE(HAVE_BIO_END_SECTOR, 1,
1354                   [bio_end_sector is defined])
1355 ])
1356 ]) # LC_HAVE_BIO_END_SECTOR
1357
1358 #
1359 # LC_HAVE_REMOVE_PROC_SUBTREE
1360 #
1361 # 3.10 introduced remove_proc_subtree
1362 #
1363 AC_DEFUN([LC_HAVE_REMOVE_PROC_SUBTREE], [
1364 LB_CHECK_COMPILE([if 'remove_proc_subtree' is defined],
1365 remove_proc_subtree, [
1366         #include <linux/proc_fs.h>
1367 ],[
1368         remove_proc_subtree(NULL, NULL);
1369 ], [
1370         AC_DEFINE(HAVE_REMOVE_PROC_SUBTREE, 1,
1371                   [remove_proc_subtree is defined])
1372 ])
1373 ]) # LC_HAVE_REMOVE_PROC_SUBTREE
1374
1375 #
1376 # LC_HAVE_PROC_REMOVE
1377 #
1378 # 3.10 introduced proc_remove
1379 #
1380 AC_DEFUN([LC_HAVE_PROC_REMOVE], [
1381 LB_CHECK_COMPILE([if 'proc_remove' is defined],
1382 proc_remove, [
1383         #include <linux/proc_fs.h>
1384 ],[
1385         proc_remove(NULL);
1386 ], [
1387         AC_DEFINE(HAVE_PROC_REMOVE, 1,
1388                   [proc_remove is defined])
1389 ])
1390 ]) # LC_HAVE_PROC_REMOVE
1391
1392 #
1393 # LC_BLKDEV_RELEASE_RETURN_INT
1394 #
1395 # 3.10 release for block device doesn't return int
1396 #
1397 AC_DEFUN([LC_BLKDEV_RELEASE_RETURN_INT], [
1398 LB_CHECK_COMPILE([if 'block_device_operations' release returns 'int'],
1399 block_device_ops_release_return_int, [
1400         #include <linux/blkdev.h>
1401 ],[
1402         struct block_device_operations fops;
1403         int i __attribute__ ((unused));
1404
1405         i = fops.release(NULL, 0);
1406 ],[
1407         AC_DEFINE(HAVE_BLKDEV_RELEASE_RETURN_INT, 1,
1408                 [block device release returns int])
1409 ])
1410 ]) # LC_BLKDEV_RELEASE_RETURN_INT
1411
1412 #
1413 # LC_INVALIDATE_RANGE
1414 #
1415 # 3.11 invalidatepage requires the length of the range to invalidate
1416 #
1417 AC_DEFUN([LC_INVALIDATE_RANGE], [
1418 LB_CHECK_COMPILE([if 'address_space_operations.invalidatepage' requires 3 arguments],
1419 address_space_ops_invalidatepage_3args, [
1420         #include <linux/fs.h>
1421 ],[
1422         struct address_space_operations a_ops;
1423         a_ops.invalidatepage(NULL, 0, 0);
1424 ],[
1425         AC_DEFINE(HAVE_INVALIDATE_RANGE, 1,
1426                 [address_space_operations.invalidatepage needs 3 arguments])
1427 ])
1428 ]) # LC_INVALIDATE_RANGE
1429
1430 #
1431 # LC_HAVE_DIR_CONTEXT
1432 #
1433 # 3.11 readdir now takes the new struct dir_context
1434 #
1435 AC_DEFUN([LC_HAVE_DIR_CONTEXT], [
1436 LB_CHECK_COMPILE([if 'dir_context' exist],
1437 dir_context, [
1438         #include <linux/fs.h>
1439 ],[
1440         struct dir_context ctx;
1441         ctx.pos = 0;
1442 ],[
1443         AC_DEFINE(HAVE_DIR_CONTEXT, 1,
1444                 [dir_context exist])
1445 ])
1446 ]) # LC_HAVE_DIR_CONTEXT
1447
1448 #
1449 # LC_D_COMPARE_5ARGS
1450 #
1451 # 3.11 dentry_operations.d_compare() taken 5 arguments.
1452 #
1453 AC_DEFUN([LC_D_COMPARE_5ARGS], [
1454 LB_CHECK_COMPILE([if 'd_compare' taken 5 arguments],
1455 d_compare_5args, [
1456         #include <linux/dcache.h>
1457 ],[
1458         ((struct dentry_operations*)0)->d_compare(NULL,NULL,0,NULL,NULL);
1459 ],[
1460         AC_DEFINE(HAVE_D_COMPARE_5ARGS, 1,
1461                 [d_compare need 5 arguments])
1462 ])
1463 ]) # LC_D_COMPARE_5ARGS
1464
1465 #
1466 # LC_HAVE_DCOUNT
1467 #
1468 # 3.11 need to access d_count to get dentry reference count
1469 #
1470 AC_DEFUN([LC_HAVE_DCOUNT], [
1471 LB_CHECK_COMPILE([if 'd_count' exist],
1472 d_count, [
1473         #include <linux/dcache.h>
1474 ],[
1475         struct dentry de;
1476         d_count(&de);
1477 ],[
1478         AC_DEFINE(HAVE_D_COUNT, 1,
1479                 [d_count exist])
1480 ])
1481 ]) # LC_HAVE_DCOUNT
1482
1483 #
1484 # LC_OLDSIZE_TRUNCATE_PAGECACHE
1485 #
1486 # 3.12 truncate_pagecache without oldsize parameter
1487 #
1488 AC_DEFUN([LC_OLDSIZE_TRUNCATE_PAGECACHE], [
1489 LB_CHECK_COMPILE([if 'truncate_pagecache' with 'old_size' parameter],
1490 truncate_pagecache_old_size, [
1491         #include <linux/mm.h>
1492 ],[
1493         truncate_pagecache(NULL, 0, 0);
1494 ],[
1495         AC_DEFINE(HAVE_OLDSIZE_TRUNCATE_PAGECACHE, 1,
1496                 [with oldsize])
1497 ])
1498 ]) # LC_OLDSIZE_TRUNCATE_PAGECACHE
1499
1500 #
1501 # LC_HAVE_DENTRY_D_U_D_ALIAS
1502 #
1503 # 3.11 kernel moved d_alias to the union d_u in struct dentry
1504 #
1505 # Some distros move d_alias to d_u but it is still a struct list
1506 #
1507 AC_DEFUN([LC_HAVE_DENTRY_D_U_D_ALIAS], [
1508 AS_IF([test "x$lb_cv_compile_i_dentry_d_alias_list" = xyes], [
1509         LB_CHECK_COMPILE([if list 'dentry.d_u.d_alias' exist],
1510         d_alias, [
1511                 #include <linux/list.h>
1512                 #include <linux/dcache.h>
1513         ],[
1514                 struct dentry de;
1515                 INIT_LIST_HEAD(&de.d_u.d_alias);
1516         ],[
1517                 AC_DEFINE(HAVE_DENTRY_D_U_D_ALIAS, 1,
1518                         [list dentry.d_u.d_alias exist])
1519         ])
1520 ],[
1521         LB_CHECK_COMPILE([if hlist 'dentry.d_u.d_alias' exist],
1522         d_alias, [
1523                 #include <linux/list.h>
1524                 #include <linux/dcache.h>
1525         ],[
1526                 struct dentry de;
1527                 INIT_HLIST_NODE(&de.d_u.d_alias);
1528         ],[
1529                 AC_DEFINE(HAVE_DENTRY_D_U_D_ALIAS, 1,
1530                         [hlist dentry.d_u.d_alias exist])
1531         ])
1532 ])
1533 ]) # LC_HAVE_DENTRY_D_U_D_ALIAS
1534
1535 #
1536 # LC_HAVE_DENTRY_D_CHILD
1537 #
1538 # 3.11 kernel d_child has been moved out of the union d_u
1539 # in struct dentry
1540 #
1541 AC_DEFUN([LC_HAVE_DENTRY_D_CHILD], [
1542 LB_CHECK_COMPILE([if 'dentry.d_child' exist],
1543 d_child, [
1544         #include <linux/list.h>
1545         #include <linux/dcache.h>
1546 ],[
1547         struct dentry de;
1548         INIT_LIST_HEAD(&de.d_child);
1549 ],[
1550         AC_DEFINE(HAVE_DENTRY_D_CHILD, 1,
1551                 [dentry.d_child exist])
1552 ])
1553 ]) # LC_HAVE_DENTRY_D_CHILD
1554
1555 #
1556 # LC_KIOCB_KI_LEFT
1557 #
1558 # 3.12 ki_left removed from struct kiocb
1559 #
1560 AC_DEFUN([LC_KIOCB_KI_LEFT], [
1561 LB_CHECK_COMPILE([if 'struct kiocb' with 'ki_left' member],
1562 kiocb_ki_left, [
1563         #include <linux/aio.h>
1564 ],[
1565         ((struct kiocb*)0)->ki_left = 0;
1566 ],[
1567         AC_DEFINE(HAVE_KIOCB_KI_LEFT, 1,
1568                 [ki_left exist])
1569 ])
1570 ]) # LC_KIOCB_KI_LEFT
1571
1572 #
1573 # LC_VFS_RENAME_5ARGS
1574 #
1575 # 3.13 has vfs_rename with 5 args
1576 #
1577 AC_DEFUN([LC_VFS_RENAME_5ARGS], [
1578 LB_CHECK_COMPILE([if Linux kernel has 'vfs_rename' with 5 args],
1579 vfs_rename_5args, [
1580         #include <linux/fs.h>
1581 ],[
1582         vfs_rename(NULL, NULL, NULL, NULL, NULL);
1583 ], [
1584         AC_DEFINE(HAVE_VFS_RENAME_5ARGS, 1,
1585                 [kernel has vfs_rename with 5 args])
1586 ])
1587 ]) # LC_VFS_RENAME_5ARGS
1588
1589 #
1590 # LC_VFS_UNLINK_3ARGS
1591 #
1592 # 3.13 has vfs_unlink with 3 args
1593 #
1594 AC_DEFUN([LC_VFS_UNLINK_3ARGS], [
1595 LB_CHECK_COMPILE([if Linux kernel has 'vfs_unlink' with 3 args],
1596 vfs_unlink_3args, [
1597         #include <linux/fs.h>
1598 ],[
1599         vfs_unlink(NULL, NULL, NULL);
1600 ], [
1601         AC_DEFINE(HAVE_VFS_UNLINK_3ARGS, 1,
1602                 [kernel has vfs_unlink with 3 args])
1603 ])
1604 ]) # LC_VFS_UNLINK_3ARGS
1605
1606 #
1607 # LC_HAVE_BVEC_ITER
1608 #
1609 # 3.14 move some of its data in struct bio into the new
1610 # struct bvec_iter
1611 #
1612 AC_DEFUN([LC_HAVE_BVEC_ITER], [
1613 LB_CHECK_COMPILE([if Linux kernel has struct bvec_iter],
1614 have_bvec_iter, [
1615         #include <linux/bio.h>
1616 ],[
1617         struct bvec_iter iter;
1618         iter.bi_bvec_done = 0;
1619 ], [
1620         AC_DEFINE(HAVE_BVEC_ITER, 1,
1621                 [kernel has struct bvec_iter])
1622 ])
1623 ]) # LC_HAVE_BVEC_ITER
1624
1625 #
1626 # LC_HAVE_TRUNCATE_IPAGE_FINAL
1627 #
1628 # 3.14 bring truncate_inode_pages_final for evict_inode
1629 #
1630 AC_DEFUN([LC_HAVE_TRUNCATE_IPAGES_FINAL], [
1631 LB_CHECK_COMPILE([if Linux kernel has truncate_inode_pages_final],
1632 truncate_ipages_final, [
1633         #include <linux/mm.h>
1634 ],[
1635         truncate_inode_pages_final(NULL);
1636 ], [
1637         AC_DEFINE(HAVE_TRUNCATE_INODE_PAGES_FINAL, 1,
1638                 [kernel has truncate_inode_pages_final])
1639 ])
1640 ]) # LC_HAVE_TRUNCATE_IPAGES_FINAL
1641
1642 #
1643 # LC_VFS_RENAME_6ARGS
1644 #
1645 # 3.15 has vfs_rename with 6 args
1646 #
1647 AC_DEFUN([LC_VFS_RENAME_6ARGS], [
1648 LB_CHECK_COMPILE([if Linux kernel has 'vfs_rename' with 6 args],
1649 vfs_rename_6args, [
1650         #include <linux/fs.h>
1651 ],[
1652         vfs_rename(NULL, NULL, NULL, NULL, NULL, NULL);
1653 ], [
1654         AC_DEFINE(HAVE_VFS_RENAME_6ARGS, 1,
1655                 [kernel has vfs_rename with 6 args])
1656 ])
1657 ]) # LC_VFS_RENAME_6ARGS
1658
1659 #
1660 # LC_DIRECTIO_USE_ITER
1661 #
1662 # 3.16 kernel changes direct IO to use iov_iter
1663 #
1664 AC_DEFUN([LC_DIRECTIO_USE_ITER], [
1665 LB_CHECK_COMPILE([if direct IO uses iov_iter],
1666 direct_io_iter, [
1667         #include <linux/fs.h>
1668 ],[
1669         struct address_space_operations ops;
1670         struct iov_iter *iter = NULL;
1671         loff_t offset = 0;
1672
1673         ops.direct_IO(0, NULL, iter, offset);
1674 ],[
1675         AC_DEFINE(HAVE_DIRECTIO_ITER, 1,
1676                 [direct IO uses iov_iter])
1677 ])
1678 ]) # LC_DIRECTIO_USE_ITER
1679
1680 #
1681 # LC_HAVE_IOV_ITER_INIT_DIRECTION
1682 #
1683 #
1684 # 3.16 linux commit 71d8e532b1549a478e6a6a8a44f309d050294d00
1685 #      changed iov_iter_init api to start accepting a tag
1686 #      that defines if its a read or write operation
1687 #
1688 AC_DEFUN([LC_HAVE_IOV_ITER_INIT_DIRECTION], [
1689 tmp_flags="$EXTRA_KCFLAGS"
1690 EXTRA_KCFLAGS="-Werror"
1691 LB_CHECK_COMPILE([if 'iov_iter_init' takes a tag],
1692 iter_init, [
1693         #include <linux/uio.h>
1694         #include <linux/fs.h>
1695 ],[
1696         const struct iovec *iov = NULL;
1697
1698         iov_iter_init(NULL, READ, iov, 1, 0);
1699 ],[
1700         AC_DEFINE(HAVE_IOV_ITER_INIT_DIRECTION, 1,
1701                 [iov_iter_init handles directional tag])
1702 ])
1703 EXTRA_KCFLAGS="$tmp_flags"
1704 ]) # LC_HAVE_IOV_ITER_INIT_DIRECTION
1705
1706 #
1707 # LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
1708 #
1709 # 3.16 introduces [read|write]_iter to struct file_operations
1710 #
1711 AC_DEFUN([LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER], [
1712 LB_CHECK_COMPILE([if 'file_operations.[read|write]_iter' exist],
1713 file_function_iter, [
1714         #include <linux/fs.h>
1715 ],[
1716         ((struct file_operations *)NULL)->read_iter(NULL, NULL);
1717         ((struct file_operations *)NULL)->write_iter(NULL, NULL);
1718 ],[
1719         AC_DEFINE(HAVE_FILE_OPERATIONS_READ_WRITE_ITER, 1,
1720                 [file_operations.[read|write]_iter functions exist])
1721 ])
1722 ]) # LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
1723
1724 #
1725 # LC_KEY_MATCH_DATA
1726 #
1727 # 3.17  replaces key_type::match with match_preparse
1728 #       and has new struct key_match_data
1729 #
1730 AC_DEFUN([LC_KEY_MATCH_DATA], [
1731 LB_CHECK_COMPILE([if struct key_match field exist],
1732 key_match, [
1733         #include <linux/key-type.h>
1734 ],[
1735         struct key_match_data data;
1736 ],[
1737         AC_DEFINE(HAVE_KEY_MATCH_DATA, 1,
1738                 [struct key_match_data exist])
1739 ])
1740 ]) # LC_KEY_MATCH_DATA
1741
1742 #
1743 # LC_NFS_FILLDIR_USE_CTX
1744 #
1745 # 3.18 kernel moved from void cookie to struct dir_context
1746 #
1747 AC_DEFUN([LC_NFS_FILLDIR_USE_CTX], [
1748 tmp_flags="$EXTRA_KCFLAGS"
1749 EXTRA_KCFLAGS="-Werror"
1750 LB_CHECK_COMPILE([if filldir_t uses struct dir_context],
1751 filldir_ctx, [
1752         #include <linux/fs.h>
1753 ],[
1754         int filldir(struct dir_context *ctx, const char* name,
1755                     int i, loff_t off, u64 tmp, unsigned temp)
1756         {
1757                 return 0;
1758         }
1759
1760         struct dir_context ctx = {
1761                 .actor = filldir,
1762         };
1763
1764         ctx.actor(NULL, "test", 0, (loff_t) 0, 0, 0);
1765 ],[
1766         AC_DEFINE(HAVE_FILLDIR_USE_CTX, 1,
1767                 [filldir_t needs struct dir_context as argument])
1768 ])
1769 EXTRA_KCFLAGS="$tmp_flags"
1770 ]) # LC_NFS_FILLDIR_USE_CTX
1771
1772 #
1773 # LC_PERCPU_COUNTER_INIT
1774 #
1775 # 3.18  For kernels 3.18 and after percpu_counter_init starts
1776 #       to pass a GFP_* memory allocation flag for internal
1777 #       memory allocation purposes.
1778 #
1779 AC_DEFUN([LC_PERCPU_COUNTER_INIT], [
1780 LB_CHECK_COMPILE([if percpu_counter_init uses GFP_* flag as argument],
1781 percpu_counter_init, [
1782         #include <linux/percpu_counter.h>
1783 ],[
1784         percpu_counter_init(NULL, 0, GFP_KERNEL);
1785 ],[
1786         AC_DEFINE(HAVE_PERCPU_COUNTER_INIT_GFP_FLAG, 1,
1787                 [percpu_counter_init uses GFP_* flag])
1788 ])
1789 ]) # LC_PERCPU_COUNTER_INIT
1790
1791 #
1792 # LC_KIOCB_HAS_NBYTES
1793 #
1794 # 3.19 kernel removed ki_nbytes from struct kiocb
1795 #
1796 AC_DEFUN([LC_KIOCB_HAS_NBYTES], [
1797 LB_CHECK_COMPILE([if struct kiocb has ki_nbytes field],
1798 ki_nbytes, [
1799         #include <linux/fs.h>
1800 ],[
1801         struct kiocb iocb;
1802
1803         iocb.ki_nbytes = 0;
1804 ],[
1805         AC_DEFINE(HAVE_KI_NBYTES, 1, [ki_nbytes field exist])
1806 ])
1807 ]) # LC_KIOCB_HAS_NBYTES
1808
1809 #
1810 # LC_BACKING_DEV_INFO_REMOVAL
1811 #
1812 # 3.20 kernel removed backing_dev_info from address_space
1813 #
1814 AC_DEFUN([LC_BACKING_DEV_INFO_REMOVAL], [
1815 LB_CHECK_COMPILE([if struct address_space has backing_dev_info],
1816 backing_dev_info, [
1817         #include <linux/fs.h>
1818 ],[
1819         struct address_space mapping;
1820
1821         mapping.backing_dev_info = NULL;
1822 ],[
1823         AC_DEFINE(HAVE_BACKING_DEV_INFO, 1, [backing_dev_info exist])
1824 ])
1825 ]) # LC_BACKING_DEV_INFO_REMOVAL
1826
1827 #
1828 # LC_HAVE_BDI_CAP_MAP_COPY
1829 #
1830 # 3.20  removed mmap handling for backing devices since
1831 #       it breaks on non-MMU systems. See kernel commit
1832 #       b4caecd48005fbed3949dde6c1cb233142fd69e9
1833 #
1834 AC_DEFUN([LC_HAVE_BDI_CAP_MAP_COPY], [
1835 LB_CHECK_COMPILE([if have 'BDI_CAP_MAP_COPY'],
1836 bdi_cap_map_copy, [
1837         #include <linux/backing-dev.h>
1838 ],[
1839         struct backing_dev_info info;
1840
1841         info.capabilities = BDI_CAP_MAP_COPY;
1842 ],[
1843         AC_DEFINE(HAVE_BDI_CAP_MAP_COPY, 1,
1844                 [BDI_CAP_MAP_COPY exist])
1845 ])
1846 ]) # LC_HAVE_BDI_CAP_MAP_COPY
1847
1848 #
1849 # LC_CANCEL_DIRTY_PAGE
1850 #
1851 # 4.0.0 kernel removed cancel_dirty_page
1852 #
1853 AC_DEFUN([LC_CANCEL_DIRTY_PAGE], [
1854 LB_CHECK_COMPILE([if cancel_dirty_page still exist],
1855 cancel_dirty_page, [
1856         #include <linux/mm.h>
1857 ],[
1858         cancel_dirty_page(NULL, PAGE_SIZE);
1859 ],[
1860         AC_DEFINE(HAVE_CANCEL_DIRTY_PAGE, 1,
1861                 [cancel_dirty_page is still available])
1862 ])
1863 ]) # LC_CANCEL_DIRTY_PAGE
1864
1865 #
1866 # LC_IOV_ITER_RW
1867 #
1868 # 4.1 kernel has iov_iter_rw
1869 #
1870 AC_DEFUN([LC_IOV_ITER_RW], [
1871 LB_CHECK_COMPILE([if iov_iter_rw exist],
1872 iov_iter_rw, [
1873         #include <linux/fs.h>
1874         #include <linux/uio.h>
1875 ],[
1876         struct iov_iter *iter = NULL;
1877
1878         iov_iter_rw(iter);
1879 ],[
1880         AC_DEFINE(HAVE_IOV_ITER_RW, 1,
1881                 [iov_iter_rw exist])
1882 ])
1883 ]) # LC_IOV_ITER_RW
1884
1885 #
1886 # LC_HAVE_SYNC_READ_WRITE
1887 #
1888 # 4.1 new_sync_[read|write] no longer exported
1889 #
1890 AC_DEFUN([LC_HAVE_SYNC_READ_WRITE], [
1891 LB_CHECK_EXPORT([new_sync_read], [fs/read_write.c],
1892         [AC_DEFINE(HAVE_SYNC_READ_WRITE, 1,
1893                         [new_sync_[read|write] is exported by the kernel])])
1894 ]) # LC_HAVE_SYNC_READ_WRITE
1895
1896 #
1897 # LC_NEW_CANCEL_DIRTY_PAGE
1898 #
1899 # 4.2 kernel has new cancel_dirty_page
1900 #
1901 AC_DEFUN([LC_NEW_CANCEL_DIRTY_PAGE], [
1902 LB_CHECK_COMPILE([if cancel_dirty_page with one argument exist],
1903 new_cancel_dirty_page, [
1904         #include <linux/mm.h>
1905 ],[
1906         cancel_dirty_page(NULL);
1907 ],[
1908         AC_DEFINE(HAVE_NEW_CANCEL_DIRTY_PAGE, 1,
1909                 [cancel_dirty_page with one arguement is available])
1910 ])
1911 ]) # LC_NEW_CANCEL_DIRTY_PAGE
1912
1913 #
1914 # LC_SYMLINK_OPS_USE_NAMEIDATA
1915 #
1916 # For the 4.2+ kernels the file system internal symlink api no
1917 # longer uses struct nameidata as a argument
1918 #
1919 AC_DEFUN([LC_SYMLINK_OPS_USE_NAMEIDATA], [
1920 LB_CHECK_COMPILE([if symlink inode operations have struct nameidata argument],
1921 symlink_use_nameidata, [
1922         #include <linux/namei.h>
1923         #include <linux/fs.h>
1924 ],[
1925         struct nameidata *nd = NULL;
1926
1927         ((struct inode_operations *)0)->follow_link(NULL, nd);
1928         ((struct inode_operations *)0)->put_link(NULL, nd, NULL);
1929 ],[
1930         AC_DEFINE(HAVE_SYMLINK_OPS_USE_NAMEIDATA, 1,
1931                 [symlink inode operations need struct nameidata argument])
1932 ])
1933 ]) # LC_SYMLINK_OPS_USE_NAMEIDATA
1934
1935 #
1936 # LC_BIO_ENDIO_USES_ONE_ARG
1937 #
1938 # 4.2 kernel bio_endio now only takes one argument
1939 #
1940 AC_DEFUN([LC_BIO_ENDIO_USES_ONE_ARG], [
1941 LB_CHECK_COMPILE([if 'bio_endio' with one argument exist],
1942 bio_endio, [
1943         #include <linux/bio.h>
1944 ],[
1945         bio_endio(NULL);
1946 ],[
1947         AC_DEFINE(HAVE_BIO_ENDIO_USES_ONE_ARG, 1,
1948                 [bio_endio takes only one argument])
1949 ])
1950 ]) # LC_BIO_ENDIO_USES_ONE_ARG
1951
1952 #
1953 # LC_HAVE_LOOP_CTL_GET_FREE
1954 #
1955 # 4.x kernel have moved userspace APIs to
1956 # the separate directory and all of them
1957 # support LOOP_CTL_GET_FREE
1958 #
1959 AC_DEFUN([LC_HAVE_LOOP_CTL_GET_FREE], [
1960 LB_CHECK_FILE([$LINUX/include/linux/loop.h], [
1961         LB_CHECK_COMPILE([if have 'HAVE_LOOP_CTL_GET_FREE'],
1962         LOOP_CTL_GET_FREE, [
1963                 #include <linux/loop.h>
1964         ],[
1965                 int i;
1966
1967                 i = LOOP_CTL_GET_FREE;
1968         ],[
1969                 AC_DEFINE(HAVE_LOOP_CTL_GET_FREE, 1,
1970                         [LOOP_CTL_GET_FREE exist])
1971         ])
1972 ],[
1973         AC_DEFINE(HAVE_LOOP_CTL_GET_FREE, 1,
1974                 [kernel has LOOP_CTL_GET_FREE])
1975 ])
1976 ]) # LC_HAVE_LOOP_CTL_GET_FREE
1977
1978 #
1979 # LC_HAVE_CACHE_HEAD_HLIST
1980 #
1981 # 4.3 kernel swiched to hlist for cache_head
1982 #
1983 AC_DEFUN([LC_HAVE_CACHE_HEAD_HLIST], [
1984 LB_CHECK_COMPILE([if 'struct cache_head' has 'cache_list' field],
1985 cache_head_has_hlist, [
1986         #include <linux/sunrpc/cache.h>
1987 ],[
1988         do {} while(sizeof(((struct cache_head *)0)->cache_list));
1989 ],[
1990         AC_DEFINE(HAVE_CACHE_HEAD_HLIST, 1,
1991                 [cache_head has hlist cache_list])
1992 ])
1993 ]) # LC_HAVE_CACHE_HEAD_HLIST
1994
1995 #
1996 # LC_HAVE_LOCKS_LOCK_FILE_WAIT
1997 #
1998 # 4.4 kernel have moved locks API users to
1999 # locks_lock_inode_wait()
2000 #
2001 AC_DEFUN([LC_HAVE_LOCKS_LOCK_FILE_WAIT], [
2002 LB_CHECK_COMPILE([if 'locks_lock_file_wait' exists],
2003 locks_lock_file_wait, [
2004         #include <linux/fs.h>
2005 ],[
2006         locks_lock_file_wait(NULL, NULL);
2007 ],[
2008         AC_DEFINE(HAVE_LOCKS_LOCK_FILE_WAIT, 1,
2009                 [kernel has locks_lock_file_wait])
2010 ])
2011 ]) # LC_HAVE_LOCKS_LOCK_FILE_WAIT
2012
2013 #
2014 # LC_HAVE_QC_MAKE_REQUEST_FN
2015 #
2016 # 4.4 request_queue.make_request_fn defined as function returns with blk_qc_t
2017 # see kernel commit dece16353ef47d8d33f5302bc158072a9d65e26f
2018 #
2019 AC_DEFUN([LC_HAVE_QC_MAKE_REQUEST_FN], [
2020 LB_CHECK_COMPILE([if 'request_queue.make_request_fn' returns blk_qc_t],
2021 make_request_fn_blk_qc_t, [
2022         #include <linux/blkdev.h>
2023 ],[
2024         blk_qc_t ret;
2025         make_request_fn *mrf;
2026         ret = mrf(NULL, NULL);
2027 ],[
2028         AC_DEFINE(HAVE_QC_MAKE_REQUEST_FN, 1,
2029                 [request_queue.make_request_fn returns blk_qc_t])
2030 ])
2031 ]) # LC_HAVE_QC_MAKE_REQUEST_FN
2032
2033 #
2034 # LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
2035 #
2036 # 4.4 kernel merged type-specific data with the payload data for keys
2037 #
2038 AC_DEFUN([LC_HAVE_KEY_PAYLOAD_DATA_ARRAY], [
2039 LB_CHECK_COMPILE([if 'struct key' has 'payload.data' as an array],
2040 key_payload_data_array, [
2041         #include <linux/key.h>
2042 ],[
2043         ((struct key *)0)->payload.data[0] = NULL;
2044 ],[
2045         AC_DEFINE(HAVE_KEY_PAYLOAD_DATA_ARRAY, 1, [payload.data is an array])
2046 ])
2047 ]) #LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
2048
2049 #
2050 # LC_PROG_LINUX
2051 #
2052 # Lustre linux kernel checks
2053 #
2054 AC_DEFUN([LC_PROG_LINUX], [
2055         AC_MSG_NOTICE([Lustre kernel checks
2056 ==============================================================================])
2057
2058         LC_CONFIG_PINGER
2059         LC_CONFIG_CHECKSUM
2060         LC_CONFIG_HEALTH_CHECK_WRITE
2061         LC_CONFIG_LRU_RESIZE
2062         LC_LLITE_LLOOP_MODULE
2063
2064         LC_GLIBC_SUPPORT_FHANDLES
2065         LC_CONFIG_RMTCLIENT
2066         LC_CONFIG_GSS
2067
2068         # 2.6.32
2069         LC_BLK_QUEUE_MAX_SEGMENTS
2070
2071         # 2.6.34
2072         LC_HAVE_DQUOT_FS_DISK_QUOTA
2073         LC_HAVE_DQUOT_SUSPEND
2074         LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE
2075
2076         # 2.6.35, 3.0.0
2077         LC_FILE_FSYNC
2078         LC_EXPORT_SIMPLE_SETATTR
2079         LC_EXPORT_TRUNCATE_COMPLETE_PAGE
2080
2081         # 2.6.36
2082         LC_FS_STRUCT_RWLOCK
2083         LC_SBOPS_EVICT_INODE
2084
2085         # 2.6.37
2086         LC_KERNEL_LOCKED
2087
2088         # 2.6.38
2089         LC_BLKDEV_GET_BY_DEV
2090         LC_GENERIC_PERMISSION
2091         LC_DCACHE_LOCK
2092         LC_INODE_I_RCU
2093         LC_D_COMPARE_7ARGS
2094         LC_D_DELETE_CONST
2095
2096         # 2.6.39
2097         LC_REQUEST_QUEUE_UNPLUG_FN
2098         LC_HAVE_FHANDLE_SYSCALLS
2099         LC_HAVE_FSTYPE_MOUNT
2100         LC_IOP_TRUNCATE
2101         LC_HAVE_INODE_OWNER_OR_CAPABLE
2102         LC_HAVE_SECURITY_IINITSEC
2103
2104         # 3.0
2105         LC_DIRTY_INODE_WITH_FLAG
2106
2107         # 3.1
2108         LC_LM_XXX_LOCK_MANAGER_OPS
2109         LC_INODE_DIO_WAIT
2110         LC_IOP_GET_ACL
2111         LC_FILE_LLSEEK_SIZE
2112         LC_INODE_PERMISION_2ARGS
2113         LC_RADIX_EXCEPTION_ENTRY
2114         LC_HAVE_LOOP_CTL_GET_FREE
2115
2116         # 3.2
2117         LC_HAVE_VOID_MAKE_REQUEST_FN
2118         LC_HAVE_PROTECT_I_NLINK
2119
2120         # 3.3
2121         LC_HAVE_MIGRATE_HEADER
2122         LC_MIGRATEPAGE_4ARGS
2123         LC_SUPEROPS_USE_DENTRY
2124         LC_INODEOPS_USE_UMODE_T
2125         LC_HAVE_CACHE_REGISTER
2126
2127         # 3.4
2128         LC_HAVE_D_MAKE_ROOT
2129         LC_KMAP_ATOMIC_HAS_1ARG
2130
2131         # 3.5
2132         LC_HAVE_CLEAR_INODE
2133         LC_HAVE_ENCODE_FH_PARENT
2134         LC_FILE_LLSEEK_SIZE_5ARG
2135
2136         # 3.6
2137         LC_DATA_FOR_LLITE_IS_LIST
2138         LC_DENTRY_OPEN_USE_PATH
2139         LC_HAVE_IOP_ATOMIC_OPEN
2140         LC_HAVE_SB_START_WRITE
2141
2142         # 3.7
2143         LC_HAVE_POSIXACL_USER_NS
2144
2145         # 3.8
2146         LC_HAVE_FILE_F_INODE
2147         LC_HAVE_SUNRPC_UPCALL_HAS_3ARGS
2148
2149         # 3.9
2150         LC_HAVE_HLIST_FOR_EACH_3ARG
2151         LC_HAVE_BIO_END_SECTOR
2152
2153         # 3.10
2154         LC_BLKDEV_RELEASE_RETURN_INT
2155         LC_HAVE_REMOVE_PROC_SUBTREE
2156         LC_HAVE_PROC_REMOVE
2157
2158         # 3.11
2159         LC_INVALIDATE_RANGE
2160         LC_HAVE_DIR_CONTEXT
2161         LC_D_COMPARE_5ARGS
2162         LC_HAVE_DCOUNT
2163         LC_HAVE_DENTRY_D_U_D_ALIAS
2164         LC_HAVE_DENTRY_D_CHILD
2165
2166         # 3.12
2167         LC_OLDSIZE_TRUNCATE_PAGECACHE
2168         LC_KIOCB_KI_LEFT
2169
2170         # 3.13
2171         LC_VFS_RENAME_5ARGS
2172         LC_VFS_UNLINK_3ARGS
2173
2174         # 3.14
2175         LC_HAVE_BVEC_ITER
2176         LC_HAVE_TRUNCATE_IPAGES_FINAL
2177
2178         # 3.15
2179         LC_VFS_RENAME_6ARGS
2180
2181         # 3.16
2182         LC_DIRECTIO_USE_ITER
2183         LC_HAVE_IOV_ITER_INIT_DIRECTION
2184         LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
2185
2186         # 3.17
2187         LC_KEY_MATCH_DATA
2188
2189         # 3.18
2190         LC_PERCPU_COUNTER_INIT
2191         LC_NFS_FILLDIR_USE_CTX
2192
2193         # 3.19
2194         LC_KIOCB_HAS_NBYTES
2195
2196         # 3.20
2197         LC_BACKING_DEV_INFO_REMOVAL
2198         LC_HAVE_BDI_CAP_MAP_COPY
2199
2200         # 4.0.0
2201         LC_CANCEL_DIRTY_PAGE
2202
2203         # 4.1.0
2204         LC_IOV_ITER_RW
2205         LC_HAVE_SYNC_READ_WRITE
2206
2207         # 4.2
2208         LC_NEW_CANCEL_DIRTY_PAGE
2209         LC_BIO_ENDIO_USES_ONE_ARG
2210         LC_SYMLINK_OPS_USE_NAMEIDATA
2211
2212         # 4.3
2213         LC_HAVE_CACHE_HEAD_HLIST
2214
2215         # 4.4
2216         LC_HAVE_LOCKS_LOCK_FILE_WAIT
2217         LC_HAVE_QC_MAKE_REQUEST_FN
2218         LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
2219
2220         #
2221         AS_IF([test "x$enable_server" != xno], [
2222                 LC_FUNC_DEV_SET_RDONLY
2223                 LC_STACK_SIZE
2224                 LC_QUOTA64
2225                 LC_QUOTA_CONFIG
2226         ])
2227 ]) # LC_PROG_LINUX
2228
2229 #
2230 # LC_CONFIG_CLIENT
2231 #
2232 # Check whether to build the client side of Lustre
2233 #
2234 AC_DEFUN([LC_CONFIG_CLIENT], [
2235 AC_MSG_CHECKING([whether to build Lustre client support])
2236 AC_ARG_ENABLE([client],
2237         AC_HELP_STRING([--disable-client],
2238                 [disable Lustre client support]),
2239         [], [enable_client="yes"])
2240 AC_MSG_RESULT([$enable_client])
2241 ]) # LC_CONFIG_CLIENT
2242
2243 #
2244 # --enable-mpitests
2245 #
2246 AC_DEFUN([LB_CONFIG_MPITESTS], [
2247 AC_ARG_ENABLE([mpitests],
2248         AC_HELP_STRING([--enable-mpitests=<yes|no|mpicc wrapper>],
2249                        [include mpi tests]), [
2250                 enable_mpitests="yes"
2251                 case $enableval in
2252                 yes)
2253                         MPICC_WRAPPER="mpicc"
2254                         ;;
2255                 no)
2256                         enable_mpitests="no"
2257                         ;;
2258                 *)
2259                         MPICC_WRAPPER=$enableval
2260                         ;;
2261                 esac
2262         ], [
2263                 enable_mpitests="yes"
2264                 MPICC_WRAPPER="mpicc"
2265         ])
2266
2267         if test "x$enable_mpitests" != "xno"; then
2268                 oldcc=$CC
2269                 CC=$MPICC_WRAPPER
2270                 AC_CACHE_CHECK([whether mpitests can be built],
2271                 lb_cv_mpi_tests, [AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2272                         #include <mpi.h>
2273                         int main(void) {
2274                                 int flag;
2275                                 MPI_Initialized(&flag);
2276                                 return 0;
2277                         }
2278                 ])], [lb_cv_mpi_tests="yes"], [lb_cv_mpi_tests="no"])
2279                 ])
2280                 enable_mpitests=$lb_cv_mpi_tests
2281                 CC=$oldcc
2282         fi
2283         AC_SUBST(MPICC_WRAPPER)
2284 ]) # LB_CONFIG_MPITESTS
2285
2286 #
2287 # LC_CONFIG_QUOTA
2288 #
2289 # whether to enable quota support global control
2290 #
2291 AC_DEFUN([LC_CONFIG_QUOTA], [
2292 AC_MSG_CHECKING([whether to enable quota support global control])
2293 AC_ARG_ENABLE([quota],
2294         AC_HELP_STRING([--enable-quota],
2295                 [enable quota support]),
2296         [], [enable_quota="yes"])
2297 AS_IF([test "x$enable_quota" = xyes],
2298         [AC_MSG_RESULT([yes])],
2299         [AC_MSG_RESULT([no])])
2300 ]) # LC_CONFIG_QUOTA
2301
2302 #
2303 # LC_QUOTA
2304 #
2305 AC_DEFUN([LC_QUOTA], [
2306 #check global
2307 LC_CONFIG_QUOTA
2308 #check for utils
2309 AS_IF([test "x$enable_quota" != xno -a "x$enable_utils" != xno], [
2310         AC_CHECK_HEADER([sys/quota.h],
2311                 [AC_DEFINE(HAVE_SYS_QUOTA_H, 1,
2312                         [Define to 1 if you have <sys/quota.h>.])],
2313                 [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
2314 ])
2315 ]) # LC_QUOTA
2316
2317 #
2318 # LC_CONFIG_NODEMAP_PROC_DEBUG
2319 #
2320 # enable nodemap proc file debugging
2321 #
2322 AC_DEFUN([LC_NODEMAP_PROC_DEBUG], [
2323 AC_MSG_CHECKING([whether to enable nodemap proc debug])
2324 AC_ARG_ENABLE([nodemap_proc_debug],
2325         AC_HELP_STRING([--enable-nodemap-proc-debug],
2326                 [enable nodemap proc debug]),
2327         [], [enable_nodemap_proc_debug="no"])
2328 AC_MSG_RESULT([$enable_nodemap_proc_debug])
2329 AS_IF([test "x$enable_nodemap_proc_debug" != xno],
2330         [AC_DEFINE(NODEMAP_PROC_DEBUG, 1,
2331                 [enable nodemap proc debug support])])
2332 ]) # LC_NODEMAP_PROC_DEBUG
2333
2334 #
2335 # LC_LLITE_LLOOP_MODULE
2336 #
2337 # lloop_llite.ko does not currently work with page sizes
2338 # of 64k or larger.
2339 #
2340 AC_DEFUN([LC_LLITE_LLOOP_MODULE], [
2341 LB_CHECK_COMPILE([whether to enable 'llite_lloop' module],
2342 enable_llite_lloop_module, [
2343         #include <asm/page.h>
2344 ],[
2345         #if PAGE_SIZE >= 65536
2346         #error "PAGE_SIZE >= 65536"
2347         #endif
2348 ],
2349         [enable_llite_lloop_module="yes"],
2350         [enable_llite_lloop_module="no"])
2351 ]) # LC_LLITE_LLOOP_MODULE
2352
2353 #
2354 # LC_OSD_ADDON
2355 #
2356 # configure support for optional OSD implementation
2357 #
2358 AC_DEFUN([LC_OSD_ADDON], [
2359 AC_MSG_CHECKING([whether to use OSD addon])
2360 AC_ARG_WITH([osd],
2361         AC_HELP_STRING([--with-osd=path],
2362                 [set path to optional osd]),
2363         [
2364         case "$with_osd" in
2365         no)
2366                 ENABLEOSDADDON=0
2367                 ;;
2368         *)
2369                 OSDADDON="$with_osd"
2370                 ENABLEOSDADDON=1
2371                 ;;
2372         esac
2373         ], [
2374                 ENABLEOSDADDON=0
2375         ])
2376 AS_IF([test $ENABLEOSDADDON -eq 0], [
2377         AC_MSG_RESULT([no])
2378         OSDADDON=""
2379 ], [
2380         OSDMODNAME=$(basename $OSDADDON)
2381         AS_IF([test -e $LUSTRE/$OSDMODNAME], [
2382                 AC_MSG_RESULT([can't link])
2383                 OSDADDON=""
2384         ], [ln -s $OSDADDON $LUSTRE/$OSDMODNAME], [
2385                 AC_MSG_RESULT([$OSDMODNAME])
2386                 OSDADDON="subdir-m += $OSDMODNAME"
2387         ], [
2388                 AC_MSG_RESULT([can't link])
2389                 OSDADDON=""
2390         ])
2391 ])
2392 AC_SUBST(OSDADDON)
2393 ]) # LC_OSD_ADDON
2394
2395 #
2396 # LC_CONFIGURE
2397 #
2398 # other configure checks
2399 #
2400 AC_DEFUN([LC_CONFIGURE], [
2401 AC_MSG_NOTICE([Lustre core checks
2402 ==============================================================================])
2403
2404 LC_CONFIG_OBD_BUFFER_SIZE
2405
2406 AS_IF([test $target_cpu == "i686" -o $target_cpu == "x86_64"],
2407         [CFLAGS="$CFLAGS -Wall -Werror"])
2408
2409 # maximum MDS thread count
2410 LC_MDS_MAX_THREADS
2411
2412 # lustre/utils/gss/gss_util.c
2413 # lustre/utils/gss/gssd_proc.c
2414 # lustre/utils/gss/krb5_util.c
2415 # lustre/utils/llog_reader.c
2416 # lustre/utils/create_iam.c
2417 # lustre/utils/libiam.c
2418 AC_CHECK_HEADERS([netdb.h endian.h])
2419 AC_CHECK_FUNCS([gethostbyname])
2420
2421 # lustre/utils/llverdev.c
2422 AC_CHECK_HEADERS([blkid/blkid.h])
2423
2424 # lustre/utils/llverfs.c
2425 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
2426
2427 SELINUX=""
2428 AC_CHECK_LIB([selinux], [is_selinux_enabled],
2429         [AC_CHECK_HEADERS([selinux/selinux.h],
2430                         [SELINUX="-lselinux"
2431                         AC_DEFINE([HAVE_SELINUX], 1,
2432                                 [support for selinux ])],
2433                         [AC_MSG_WARN([
2434
2435 No libselinux-devel package found, unable to build selinux enabled tools
2436 ])
2437 ])],
2438         [AC_MSG_WARN([
2439
2440 No selinux package found, unable to build selinux enabled tools
2441 ])
2442 ])
2443 AC_SUBST(SELINUX)
2444
2445 # Super safe df
2446 AC_MSG_CHECKING([whether to report minimum OST free space])
2447 AC_ARG_ENABLE([mindf],
2448         AC_HELP_STRING([--enable-mindf],
2449                 [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
2450         [], [enable_mindf="no"])
2451 AC_MSG_RESULT([$enable_mindf])
2452 AS_IF([test "$enable_mindf" = "yes"],
2453         [AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])])
2454
2455 AC_MSG_CHECKING([whether to randomly failing memory alloc])
2456 AC_ARG_ENABLE([fail_alloc],
2457         AC_HELP_STRING([--disable-fail-alloc],
2458                 [disable randomly alloc failure]),
2459         [], [enable_fail_alloc="yes"])
2460 AC_MSG_RESULT([$enable_fail_alloc])
2461 AS_IF([test "x$enable_fail_alloc" != xno],
2462         [AC_DEFINE([RANDOM_FAIL_ALLOC], 1,
2463                 [enable randomly alloc failure])])
2464
2465 AC_MSG_CHECKING([whether to check invariants (expensive cpu-wise)])
2466 AC_ARG_ENABLE([invariants],
2467         AC_HELP_STRING([--enable-invariants],
2468                 [enable invariant checking (cpu intensive)]),
2469         [], [enable_invariants="no"])
2470 AC_MSG_RESULT([$enable_invariants])
2471 AS_IF([test "x$enable_invariants" = xyes],
2472         [AC_DEFINE([CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK], 1,
2473                 [enable invariant checking])])
2474
2475 AC_MSG_CHECKING([whether to track references with lu_ref])
2476 AC_ARG_ENABLE([lu_ref],
2477         AC_HELP_STRING([--enable-lu_ref],
2478                 [enable lu_ref reference tracking code]),
2479         [], [enable_lu_ref="no"])
2480 AC_MSG_RESULT([$enable_lu_ref])
2481 AS_IF([test "x$enable_lu_ref" = xyes],
2482         [AC_DEFINE([USE_LU_REF], 1,
2483                 [enable lu_ref reference tracking code])])
2484
2485 AC_MSG_CHECKING([whether to enable page state tracking])
2486 AC_ARG_ENABLE([pgstate-track],
2487         AC_HELP_STRING([--enable-pgstate-track],
2488                 [enable page state tracking]),
2489         [], [enable_pgstat_track="no"])
2490 AC_MSG_RESULT([$enable_pgstat_track])
2491 AS_IF([test "x$enable_pgstat_track" = xyes],
2492         [AC_DEFINE([CONFIG_DEBUG_PAGESTATE_TRACKING], 1,
2493                 [enable page state tracking code])])
2494 ]) # LC_CONFIGURE
2495
2496 #
2497 # LC_CONDITIONALS
2498 #
2499 # AM_CONDITIONALS for lustre
2500 #
2501 AC_DEFUN([LC_CONDITIONALS], [
2502 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
2503 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
2504 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
2505 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
2506 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
2507 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
2508 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
2509 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
2510 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
2511 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
2512 AM_CONDITIONAL(LLITE_LLOOP, test x$enable_llite_lloop_module = xyes)
2513 ]) # LC_CONDITIONALS
2514
2515 #
2516 # LC_CONFIG_FILES
2517 #
2518 # files that should be generated with AC_OUTPUT
2519 #
2520 AC_DEFUN([LC_CONFIG_FILES],
2521 [AC_CONFIG_FILES([
2522 lustre/Makefile
2523 lustre/autoMakefile
2524 lustre/autoconf/Makefile
2525 lustre/conf/Makefile
2526 lustre/contrib/Makefile
2527 lustre/doc/Makefile
2528 lustre/include/Makefile
2529 lustre/include/lustre/Makefile
2530 lustre/kernel_patches/targets/3.10-rhel7.target
2531 lustre/kernel_patches/targets/2.6-rhel6.8.target
2532 lustre/kernel_patches/targets/2.6-rhel6.7.target
2533 lustre/kernel_patches/targets/2.6-rhel6.6.target
2534 lustre/kernel_patches/targets/2.6-rhel6.target
2535 lustre/kernel_patches/targets/2.6-rhel5.target
2536 lustre/kernel_patches/targets/2.6-sles11.target
2537 lustre/kernel_patches/targets/3.0-sles11.target
2538 lustre/kernel_patches/targets/3.0-sles11sp3.target
2539 lustre/kernel_patches/targets/3.0-sles11sp4.target
2540 lustre/kernel_patches/targets/3.12-sles12.target
2541 lustre/kernel_patches/targets/2.6-fc11.target
2542 lustre/kernel_patches/targets/2.6-fc12.target
2543 lustre/kernel_patches/targets/2.6-fc15.target
2544 lustre/kernel_patches/targets/3.x-fc18.target
2545 lustre/ldlm/Makefile
2546 lustre/fid/Makefile
2547 lustre/fid/autoMakefile
2548 lustre/llite/Makefile
2549 lustre/llite/autoMakefile
2550 lustre/lov/Makefile
2551 lustre/lov/autoMakefile
2552 lustre/mdc/Makefile
2553 lustre/mdc/autoMakefile
2554 lustre/lmv/Makefile
2555 lustre/lmv/autoMakefile
2556 lustre/lfsck/Makefile
2557 lustre/lfsck/autoMakefile
2558 lustre/mdt/Makefile
2559 lustre/mdt/autoMakefile
2560 lustre/mdd/Makefile
2561 lustre/mdd/autoMakefile
2562 lustre/fld/Makefile
2563 lustre/fld/autoMakefile
2564 lustre/obdclass/Makefile
2565 lustre/obdclass/autoMakefile
2566 lustre/obdclass/linux/Makefile
2567 lustre/obdecho/Makefile
2568 lustre/obdecho/autoMakefile
2569 lustre/ofd/Makefile
2570 lustre/ofd/autoMakefile
2571 lustre/osc/Makefile
2572 lustre/osc/autoMakefile
2573 lustre/ost/Makefile
2574 lustre/ost/autoMakefile
2575 lustre/osd-ldiskfs/Makefile
2576 lustre/osd-ldiskfs/autoMakefile
2577 lustre/osd-zfs/Makefile
2578 lustre/osd-zfs/autoMakefile
2579 lustre/mgc/Makefile
2580 lustre/mgc/autoMakefile
2581 lustre/mgs/Makefile
2582 lustre/mgs/autoMakefile
2583 lustre/target/Makefile
2584 lustre/ptlrpc/Makefile
2585 lustre/ptlrpc/autoMakefile
2586 lustre/ptlrpc/gss/Makefile
2587 lustre/ptlrpc/gss/autoMakefile
2588 lustre/quota/Makefile
2589 lustre/quota/autoMakefile
2590 lustre/scripts/Makefile
2591 lustre/tests/Makefile
2592 lustre/tests/mpi/Makefile
2593 lustre/utils/Makefile
2594 lustre/utils/gss/Makefile
2595 lustre/osp/Makefile
2596 lustre/osp/autoMakefile
2597 lustre/lod/Makefile
2598 lustre/lod/autoMakefile
2599 ])
2600 ]) # LC_CONFIG_FILES