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