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