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