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