Whamcloud - gitweb
e167ac01c3747f906f3441b2bc72d6b380740801
[fs/lustre-release.git] / lustre / autoconf / lustre-core.m4
1 #* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 #* vim:expandtab:shiftwidth=8:tabstop=8:
3 #
4 # LC_CONFIG_SRCDIR
5 #
6 # Wrapper for AC_CONFIG_SUBDIR
7 #
8 AC_DEFUN([LC_CONFIG_SRCDIR],
9 [AC_CONFIG_SRCDIR([lustre/obdclass/obdo.c])
10 libcfs_is_module=yes
11 ldiskfs_is_ext4=yes
12 ])
13
14 #
15 # LC_PATH_DEFAULTS
16 #
17 # lustre specific paths
18 #
19 AC_DEFUN([LC_PATH_DEFAULTS],
20 [# ptlrpc kernel build requires this
21 LUSTRE="$PWD/lustre"
22 AC_SUBST(LUSTRE)
23
24 # mount.lustre
25 rootsbindir='/sbin'
26 AC_SUBST(rootsbindir)
27
28 demodir='$(docdir)/demo'
29 AC_SUBST(demodir)
30
31 pkgexampledir='${pkgdatadir}/examples'
32 AC_SUBST(pkgexampledir)
33 ])
34
35 #
36 # LC_TARGET_SUPPORTED
37 #
38 # is the target os supported?
39 #
40 AC_DEFUN([LC_TARGET_SUPPORTED],
41 [case $target_os in
42         linux* | darwin*)
43 $1
44                 ;;
45         *)
46 $2
47                 ;;
48 esac
49 ])
50
51 #
52 # LC_CONFIG_OBD_BUFFER_SIZE
53 #
54 # the maximum buffer size of lctl ioctls
55 #
56 AC_DEFUN([LC_CONFIG_OBD_BUFFER_SIZE],
57 [AC_MSG_CHECKING([maximum OBD ioctl size])
58 AC_ARG_WITH([obd-buffer-size],
59         AC_HELP_STRING([--with-obd-buffer-size=[size]],
60                         [set lctl ioctl maximum bytes (default=8192)]),
61         [
62                 OBD_BUFFER_SIZE=$with_obd_buffer_size
63         ],[
64                 OBD_BUFFER_SIZE=8192
65         ])
66 AC_MSG_RESULT([$OBD_BUFFER_SIZE bytes])
67 AC_DEFINE_UNQUOTED(OBD_MAX_IOCTL_BUFFER, $OBD_BUFFER_SIZE, [IOCTL Buffer Size])
68 ])
69
70 #
71 # LC_READLINK_SSIZE_T
72 #
73 AC_DEFUN([LC_READLINK_SSIZE_T],
74 [AC_MSG_CHECKING([if readlink returns ssize_t])
75 AC_TRY_COMPILE([
76         #include <unistd.h>
77 ],[
78         ssize_t readlink(const char *, char *, size_t);
79 ],[
80         AC_MSG_RESULT([yes])
81         AC_DEFINE(HAVE_POSIX_1003_READLINK, 1, [readlink returns ssize_t])
82 ],[
83         AC_MSG_RESULT([no])
84 ])
85 ])
86
87 #
88 # only for Lustre-patched kernels
89 #
90 AC_DEFUN([LC_LUSTRE_VERSION_H],
91 [LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
92         rm -f "$LUSTRE/include/linux/lustre_version.h"
93 ],[
94         touch "$LUSTRE/include/linux/lustre_version.h"
95         if test x$enable_server = xyes ; then
96                 AC_MSG_WARN([Unpatched kernel detected.])
97                 AC_MSG_WARN([Lustre servers cannot be built with an unpatched kernel;])
98                 AC_MSG_WARN([disabling server build])
99                 enable_server='no'
100         fi
101 ])
102 ])
103
104 #
105 # LC_FUNC_DEV_SET_RDONLY
106 #
107 # check for the old-style dev_set_rdonly which took an extra "devno" param
108 # and can only set a single device to discard writes at one time
109 #
110 AC_DEFUN([LC_FUNC_DEV_SET_RDONLY],
111 [AC_MSG_CHECKING([if kernel has new dev_set_rdonly])
112 LB_LINUX_TRY_COMPILE([
113         #include <linux/fs.h>
114         #include <linux/blkdev.h>
115 ],[
116         #ifndef HAVE_CLEAR_RDONLY_ON_PUT
117         #error needs to be patched by lustre kernel patches from Lustre version 1.4.3 or above.
118         #endif
119 ],[
120         AC_MSG_RESULT([yes])
121         AC_DEFINE(HAVE_DEV_SET_RDONLY, 1, [kernel has new dev_set_rdonly])
122 ],[
123         AC_MSG_ERROR([no, Linux kernel source needs to be patches by lustre
124 kernel patches from Lustre version 1.4.3 or above.])
125 ])
126 ])
127
128 #
129 # Ensure stack size big than 8k in Lustre server (all kernels)
130 #
131 AC_DEFUN([LC_STACK_SIZE],
132 [AC_MSG_CHECKING([stack size big than 8k])
133 LB_LINUX_TRY_COMPILE([
134         #include <linux/thread_info.h>
135 ],[
136         #if THREAD_SIZE < 8192
137         #error "stack size < 8192"
138         #endif
139 ],[
140         AC_MSG_RESULT(yes)
141 ],[
142         AC_MSG_ERROR([Lustre requires that Linux is configured with at least a 8KB stack.])
143 ])
144 ])
145
146 #
147 # Allow the user to set the MDS thread upper limit
148 #
149 AC_DEFUN([LC_MDS_MAX_THREADS],
150 [
151         AC_ARG_WITH([mds_max_threads],
152         AC_HELP_STRING([--with-mds-max-threads=size],
153                         [define the maximum number of threads available on the MDS: (default=512)]),
154         [
155                 MDS_THREAD_COUNT=$with_mds_max_threads
156                 AC_DEFINE_UNQUOTED(MDT_MAX_THREADS, $MDS_THREAD_COUNT, [maximum number of mdt threads])
157         ])
158 ])
159
160 #
161 # LC_CONFIG_PINGER
162 #
163 # the pinger is temporary, until we have the recovery node in place
164 #
165 AC_DEFUN([LC_CONFIG_PINGER],
166 [AC_MSG_CHECKING([whether to enable pinger support])
167 AC_ARG_ENABLE([pinger],
168         AC_HELP_STRING([--disable-pinger],
169                         [disable recovery pinger support]),
170         [],[enable_pinger='yes'])
171 AC_MSG_RESULT([$enable_pinger])
172 if test x$enable_pinger != xno ; then
173   AC_DEFINE(ENABLE_PINGER, 1, Use the Pinger)
174 fi
175 ])
176
177 #
178 # LC_CONFIG_CHECKSUM
179 #
180 # do checksum of bulk data between client and OST
181 #
182 AC_DEFUN([LC_CONFIG_CHECKSUM],
183 [AC_MSG_CHECKING([whether to enable data checksum support])
184 AC_ARG_ENABLE([checksum],
185        AC_HELP_STRING([--disable-checksum],
186                        [disable data checksum support]),
187        [],[enable_checksum='yes'])
188 AC_MSG_RESULT([$enable_checksum])
189 if test x$enable_checksum != xno ; then
190   AC_DEFINE(ENABLE_CHECKSUM, 1, do data checksums)
191 fi
192 ])
193
194 #
195 # LC_CONFIG_LIBLUSTRE_RECOVERY
196 #
197 AC_DEFUN([LC_CONFIG_LIBLUSTRE_RECOVERY],
198 [AC_MSG_CHECKING([whether to enable liblustre recovery support])
199 AC_ARG_ENABLE([liblustre-recovery],
200         AC_HELP_STRING([--disable-liblustre-recovery],
201                         [disable liblustre recovery support]),
202         [],[enable_liblustre_recovery='yes'])
203 AC_MSG_RESULT([$enable_liblustre_recovery])
204 if test x$enable_liblustre_recovery != xno ; then
205   AC_DEFINE(ENABLE_LIBLUSTRE_RECOVERY, 1, Liblustre Can Recover)
206 fi
207 ])
208
209 #
210 # LC_CONFIG_HEALTH_CHECK_WRITE
211 #
212 # Turn off the actual write to the disk
213 #
214 AC_DEFUN([LC_CONFIG_HEALTH_CHECK_WRITE],
215 [AC_MSG_CHECKING([whether to enable a write with the health check])
216 AC_ARG_ENABLE([health_write],
217         AC_HELP_STRING([--enable-health_write],
218                         [enable disk writes when doing health check]),
219         [],[enable_health_write='no'])
220 AC_MSG_RESULT([$enable_health_write])
221 if test x$enable_health_write != xno ; then
222   AC_DEFINE(USE_HEALTH_CHECK_WRITE, 1, Write when Checking Health)
223 fi
224 ])
225
226 AC_DEFUN([LC_CONFIG_LRU_RESIZE],
227 [AC_MSG_CHECKING([whether to enable lru self-adjusting])
228 AC_ARG_ENABLE([lru_resize],
229         AC_HELP_STRING([--enable-lru-resize],
230                         [enable lru resize support]),
231         [],[enable_lru_resize='yes'])
232 AC_MSG_RESULT([$enable_lru_resize])
233 if test x$enable_lru_resize != xno; then
234    AC_DEFINE(HAVE_LRU_RESIZE_SUPPORT, 1, [Enable lru resize support])
235 fi
236 ])
237
238 # whether to enable quota support(kernel modules)
239 AC_DEFUN([LC_QUOTA_MODULE],
240 [if test x$enable_quota != xno; then
241     LB_LINUX_CONFIG([QUOTA],[
242         enable_quota_module='yes'
243         AC_DEFINE(HAVE_QUOTA_SUPPORT, 1, [Enable quota support])
244     ],[
245         enable_quota_module='no'
246         AC_MSG_WARN([quota is not enabled because the kernel - lacks quota support])
247     ])
248 fi
249 ])
250
251 # truncate_complete_page() was exported from RHEL5/SLES10, but not in SLES11 SP0 (2.6.27)
252 # remove_from_page_cache() was exported between 2.6.35 and 2.6.38
253 # delete_from_page_cache() is exported from 2.6.39
254 AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE],
255          [LB_CHECK_SYMBOL_EXPORT([truncate_complete_page],
256                                  [mm/truncate.c],
257                                  [AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
258                                             [kernel export truncate_complete_page])])
259           LB_CHECK_SYMBOL_EXPORT([remove_from_page_cache],
260                                  [mm/filemap.c],
261                                  [AC_DEFINE(HAVE_REMOVE_FROM_PAGE_CACHE, 1,
262                                             [kernel export remove_from_page_cache])])
263           LB_CHECK_SYMBOL_EXPORT([delete_from_page_cache],
264                                  [mm/filemap.c],
265                                  [AC_DEFINE(HAVE_DELETE_FROM_PAGE_CACHE, 1,
266                                             [kernel export delete_from_page_cache])])
267          ])
268
269 AC_DEFUN([LC_EXPORT_D_REHASH_COND],
270 [LB_CHECK_SYMBOL_EXPORT([d_rehash_cond],
271 [fs/dcache.c],[
272 AC_DEFINE(HAVE_D_REHASH_COND, 1,
273             [d_rehash_cond is exported by the kernel])
274 ],[
275 ])
276 ])
277
278 AC_DEFUN([LC_EXPORT___D_REHASH],
279 [LB_CHECK_SYMBOL_EXPORT([__d_rehash],
280 [fs/dcache.c],[
281 AC_DEFINE(HAVE___D_REHASH, 1,
282             [__d_rehash is exported by the kernel])
283 ],[
284 ])
285 ])
286
287 # The actual symbol exported varies among architectures, so we need
288 # to check many symbols (but only in the current architecture.)  No
289 # matter what symbol is exported, the kernel #defines node_to_cpumask
290 # to the appropriate function and that's what we use.
291 AC_DEFUN([LC_EXPORT_NODE_TO_CPUMASK],
292          [LB_CHECK_SYMBOL_EXPORT([node_to_cpumask],
293                                  [arch/$LINUX_ARCH/mm/numa.c],
294                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
295                                             [node_to_cpumask is exported by
296                                              the kernel])]) # x86_64
297           LB_CHECK_SYMBOL_EXPORT([node_to_cpu_mask],
298                                  [arch/$LINUX_ARCH/kernel/smpboot.c],
299                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
300                                             [node_to_cpumask is exported by
301                                              the kernel])]) # ia64
302           LB_CHECK_SYMBOL_EXPORT([node_2_cpu_mask],
303                                  [arch/$LINUX_ARCH/kernel/smpboot.c],
304                                  [AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1,
305                                             [node_to_cpumask is exported by
306                                              the kernel])]) # i386
307           ])
308
309 #
310 # LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
311 #
312 # Check for our patched grab_cache_page_nowait_gfp() function
313 # after 2.6.29 we can emulate this using add_to_page_cache_lru()
314 #
315 AC_DEFUN([LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP],
316 [LB_CHECK_SYMBOL_EXPORT([grab_cache_page_nowait_gfp],
317 [mm/filemap.c],[
318         AC_DEFINE(HAVE_GRAB_CACHE_PAGE_NOWAIT_GFP, 1,
319                   [kernel exports grab_cache_page_nowait_gfp])
320         ],
321         [LB_CHECK_SYMBOL_EXPORT([add_to_page_cache_lru],
322         [mm/filemap.c],[
323                 AC_DEFINE(HAVE_ADD_TO_PAGE_CACHE_LRU, 1,
324                         [kernel exports add_to_page_cache_lru])
325         ],[
326         ])
327         ])
328 ])
329
330 #
331 #
332 # between 2.6.5 - 2.6.22 filemap_populate is exported in some kernels
333 #
334 AC_DEFUN([LC_FILEMAP_POPULATE],
335 [AC_MSG_CHECKING([for exported filemap_populate])
336 LB_LINUX_TRY_COMPILE([
337         #include <asm/page.h>
338         #include <linux/mm.h>
339 ],[
340        filemap_populate(NULL, 0, 0, __pgprot(0), 0, 0);
341 ],[
342         AC_MSG_RESULT([yes])
343         AC_DEFINE(HAVE_FILEMAP_POPULATE, 1, [Kernel exports filemap_populate])
344 ],[
345         AC_MSG_RESULT([no])
346 ])
347 ])
348
349 #
350 # added in 2.6.17
351 #
352 AC_DEFUN([LC_BIT_SPINLOCK_H],
353 [LB_CHECK_FILE([$LINUX/include/linux/bit_spinlock.h],[
354         AC_MSG_CHECKING([if bit_spinlock.h can be compiled])
355         LB_LINUX_TRY_COMPILE([
356                 #include <asm/processor.h>
357                 #include <linux/spinlock.h>
358                 #include <linux/bit_spinlock.h>
359         ],[],[
360                 AC_MSG_RESULT([yes])
361                 AC_DEFINE(HAVE_BIT_SPINLOCK_H, 1, [Kernel has bit_spinlock.h])
362         ],[
363                 AC_MSG_RESULT([no])
364         ])
365 ],
366 [])
367 ])
368
369 #
370 # LC_CONST_ACL_SIZE
371 #
372 AC_DEFUN([LC_CONST_ACL_SIZE],
373 [AC_MSG_CHECKING([calc acl size])
374 tmp_flags="$CFLAGS"
375 CFLAGS="$CFLAGS -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -I$LINUX/arch/`uname -m|sed -e 's/ppc.*/powerpc/' -e 's/x86_64/x86/' -e 's/i.86/x86/'`/include -include $AUTOCONF_HDIR/autoconf.h $EXTRA_KCFLAGS"
376 AC_TRY_RUN([
377         #define __KERNEL__
378         #include <linux/types.h>
379         #undef __KERNEL__
380         // block include
381         #define __LINUX_POSIX_ACL_H
382
383         #ifdef CONFIG_FS_POSIX_ACL
384         # include <linux/posix_acl_xattr.h>
385         #endif
386
387         #include <stdio.h>
388
389         int main(void)
390         {
391                 /* LUSTRE_POSIX_ACL_MAX_ENTRIES  = 32 */
392             int size = posix_acl_xattr_size(32);
393             FILE *f = fopen("acl.size","w+");
394             fprintf(f,"%d", size);
395             fclose(f);
396
397             return 0;
398         }
399 ],[
400         acl_size=`cat acl.size`
401         AC_MSG_RESULT([ACL size $acl_size])
402         AC_DEFINE_UNQUOTED(XATTR_ACL_SIZE, AS_TR_SH([$acl_size]), [size of xattr acl])
403 ],[
404         AC_ERROR([ACL size can't be computed])
405 ],[
406         AC_MSG_RESULT([can't check ACL size, make it 260])
407         AC_DEFINE_UNQUOTED(XATTR_ACL_SIZE,260)
408 ])
409 CFLAGS="$tmp_flags"
410 ])
411
412 # added in 2.6.16
413 #
414 AC_DEFUN([LC_STRUCT_INTENT_FILE],
415 [AC_MSG_CHECKING([if struct open_intent has a file field])
416 LB_LINUX_TRY_COMPILE([
417         #include <linux/fs.h>
418         #include <linux/namei.h>
419 ],[
420         struct open_intent intent;
421         &intent.file;
422 ],[
423         AC_MSG_RESULT([yes])
424         AC_DEFINE(HAVE_FILE_IN_STRUCT_INTENT, 1, [struct open_intent has a file field])
425 ],[
426         AC_MSG_RESULT([no])
427 ])
428 ])
429
430 #
431 # LC_CAPA_CRYPTO
432 #
433 AC_DEFUN([LC_CAPA_CRYPTO],
434 [LB_LINUX_CONFIG_IM([CRYPTO],[],[
435         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO is enabled in your kernel.])
436 ])
437 LB_LINUX_CONFIG_IM([CRYPTO_HMAC],[],[
438         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO_HMAC is enabled in your kernel.])
439 ])
440 LB_LINUX_CONFIG_IM([CRYPTO_SHA1],[],[
441         AC_MSG_ERROR([Lustre capability require that CONFIG_CRYPTO_SHA1 is enabled in your kernel.])
442 ])
443 ])
444
445 #
446 # LC_CONFIG_RMTCLIENT
447 #
448 dnl FIXME
449 dnl the AES symbol usually tied with arch, e.g. CRYPTO_AES_586
450 dnl FIXME
451 AC_DEFUN([LC_CONFIG_RMTCLIENT],
452 [LB_LINUX_CONFIG_IM([CRYPTO_AES],[],[
453         AC_MSG_WARN([Lustre remote client require that CONFIG_CRYPTO_AES is enabled in your kernel.])
454 ])
455 ])
456
457 #
458 # LC_CONFIG_GSS_KEYRING (default enabled, if gss is enabled)
459 #
460 AC_DEFUN([LC_CONFIG_GSS_KEYRING],
461 [AC_MSG_CHECKING([whether to enable gss keyring backend])
462  AC_ARG_ENABLE([gss_keyring],
463                [AC_HELP_STRING([--disable-gss-keyring],
464                                [disable gss keyring backend])],
465                [],[enable_gss_keyring='yes'])
466  AC_MSG_RESULT([$enable_gss_keyring])
467
468  if test x$enable_gss_keyring != xno; then
469         LB_LINUX_CONFIG_IM([KEYS],[],
470                            [AC_MSG_ERROR([GSS keyring backend require that CONFIG_KEYS be enabled in your kernel.])])
471
472         AC_CHECK_LIB([keyutils], [keyctl_search], [],
473                      [AC_MSG_ERROR([libkeyutils is not found, which is required by gss keyring backend])],)
474
475         AC_DEFINE([HAVE_GSS_KEYRING], [1],
476                   [Define this if you enable gss keyring backend])
477  fi
478 ])
479
480 AC_DEFUN([LC_SUNRPC_CACHE],
481 [AC_MSG_CHECKING([if sunrpc struct cache_head uses kref])
482 LB_LINUX_TRY_COMPILE([
483         #include <linux/sunrpc/cache.h>
484 ],[
485         struct cache_head ch;
486         &ch.ref.refcount;
487 ],[
488         AC_MSG_RESULT([yes])
489         AC_DEFINE(HAVE_SUNRPC_CACHE_V2, 1, [sunrpc cache facility v2])
490 ],[
491         AC_MSG_RESULT([no])
492 ])
493 ])
494
495 AC_DEFUN([LC_CONFIG_SUNRPC],
496 [LB_LINUX_CONFIG_IM([SUNRPC],[],
497                     [AC_MSG_ERROR([kernel SUNRPC support is required by using GSS.])])
498  LC_SUNRPC_CACHE
499 ])
500
501 #
502 # LC_CONFIG_GSS (default disabled)
503 #
504 # Build gss and related tools of Lustre. Currently both kernel and user space
505 # parts are depend on linux platform.
506 #
507 AC_DEFUN([LC_CONFIG_GSS],
508 [AC_MSG_CHECKING([whether to enable gss/krb5 support])
509  AC_ARG_ENABLE([gss],
510                [AC_HELP_STRING([--enable-gss], [enable gss/krb5 support])],
511                [],[enable_gss='no'])
512  AC_MSG_RESULT([$enable_gss])
513
514  if test x$enable_gss == xyes; then
515         LC_CONFIG_GSS_KEYRING
516         LC_CONFIG_SUNRPC
517
518         AC_DEFINE([HAVE_GSS], [1], [Define this if you enable gss])
519
520         LB_LINUX_CONFIG_IM([CRYPTO_MD5],[],
521                            [AC_MSG_WARN([kernel MD5 support is recommended by using GSS.])])
522         LB_LINUX_CONFIG_IM([CRYPTO_SHA1],[],
523                            [AC_MSG_WARN([kernel SHA1 support is recommended by using GSS.])])
524         LB_LINUX_CONFIG_IM([CRYPTO_SHA256],[],
525                            [AC_MSG_WARN([kernel SHA256 support is recommended by using GSS.])])
526         LB_LINUX_CONFIG_IM([CRYPTO_SHA512],[],
527                            [AC_MSG_WARN([kernel SHA512 support is recommended by using GSS.])])
528
529         AC_CHECK_LIB([gssapi], [gss_init_sec_context],
530                      [GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssapi"],
531                      [AC_CHECK_LIB([gssglue], [gss_init_sec_context],
532                                    [GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssglue"],
533                                    [AC_MSG_ERROR([libgssapi or libgssglue is not found, which is required by GSS.])])],)
534
535         AC_SUBST(GSSAPI_LIBS)
536
537         AC_KERBEROS_V5
538  fi
539 ])
540
541 #
542 # LC_FUNC_HAVE_CAN_SLEEP_ARG
543 #
544 # 2.6.5 kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()
545 #
546 AC_DEFUN([LC_FUNC_HAVE_CAN_SLEEP_ARG],
547 [AC_MSG_CHECKING([if kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
548 LB_LINUX_TRY_COMPILE([
549         #include <linux/fs.h>
550 ],[
551         int cansleep;
552         struct file *file;
553         struct file_lock *file_lock;
554         flock_lock_file_wait(file, file_lock, cansleep);
555 ],[
556         AC_DEFINE(HAVE_CAN_SLEEP_ARG, 1,
557                 [kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
558         AC_MSG_RESULT([yes])
559 ],[
560         AC_MSG_RESULT([no])
561 ])
562 ])
563
564 #
565 # LC_FUNC_F_OP_FLOCK
566 #
567 # rhel4.2 kernel has f_op->flock field
568 #
569 AC_DEFUN([LC_FUNC_F_OP_FLOCK],
570 [AC_MSG_CHECKING([if struct file_operations has flock field])
571 LB_LINUX_TRY_COMPILE([
572         #include <linux/fs.h>
573 ],[
574         struct file_operations ll_file_operations_flock;
575         ll_file_operations_flock.flock = NULL;
576 ],[
577         AC_DEFINE(HAVE_F_OP_FLOCK, 1,
578                 [struct file_operations has flock field])
579         AC_MSG_RESULT([yes])
580 ],[
581         AC_MSG_RESULT([no])
582 ])
583 ])
584
585 AC_DEFUN([LC_QUOTA_READ],
586 [AC_MSG_CHECKING([if kernel supports quota_read])
587 LB_LINUX_TRY_COMPILE([
588         #include <linux/fs.h>
589 ],[
590         struct super_operations sp;
591         void *i = (void *)sp.quota_read;
592 ],[
593         AC_MSG_RESULT([yes])
594         AC_DEFINE(KERNEL_SUPPORTS_QUOTA_READ, 1, [quota_read found])
595 ],[
596         AC_MSG_RESULT([no])
597 ])
598 ])
599
600 #
601 # LC_COOKIE_FOLLOW_LINK
602 #
603 # kernel 2.6.13+ ->follow_link returns a cookie
604 #
605
606 AC_DEFUN([LC_COOKIE_FOLLOW_LINK],
607 [AC_MSG_CHECKING([if inode_operations->follow_link returns a cookie])
608 LB_LINUX_TRY_COMPILE([
609         #include <linux/fs.h>
610         #include <linux/namei.h>
611 ],[
612         struct dentry dentry;
613         struct nameidata nd;
614
615         dentry.d_inode->i_op->put_link(&dentry, &nd, NULL);
616 ],[
617         AC_DEFINE(HAVE_COOKIE_FOLLOW_LINK, 1, [inode_operations->follow_link returns a cookie])
618         AC_MSG_RESULT([yes])
619 ],[
620         AC_MSG_RESULT([no])
621 ])
622 ])
623
624 #
625 # LC_FUNC_RCU
626 #
627 # kernels prior than 2.6.0(?) have no RCU supported; in kernel 2.6.5(SUSE),
628 # call_rcu takes three parameters.
629 #
630 AC_DEFUN([LC_FUNC_RCU],
631 [AC_MSG_CHECKING([if kernel have RCU supported])
632 LB_LINUX_TRY_COMPILE([
633         #include <linux/rcupdate.h>
634 ],[],[
635         AC_DEFINE(HAVE_RCU, 1, [have RCU defined])
636         AC_MSG_RESULT([yes])
637
638         AC_MSG_CHECKING([if call_rcu takes three parameters])
639         LB_LINUX_TRY_COMPILE([
640                 #include <linux/rcupdate.h>
641         ],[
642                 struct rcu_head rh;
643                 call_rcu(&rh, (void (*)(struct rcu_head *))1, NULL);
644         ],[
645                 AC_DEFINE(HAVE_CALL_RCU_PARAM, 1, [call_rcu takes three parameters])
646                 AC_MSG_RESULT([yes])
647         ],[
648                 AC_MSG_RESULT([no])
649         ])
650
651 ],[
652         AC_MSG_RESULT([no])
653 ])
654 ])
655
656 AC_DEFUN([LC_PERCPU_COUNTER],
657 [AC_MSG_CHECKING([if have struct percpu_counter defined])
658 LB_LINUX_TRY_COMPILE([
659         #include <linux/percpu_counter.h>
660 ],[],[
661         AC_DEFINE(HAVE_PERCPU_COUNTER, 1, [percpu_counter found])
662         AC_MSG_RESULT([yes])
663
664         AC_MSG_CHECKING([if percpu_counter_inc takes the 2nd argument])
665         LB_LINUX_TRY_COMPILE([
666                 #include <linux/percpu_counter.h>
667         ],[
668                 struct percpu_counter c;
669                 percpu_counter_init(&c, 0);
670         ],[
671                 AC_DEFINE(HAVE_PERCPU_2ND_ARG, 1, [percpu_counter_init has two
672                                                    arguments])
673                 AC_MSG_RESULT([yes])
674         ],[
675                 AC_MSG_RESULT([no])
676         ])
677 ],[
678         AC_MSG_RESULT([no])
679 ])
680 ])
681
682 AC_DEFUN([LC_TASK_CLENV_STORE],
683 [
684         AC_MSG_CHECKING([if we can store cl_env in task_struct])
685         if test x$have_task_clenv_store != xyes ; then
686                 LC_TASK_CLENV_TUX_INFO
687         fi
688 ])
689
690 # ~2.6.11
691
692 AC_DEFUN([LC_S_TIME_GRAN],
693 [AC_MSG_CHECKING([if super block has s_time_gran member])
694 LB_LINUX_TRY_COMPILE([
695         #include <linux/fs.h>
696 ],[
697         struct super_block sb;
698
699         return sb.s_time_gran;
700 ],[
701         AC_MSG_RESULT([yes])
702         AC_DEFINE(HAVE_S_TIME_GRAN, 1, [super block has s_time_gran member])
703 ],[
704         AC_MSG_RESULT([no])
705 ])
706 ])
707
708 AC_DEFUN([LC_SB_TIME_GRAN],
709 [AC_MSG_CHECKING([if kernel has old get_sb_time_gran])
710 LB_LINUX_TRY_COMPILE([
711         #include <linux/fs.h>
712 ],[
713         return get_sb_time_gran(NULL);
714 ],[
715         AC_MSG_RESULT([yes])
716         AC_DEFINE(HAVE_SB_TIME_GRAN, 1, [kernel has old get_sb_time_gran])
717 ],[
718         AC_MSG_RESULT([no])
719 ])
720 ])
721
722 # 2.6.12
723
724 # ~2.6.12 merge patch from oracle to convert tree_lock from spinlock to rwlock
725 AC_DEFUN([LC_RW_TREE_LOCK],
726 [AC_MSG_CHECKING([if kernel has tree_lock as rwlock])
727 tmp_flags="$EXTRA_KCFLAGS"
728 EXTRA_KCFLAGS="-Werror"
729 LB_LINUX_TRY_COMPILE([
730         #include <linux/fs.h>
731 ],[
732         struct address_space a;
733
734         write_lock(&a.tree_lock);
735 ],[
736         AC_MSG_RESULT([yes])
737         AC_DEFINE(HAVE_RW_TREE_LOCK, 1, [kernel has tree_lock as rw_lock])
738 ],[
739         AC_MSG_RESULT([no])
740 ])
741 EXTRA_KCFLAGS="$tmp_flags"
742 ])
743
744 # 2.6.15
745
746 # LC_INODE_I_MUTEX
747 # after 2.6.15 inode have i_mutex intead of i_sem
748 AC_DEFUN([LC_INODE_I_MUTEX],
749 [AC_MSG_CHECKING([if inode has i_mutex ])
750 LB_LINUX_TRY_COMPILE([
751         #include <linux/mutex.h>
752         #include <linux/fs.h>
753         #undef i_mutex
754 ],[
755         struct inode i;
756
757         mutex_unlock(&i.i_mutex);
758 ],[
759         AC_MSG_RESULT(yes)
760         AC_DEFINE(HAVE_INODE_I_MUTEX, 1,
761                 [after 2.6.15 inode have i_mutex intead of i_sem])
762 ],[
763         AC_MSG_RESULT(no)
764 ])
765 ])
766
767 # 2.6.16
768
769 # LC_SECURITY_PLUG  # for SLES10 SP2
770 # check security plug in sles10 sp2 kernel
771 AC_DEFUN([LC_SECURITY_PLUG],
772 [AC_MSG_CHECKING([If kernel has security plug support])
773 LB_LINUX_TRY_COMPILE([
774         #include <linux/fs.h>
775 ],[
776         struct dentry   *dentry;
777         struct vfsmount *mnt;
778         struct iattr    *iattr;
779
780         notify_change(dentry, mnt, iattr);
781 ],[
782         AC_MSG_RESULT(yes)
783         AC_DEFINE(HAVE_SECURITY_PLUG, 1,
784                 [SLES10 SP2 use extra parameter in vfs])
785 ],[
786         AC_MSG_RESULT(no)
787 ])
788 ])
789
790 # 2.6.17
791
792 # inode have i_private field since 2.6.17
793 AC_DEFUN([LC_INODE_IPRIVATE],
794 [AC_MSG_CHECKING([if inode has a i_private field])
795 LB_LINUX_TRY_COMPILE([
796 #include <linux/fs.h>
797 ],[
798         struct inode i;
799         i.i_private = NULL; 
800 ],[
801         AC_MSG_RESULT(yes)
802         AC_DEFINE(HAVE_INODE_IPRIVATE, 1,
803                 [struct inode has i_private field])
804 ],[
805         AC_MSG_RESULT(no)
806 ])
807 ])
808
809 # LC_DQUOTOFF_MUTEX
810 # after 2.6.17 dquote use mutex instead if semaphore
811 AC_DEFUN([LC_DQUOTOFF_MUTEX],
812 [AC_MSG_CHECKING([use dqonoff_mutex])
813 LB_LINUX_TRY_COMPILE([
814         #include <linux/mutex.h>
815         #include <linux/fs.h>
816         #include <linux/quota.h>
817 ],[
818         struct quota_info dq;
819
820         mutex_unlock(&dq.dqonoff_mutex);
821 ],[
822         AC_MSG_RESULT(yes)
823         AC_DEFINE(HAVE_DQUOTOFF_MUTEX, 1,
824                 [after 2.6.17 dquote use mutex instead if semaphore])
825 ],[
826         AC_MSG_RESULT(no)
827 ])
828 ])
829
830 # 2.6.18
831
832 # LC_NR_PAGECACHE
833 # 2.6.18 don't export nr_pagecahe
834 AC_DEFUN([LC_NR_PAGECACHE],
835 [AC_MSG_CHECKING([kernel export nr_pagecache])
836 LB_LINUX_TRY_COMPILE([
837         #include <linux/pagemap.h>
838 ],[
839         return atomic_read(&nr_pagecache);
840 ],[
841         AC_MSG_RESULT(yes)
842         AC_DEFINE(HAVE_NR_PAGECACHE, 1,
843                 [is kernel export nr_pagecache])
844 ],[
845         AC_MSG_RESULT(no)
846 ])
847 ])
848
849 #
850 # LC_STATFS_DENTRY_PARAM
851 # starting from 2.6.18 linux kernel uses dentry instead of super_block
852 # for the first parameter of the super_operations->statfs() callback.
853 #
854 #
855 AC_DEFUN([LC_STATFS_DENTRY_PARAM],
856 [AC_MSG_CHECKING([if super_ops.statfs() first parameter is dentry])
857 tmp_flags="$EXTRA_KCFLAGS"
858 EXTRA_KCFLAGS="-Werror"
859 LB_LINUX_TRY_COMPILE([
860         #include <linux/fs.h>
861 ],[
862         ((struct super_operations *)0)->statfs((struct dentry *)0, (struct kstatfs*)0);
863 ],[
864         AC_DEFINE(HAVE_STATFS_DENTRY_PARAM, 1,
865                   [super_ops.statfs() first parameter is dentry])
866         AC_MSG_RESULT([yes])
867 ],[
868         AC_MSG_RESULT([no])
869 ])
870 EXTRA_KCFLAGS="$tmp_flags"
871 ])
872
873 #
874 # LC_VFS_KERN_MOUNT
875 # starting from 2.6.18 kernel don't export do_kern_mount
876 # and want to use vfs_kern_mount instead.
877 #
878 AC_DEFUN([LC_VFS_KERN_MOUNT],
879 [AC_MSG_CHECKING([vfs_kern_mount exist in kernel])
880 LB_LINUX_TRY_COMPILE([
881         #include <linux/mount.h>
882 ],[
883         vfs_kern_mount(NULL, 0, NULL, NULL);
884 ],[
885         AC_DEFINE(HAVE_VFS_KERN_MOUNT, 1,
886                 [vfs_kern_mount exist in kernel])
887         AC_MSG_RESULT([yes])
888 ],[
889         AC_MSG_RESULT([no])
890 ])
891 ])
892
893 #
894 # LC_INVALIDATEPAGE_RETURN_INT
895 # 2.6.17 changes return type for invalidatepage to 'void' from 'int'
896 #
897 AC_DEFUN([LC_INVALIDATEPAGE_RETURN_INT],
898 [AC_MSG_CHECKING([invalidatepage has return int])
899 LB_LINUX_TRY_COMPILE([
900         #include <linux/buffer_head.h>
901 ],[
902         int rc = block_invalidatepage(NULL, 0);
903 ],[
904         AC_MSG_RESULT(yes)
905         AC_DEFINE(HAVE_INVALIDATEPAGE_RETURN_INT, 1,
906                 [Define if return type of invalidatepage should be int])
907 ],[
908         AC_MSG_RESULT(no)
909 ])
910 ])
911
912 # LC_UMOUNTBEGIN_HAS_VFSMOUNT
913 # after 2.6.18 umount_begin has different parameters
914 AC_DEFUN([LC_UMOUNTBEGIN_HAS_VFSMOUNT],
915 [AC_MSG_CHECKING([if umount_begin needs vfsmount parameter instead of super_block])
916 tmp_flags="$EXTRA_KCFLAGS"
917 EXTRA_KCFLAGS="-Werror"
918 LB_LINUX_TRY_COMPILE([
919         #include <linux/fs.h>
920
921         struct vfsmount;
922         static void cfg_umount_begin (struct vfsmount *v, int flags)
923         {
924                 ;
925         }
926
927         static struct super_operations cfg_super_operations = {
928                 .umount_begin   = cfg_umount_begin,
929         };
930 ],[
931         cfg_super_operations.umount_begin(NULL,0);
932 ],[
933         AC_MSG_RESULT(yes)
934         AC_DEFINE(HAVE_UMOUNTBEGIN_VFSMOUNT, 1,
935                 [Define umount_begin need second argument])
936 ],[
937         AC_MSG_RESULT(no)
938 ])
939 EXTRA_KCFLAGS="$tmp_flags"
940 ])
941
942 # LC_SEQ_LOCK
943 # after 2.6.18 seq_file has lock intead of sem
944 AC_DEFUN([LC_SEQ_LOCK],
945 [AC_MSG_CHECKING([if struct seq_file has lock field])
946 LB_LINUX_TRY_COMPILE([
947         #include <linux/seq_file.h>
948 ],[
949         struct seq_file seq;
950
951         mutex_unlock(&seq.lock);
952 ],[
953         AC_MSG_RESULT(yes)
954         AC_DEFINE(HAVE_SEQ_LOCK, 1,
955                 [after 2.6.18 seq_file has lock intead of sem])
956 ],[
957         AC_MSG_RESULT(NO)
958 ])
959 ])
960
961 #
962 # LC_EXPORT_FILEMAP_FDATAWRITE_RANGE
963 #
964 # No standard kernels export this
965 #
966 AC_DEFUN([LC_EXPORT_FILEMAP_FDATAWRITE_RANGE],
967 [LB_CHECK_SYMBOL_EXPORT([filemap_fdatawrite_range],
968 [mm/filemap.c],[
969 AC_DEFINE(HAVE_FILEMAP_FDATAWRITE_RANGE, 1,
970             [filemap_fdatawrite_range is exported by the kernel])
971 ],[
972 ])
973 ])
974
975 # LC_FLUSH_OWNER_ID
976 # starting from 2.6.18 the file_operations .flush
977 # method has a new "fl_owner_t id" parameter
978 #
979 AC_DEFUN([LC_FLUSH_OWNER_ID],
980 [AC_MSG_CHECKING([if file_operations .flush has an fl_owner_t id])
981 LB_LINUX_TRY_COMPILE([
982         #include <linux/fs.h>
983 ],[
984         struct file_operations *fops = NULL;
985         fl_owner_t id;
986         int i;
987
988         i = fops->flush(NULL, id);
989 ],[
990         AC_DEFINE(HAVE_FLUSH_OWNER_ID, 1,
991                 [file_operations .flush method has an fl_owner_t id])
992         AC_MSG_RESULT([yes])
993 ],[
994         AC_MSG_RESULT([no])
995 ])
996 ])
997
998 #
999 # LC_EXPORT_INVALIDATE_MAPPING_PAGES
1000 #
1001 # SLES9, RHEL4, RHEL5, vanilla 2.6.24 export invalidate_mapping_pages() but
1002 # SLES10 2.6.16 does not, for some reason.  For filter cache invalidation.
1003 #
1004 AC_DEFUN([LC_EXPORT_INVALIDATE_MAPPING_PAGES],
1005     [LB_CHECK_SYMBOL_EXPORT([invalidate_mapping_pages], [mm/truncate.c], [
1006          AC_DEFINE(HAVE_INVALIDATE_MAPPING_PAGES, 1,
1007                         [exported invalidate_mapping_pages])],
1008     [LB_CHECK_SYMBOL_EXPORT([invalidate_inode_pages], [mm/truncate.c], [
1009          AC_DEFINE(HAVE_INVALIDATE_INODE_PAGES, 1,
1010                         [exported invalidate_inode_pages])], [
1011        AC_MSG_ERROR([no way to invalidate pages])
1012   ])
1013     ],[])
1014 ])
1015
1016 #2.6.18 + RHEL5 (fc6)
1017
1018 # RHEL5 in FS-cache patch rename PG_checked flag into PG_fs_misc
1019 AC_DEFUN([LC_PG_FS_MISC],
1020 [AC_MSG_CHECKING([kernel has PG_fs_misc])
1021 LB_LINUX_TRY_COMPILE([
1022         #include <linux/mm.h>
1023         #include <linux/page-flags.h>
1024 ],[
1025         #ifndef PG_fs_misc
1026         #error PG_fs_misc not defined in kernel
1027         #endif
1028 ],[
1029         AC_MSG_RESULT(yes)
1030         AC_DEFINE(HAVE_PG_FS_MISC, 1,
1031                   [is kernel have PG_fs_misc])
1032 ],[
1033         AC_MSG_RESULT(no)
1034 ])
1035 ])
1036
1037 # RHEL5 PageChecked and SetPageChecked defined
1038 AC_DEFUN([LC_PAGE_CHECKED],
1039 [AC_MSG_CHECKING([kernel has PageChecked and SetPageChecked])
1040 LB_LINUX_TRY_COMPILE([
1041         #include <linux/mm.h>
1042 #ifdef HAVE_LINUX_MMTYPES_H
1043         #include <linux/mm_types.h>
1044 #endif
1045         #include <linux/page-flags.h>
1046 ],[
1047         struct page *p = NULL;
1048
1049         /* before 2.6.26 this define*/
1050         #ifndef PageChecked     
1051         /* 2.6.26 use function instead of define for it */
1052         SetPageChecked(p);
1053         PageChecked(p);
1054         #endif
1055 ],[
1056         AC_MSG_RESULT(yes)
1057         AC_DEFINE(HAVE_PAGE_CHECKED, 1,
1058                   [does kernel have PageChecked and SetPageChecked])
1059 ],[
1060         AC_MSG_RESULT(no)
1061 ])
1062 ])
1063
1064 #
1065 # LC_LINUX_FIEMAP_H
1066 #
1067 # If we have fiemap.h
1068 # after 2.6.27 use fiemap.h in include/linux
1069 #
1070 AC_DEFUN([LC_LINUX_FIEMAP_H],
1071 [LB_CHECK_FILE([$LINUX/include/linux/fiemap.h],[
1072         AC_MSG_CHECKING([if fiemap.h can be compiled])
1073         LB_LINUX_TRY_COMPILE([
1074                 #include <linux/types.h>
1075                 #include <linux/fiemap.h>
1076         ],[],[
1077                 AC_MSG_RESULT([yes])
1078                 AC_DEFINE(HAVE_LINUX_FIEMAP_H, 1, [Kernel has fiemap.h])
1079         ],[
1080                 AC_MSG_RESULT([no])
1081         ])
1082 ],
1083 [])
1084 ])
1085
1086 # 2.6.19
1087
1088 # 2.6.19 API changes
1089 # inode don't have i_blksize field
1090 AC_DEFUN([LC_INODE_BLKSIZE],
1091 [AC_MSG_CHECKING([inode has i_blksize field])
1092 LB_LINUX_TRY_COMPILE([
1093 #include <linux/fs.h>
1094 ],[
1095         struct inode i;
1096         i.i_blksize = 0;
1097 ],[
1098         AC_MSG_RESULT(yes)
1099         AC_DEFINE(HAVE_INODE_BLKSIZE, 1,
1100                 [struct inode has i_blksize field])
1101 ],[
1102         AC_MSG_RESULT(no)
1103 ])
1104 ])
1105
1106 # LC_FILE_WRITEV
1107 # 2.6.19 replaced writev with aio_write
1108 AC_DEFUN([LC_FILE_WRITEV],
1109 [AC_MSG_CHECKING([writev in fops])
1110 LB_LINUX_TRY_COMPILE([
1111         #include <linux/fs.h>
1112 ],[
1113         struct file_operations *fops = NULL;
1114         fops->writev = NULL;
1115 ],[
1116         AC_MSG_RESULT(yes)
1117         AC_DEFINE(HAVE_FILE_WRITEV, 1,
1118                 [use fops->writev])
1119 ],[
1120         AC_MSG_RESULT(no)
1121 ])
1122 ])
1123
1124 # LC_FILE_READV
1125 # 2.6.19 replaced readv with aio_read
1126 AC_DEFUN([LC_FILE_READV],
1127 [AC_MSG_CHECKING([readv in fops])
1128 LB_LINUX_TRY_COMPILE([
1129         #include <linux/fs.h>
1130 ],[
1131         struct file_operations *fops = NULL;
1132         fops->readv = NULL;
1133 ],[
1134         AC_MSG_RESULT(yes)
1135         AC_DEFINE(HAVE_FILE_READV, 1,
1136                 [use fops->readv])
1137 ],[
1138         AC_MSG_RESULT(no)
1139 ])
1140 ])
1141
1142 # 2.6.20
1143
1144 # LC_CANCEL_DIRTY_PAGE
1145 # 2.6.20 introduced cancel_dirty_page instead of clear_page_dirty.
1146 AC_DEFUN([LC_CANCEL_DIRTY_PAGE],
1147         [AC_MSG_CHECKING([kernel has cancel_dirty_page])
1148         # the implementation of cancel_dirty_page in OFED 1.4.1's SLES10 SP2
1149         # backport is broken, so ignore it
1150         if test -f $OFED_BACKPORT_PATH/linux/mm.h &&
1151            test "$(sed -ne '/^static inline void cancel_dirty_page(struct page \*page, unsigned int account_size)$/,/^}$/p' $OFED_BACKPORT_PATH/linux/mm.h | md5sum)" = "c518cb32d6394760c5bca14cb7538d3e  -"; then
1152                 AC_MSG_RESULT(no)
1153         else
1154                 LB_LINUX_TRY_COMPILE([
1155                         #include <linux/mm.h>
1156                         #include <linux/page-flags.h>
1157 ],[
1158                         cancel_dirty_page(NULL, 0);
1159 ],[
1160                         AC_MSG_RESULT(yes)
1161                         AC_DEFINE(HAVE_CANCEL_DIRTY_PAGE, 1,
1162                                   [kernel has cancel_dirty_page instead of clear_page_dirty])
1163 ],[
1164                         AC_MSG_RESULT(no)
1165 ])
1166         fi
1167 ])
1168
1169 # raid5-zerocopy patch
1170
1171 #
1172 # LC_PAGE_CONSTANT
1173 #
1174 # In order to support raid5 zerocopy patch, we have to patch the kernel to make
1175 # it support constant page, which means the page won't be modified during the
1176 # IO.
1177 #
1178 AC_DEFUN([LC_PAGE_CONSTANT],
1179 [AC_MSG_CHECKING([if kernel have PageConstant defined])
1180 LB_LINUX_TRY_COMPILE([
1181         #include <linux/mm.h>
1182         #include <linux/page-flags.h>
1183 ],[
1184         #ifndef PG_constant
1185         #error "Have no raid5 zcopy patch"
1186         #endif
1187 ],[
1188         AC_MSG_RESULT(yes)
1189         AC_DEFINE(HAVE_PAGE_CONSTANT, 1, [kernel have PageConstant supported])
1190 ],[
1191         AC_MSG_RESULT(no);
1192 ])
1193 ])
1194
1195 # 2.6.22
1196
1197 # 2.6.22 lost second parameter for invalidate_bdev
1198 AC_DEFUN([LC_INVALIDATE_BDEV_2ARG],
1199 [AC_MSG_CHECKING([if invalidate_bdev has second argument])
1200 LB_LINUX_TRY_COMPILE([
1201         #include <linux/buffer_head.h>
1202 ],[
1203         invalidate_bdev(NULL,0);
1204 ],[
1205         AC_MSG_RESULT([yes])
1206         AC_DEFINE(HAVE_INVALIDATE_BDEV_2ARG, 1,
1207                 [invalidate_bdev has second argument])
1208 ],[
1209         AC_MSG_RESULT([no])
1210 ])
1211 ])
1212
1213 #
1214 # check for crypto API
1215 #
1216 AC_DEFUN([LC_ASYNC_BLOCK_CIPHER],
1217 [AC_MSG_CHECKING([if kernel has block cipher support])
1218 LB_LINUX_TRY_COMPILE([
1219         #include <linux/err.h>
1220         #include <linux/crypto.h>
1221 ],[
1222         struct crypto_blkcipher *tfm;
1223         tfm = crypto_alloc_blkcipher("aes", 0, sizeof(tfm) );
1224 ],[
1225         AC_MSG_RESULT([yes])
1226         AC_DEFINE(HAVE_ASYNC_BLOCK_CIPHER, 1, [kernel has block cipher support])
1227 ],[
1228         AC_MSG_RESULT([no])
1229 ])
1230 ])
1231
1232 #
1233 # check for struct hash_desc
1234 #
1235 AC_DEFUN([LC_STRUCT_HASH_DESC],
1236 [AC_MSG_CHECKING([if kernel has struct hash_desc])
1237 LB_LINUX_TRY_COMPILE([
1238         #include <linux/err.h>
1239         #include <linux/crypto.h>
1240 ],[
1241         struct hash_desc foo;
1242 ],[
1243         AC_MSG_RESULT([yes])
1244         AC_DEFINE(HAVE_STRUCT_HASH_DESC, 1, [kernel has struct hash_desc])
1245 ],[
1246         AC_MSG_RESULT([no])
1247 ])
1248 ])
1249
1250 #
1251 # check for struct blkcipher_desc
1252 #
1253 AC_DEFUN([LC_STRUCT_BLKCIPHER_DESC],
1254 [AC_MSG_CHECKING([if kernel has struct blkcipher_desc])
1255 LB_LINUX_TRY_COMPILE([
1256         #include <linux/err.h>
1257         #include <linux/crypto.h>
1258 ],[
1259         struct blkcipher_desc foo;
1260 ],[
1261         AC_MSG_RESULT([yes])
1262         AC_DEFINE(HAVE_STRUCT_BLKCIPHER_DESC, 1, [kernel has struct blkcipher_desc])
1263 ],[
1264         AC_MSG_RESULT([no])
1265 ])
1266 ])
1267
1268 #
1269 # 2.6.19 check for FS_RENAME_DOES_D_MOVE flag
1270 #
1271 AC_DEFUN([LC_FS_RENAME_DOES_D_MOVE],
1272 [AC_MSG_CHECKING([if kernel has FS_RENAME_DOES_D_MOVE flag])
1273 LB_LINUX_TRY_COMPILE([
1274         #include <linux/fs.h>
1275 ],[
1276         int v = FS_RENAME_DOES_D_MOVE;
1277 ],[
1278         AC_MSG_RESULT([yes])
1279         AC_DEFINE(HAVE_FS_RENAME_DOES_D_MOVE, 1, [kernel has FS_RENAME_DOES_D_MOVE flag])
1280 ],[
1281         AC_MSG_RESULT([no])
1282 ])
1283 ])
1284
1285 # 2.6.23
1286
1287 # 2.6.23 have return type 'void' for unregister_blkdev
1288 AC_DEFUN([LC_UNREGISTER_BLKDEV_RETURN_INT],
1289 [AC_MSG_CHECKING([if unregister_blkdev return int])
1290 LB_LINUX_TRY_COMPILE([
1291         #include <linux/fs.h>
1292 ],[
1293         int i = unregister_blkdev(0,NULL);
1294 ],[
1295         AC_MSG_RESULT([yes])
1296         AC_DEFINE(HAVE_UNREGISTER_BLKDEV_RETURN_INT, 1,
1297                 [unregister_blkdev return int])
1298 ],[
1299         AC_MSG_RESULT([no])
1300 ])
1301 ])
1302
1303 # 2.6.23 change .sendfile to .splice_read
1304 AC_DEFUN([LC_KERNEL_SPLICE_READ],
1305 [AC_MSG_CHECKING([if kernel has .splice_read])
1306 LB_LINUX_TRY_COMPILE([
1307         #include <linux/fs.h>
1308 ],[
1309         struct file_operations file;
1310
1311         file.splice_read = NULL;
1312 ], [
1313         AC_MSG_RESULT([yes])
1314         AC_DEFINE(HAVE_KERNEL_SPLICE_READ, 1,
1315                 [kernel has .slice_read])
1316 ],[
1317         AC_MSG_RESULT([no])
1318 ])
1319 ])
1320
1321 # 2.6.23 change .sendfile to .splice_read
1322 # RHEL4 (-92 kernel) have both sendfile and .splice_read API
1323 AC_DEFUN([LC_KERNEL_SENDFILE],
1324 [AC_MSG_CHECKING([if kernel has .sendfile])
1325 LB_LINUX_TRY_COMPILE([
1326         #include <linux/fs.h>
1327 ],[
1328         struct file_operations file;
1329
1330         file.sendfile = NULL;
1331 ], [
1332         AC_MSG_RESULT([yes])
1333         AC_DEFINE(HAVE_KERNEL_SENDFILE, 1,
1334                 [kernel has .sendfile])
1335 ],[
1336         AC_MSG_RESULT([no])
1337 ])
1338 ])
1339
1340 # 2.6.23 extract nfs export related data into exportfs.h
1341 AC_DEFUN([LC_HAVE_EXPORTFS_H],
1342 [LB_CHECK_FILE([$LINUX/include/linux/exportfs.h], [
1343         AC_DEFINE(HAVE_LINUX_EXPORTFS_H, 1,
1344                 [kernel has include/exportfs.h])
1345 ],[
1346         AC_MSG_RESULT([no])
1347 ])
1348 ])
1349
1350 # 2.6.23 has new page fault handling API
1351 AC_DEFUN([LC_VM_OP_FAULT],
1352 [AC_MSG_CHECKING([kernel has .fault in vm_operation_struct])
1353 LB_LINUX_TRY_COMPILE([
1354         #include <linux/mm.h>
1355 ],[
1356         struct vm_operations_struct op;
1357
1358         op.fault = NULL;
1359 ], [
1360         AC_MSG_RESULT([yes])
1361         AC_DEFINE(HAVE_VM_OP_FAULT, 1,
1362                 [kernel has .fault in vm_operation_struct])
1363 ],[
1364         AC_MSG_RESULT([no])
1365 ])
1366 ])
1367
1368 # 2.6.23 add code to wait other users to complete before removing procfs entry
1369 AC_DEFUN([LC_PROCFS_USERS],
1370 [AC_MSG_CHECKING([if kernel has pde_users member in procfs entry struct])
1371 LB_LINUX_TRY_COMPILE([
1372         #include <linux/proc_fs.h>
1373 ],[
1374         struct proc_dir_entry pde;
1375
1376         pde.pde_users   = 0;
1377 ],[
1378         AC_MSG_RESULT([yes])
1379         AC_DEFINE(HAVE_PROCFS_USERS, 1,
1380                 [kernel has pde_users member in procfs entry struct])
1381 ],[
1382         AC_MSG_RESULT([no])
1383 ])
1384 ])
1385
1386 # 2.6.23 exports exportfs_decode_fh
1387 AC_DEFUN([LC_EXPORTFS_DECODE_FH],
1388 [LB_CHECK_SYMBOL_EXPORT([exportfs_decode_fh],
1389 [fs/exportfs/expfs.c],[
1390         AC_DEFINE(HAVE_EXPORTFS_DECODE_FH, 1,
1391                 [exportfs_decode_fh has been export])
1392 ],[
1393 ])
1394 ])
1395
1396 # 2.6.24
1397
1398 # 2.6.24 need linux/mm_types.h included
1399 AC_DEFUN([LC_HAVE_MMTYPES_H],
1400 [LB_CHECK_FILE([$LINUX/include/linux/mm_types.h], [
1401         AC_DEFINE(HAVE_LINUX_MMTYPES_H, 1,
1402                 [kernel has include/mm_types.h])
1403 ],[
1404         AC_MSG_RESULT([no])
1405 ])
1406 ])
1407
1408 # 2.6.24 has bio_endio with 2 args
1409 AC_DEFUN([LC_BIO_ENDIO_2ARG],
1410 [AC_MSG_CHECKING([if kernel has bio_endio with 2 args])
1411 LB_LINUX_TRY_COMPILE([
1412         #include <linux/bio.h>
1413 ],[
1414         bio_endio(NULL, 0);
1415 ], [
1416         AC_MSG_RESULT([yes])
1417         AC_DEFINE(HAVE_BIO_ENDIO_2ARG, 1,
1418                 [kernel has bio_endio with 2 args])
1419 ],[
1420         AC_MSG_RESULT([no])
1421 ])
1422 ])
1423
1424 # 2.6.24 has new members in exports struct.
1425 AC_DEFUN([LC_FH_TO_DENTRY],
1426 [AC_MSG_CHECKING([if kernel has .fh_to_dentry member in export_operations struct])
1427 LB_LINUX_TRY_COMPILE([
1428         #include <linux/fs.h>
1429 #ifdef HAVE_LINUX_EXPORTFS_H
1430         #include <linux/exportfs.h>
1431 #endif
1432 ],[
1433         struct export_operations exp;
1434         memset(exp.fh_to_dentry, 0, sizeof(exp.fh_to_dentry));
1435 ], [
1436         AC_MSG_RESULT([yes])
1437         AC_DEFINE(HAVE_FH_TO_DENTRY, 1,
1438                 [kernel has .fh_to_dentry member in export_operations struct])
1439 ],[
1440         AC_MSG_RESULT([no])
1441 ])
1442 ])
1443
1444 # 2.6.24 removes long aged procfs entry -> deleted member
1445 AC_DEFUN([LC_PROCFS_DELETED],
1446 [AC_MSG_CHECKING([if kernel has deleted member in procfs entry struct])
1447 LB_LINUX_TRY_COMPILE([
1448         #include <linux/proc_fs.h>
1449 ],[
1450         struct proc_dir_entry pde;
1451
1452         pde.deleted = sizeof(pde);
1453 ], [
1454         AC_MSG_RESULT([yes])
1455         AC_DEFINE(HAVE_PROCFS_DELETED, 1,
1456                 [kernel has deleted member in procfs entry struct])
1457 ],[
1458         AC_MSG_RESULT([no])
1459 ])
1460 ])
1461
1462 # 2.6.24 has bdi_init()/bdi_destroy() functions.
1463 AC_DEFUN([LC_EXPORT_BDI_INIT],
1464 [LB_CHECK_SYMBOL_EXPORT([bdi_init],
1465 [mm/backing-dev.c],[
1466         AC_DEFINE(HAVE_BDI_INIT, 1,
1467                 [bdi_init/bdi_destroy functions are present])
1468 ],[
1469 ])
1470 ])
1471
1472 # 2.6.25
1473
1474 # 2.6.25 change define to inline
1475 AC_DEFUN([LC_MAPPING_CAP_WRITEBACK_DIRTY],
1476 [AC_MSG_CHECKING([if kernel have mapping_cap_writeback_dirty])
1477 LB_LINUX_TRY_COMPILE([
1478         #include <linux/backing-dev.h>
1479 ],[
1480         #ifndef mapping_cap_writeback_dirty
1481         mapping_cap_writeback_dirty(NULL);
1482         #endif
1483 ],[
1484         AC_MSG_RESULT([yes])
1485         AC_DEFINE(HAVE_MAPPING_CAP_WRITEBACK_DIRTY, 1,
1486                 [kernel have mapping_cap_writeback_dirty])
1487 ],[
1488         AC_MSG_RESULT([no])
1489 ])
1490 ])
1491
1492 # 2.6.26
1493
1494 # 2.6.26 isn't export set_fs_pwd and change paramter in fs struct
1495 AC_DEFUN([LC_FS_STRUCT_USE_PATH],
1496 [AC_MSG_CHECKING([fs_struct use path structure])
1497 LB_LINUX_TRY_COMPILE([
1498         #include <asm/atomic.h>
1499         #include <linux/spinlock.h>
1500         #include <linux/fs_struct.h>
1501 ],[
1502         struct path path;
1503         struct fs_struct fs;
1504
1505         fs.pwd = path;
1506         memset(&fs, 0, sizeof(fs));
1507 ], [
1508         AC_MSG_RESULT([yes])
1509         AC_DEFINE(HAVE_FS_STRUCT_USE_PATH, 1,
1510                 [fs_struct use path structure])
1511 ],[
1512         AC_MSG_RESULT([no])
1513 ])
1514 ])
1515
1516
1517 #
1518 # 2.6.27
1519 #
1520 AC_DEFUN([LC_INODE_PERMISION_2ARGS],
1521 [AC_MSG_CHECKING([inode_operations->permission has two args])
1522 LB_LINUX_TRY_COMPILE([
1523         #include <linux/fs.h>
1524 ],[
1525         struct inode *inode;
1526         inode->i_op->permission(NULL, 0);
1527 ],[
1528         AC_DEFINE(HAVE_INODE_PERMISION_2ARGS, 1,
1529                   [inode_operations->permission has two args])
1530         AC_MSG_RESULT([yes])
1531 ],[
1532         AC_MSG_RESULT([no])
1533 ])
1534 ])
1535
1536 # 2.6.27 has file_remove_suid instead of remove_suid
1537 AC_DEFUN([LC_FILE_REMOVE_SUID],
1538 [AC_MSG_CHECKING([kernel has file_remove_suid])
1539 LB_LINUX_TRY_COMPILE([
1540         #include <linux/fs.h>
1541 ],[
1542         file_remove_suid(NULL);
1543 ],[
1544         AC_DEFINE(HAVE_FILE_REMOVE_SUID, 1,
1545                   [kernel have file_remove_suid])
1546         AC_MSG_RESULT([yes])
1547 ],[
1548         AC_MSG_RESULT([no])
1549 ])
1550 ])
1551
1552 # 2.6.27 have new page locking API
1553 AC_DEFUN([LC_TRYLOCKPAGE],
1554 [AC_MSG_CHECKING([kernel uses trylock_page for page lock])
1555 LB_LINUX_TRY_COMPILE([
1556         #include <linux/pagemap.h>
1557 ],[
1558         trylock_page(NULL);
1559 ],[
1560         AC_DEFINE(HAVE_TRYLOCK_PAGE, 1,
1561                   [kernel uses trylock_page for page lock])
1562         AC_MSG_RESULT([yes])
1563 ],[
1564         AC_MSG_RESULT([no])
1565 ])
1566 ])
1567
1568 # 2.6.27 removed the read_inode from super_operations.
1569 AC_DEFUN([LC_READ_INODE_IN_SBOPS],
1570 [AC_MSG_CHECKING([super_operations has a read_inode field])
1571 LB_LINUX_TRY_COMPILE([
1572         #include <linux/fs.h>
1573 ],[
1574         struct super_operations *sop;
1575         sop->read_inode(NULL);
1576 ],[
1577         AC_DEFINE(HAVE_READ_INODE_IN_SBOPS, 1,
1578                 [super_operations has a read_inode])
1579         AC_MSG_RESULT([yes])
1580 ],[
1581         AC_MSG_RESULT([no])
1582 ])
1583 ])
1584
1585 # 2.6.27 has inode_permission instead of permisson
1586 AC_DEFUN([LC_EXPORT_INODE_PERMISSION],
1587 [LB_CHECK_SYMBOL_EXPORT([inode_permission],
1588 [fs/namei.c],[
1589 AC_DEFINE(HAVE_EXPORT_INODE_PERMISSION, 1,
1590             [inode_permission is exported by the kernel])
1591 ],[
1592 ])
1593 ])
1594
1595 # 2.6.27 use 5th parameter in quota_on for remount.
1596 AC_DEFUN([LC_QUOTA_ON_5ARGS],
1597 [AC_MSG_CHECKING([quota_on needs 5 parameters])
1598 LB_LINUX_TRY_COMPILE([
1599         #include <linux/quota.h>
1600 ],[
1601         struct quotactl_ops *qop;
1602         qop->quota_on(NULL, 0, 0, NULL, 0);
1603 ],[
1604         AC_DEFINE(HAVE_QUOTA_ON_5ARGS, 1,
1605                 [quota_on needs 5 paramters])
1606         AC_MSG_RESULT([yes])
1607 ],[
1608         AC_MSG_RESULT([no])
1609 ])
1610 ])
1611
1612 # 2.6.27 use 3th parameter in quota_off for remount.
1613 AC_DEFUN([LC_QUOTA_OFF_3ARGS],
1614 [AC_MSG_CHECKING([quota_off needs 3 parameters])
1615 LB_LINUX_TRY_COMPILE([
1616         #include <linux/quota.h>
1617 ],[
1618         struct quotactl_ops *qop;
1619         qop->quota_off(NULL, 0, 0);
1620 ],[
1621         AC_DEFINE(HAVE_QUOTA_OFF_3ARGS, 1,
1622                 [quota_off needs 3 paramters])
1623         AC_MSG_RESULT([yes])
1624 ],[
1625         AC_MSG_RESULT([no])
1626 ])
1627 ])
1628
1629 # 2.6.27 has vfs_dq_off inline function.
1630 AC_DEFUN([LC_VFS_DQ_OFF],
1631 [AC_MSG_CHECKING([vfs_dq_off is defined])
1632 LB_LINUX_TRY_COMPILE([
1633         #include <linux/quotaops.h>
1634 ],[
1635         vfs_dq_off(NULL, 0);
1636 ],[
1637         AC_DEFINE(HAVE_VFS_DQ_OFF, 1, [vfs_dq_off is defined])
1638         AC_MSG_RESULT([yes])
1639 ],[
1640         AC_MSG_RESULT([no])
1641 ])
1642 ])
1643
1644 # LC_LOCK_MAP_ACQUIRE
1645 # after 2.6.27 lock_map_acquire replaces lock_acquire
1646 AC_DEFUN([LC_LOCK_MAP_ACQUIRE],
1647 [AC_MSG_CHECKING([if lock_map_acquire is defined])
1648 LB_LINUX_TRY_COMPILE([
1649         #include <linux/lockdep.h>
1650 ],[
1651         lock_map_acquire(NULL);
1652 ],[
1653         AC_MSG_RESULT(yes)
1654         AC_DEFINE(HAVE_LOCK_MAP_ACQUIRE, 1,
1655                 [lock_map_acquire is defined])
1656 ],[
1657         AC_MSG_RESULT(no)
1658 ])
1659 ])
1660
1661 # 2.6.27.15-2 sles11
1662
1663 # 2.6.27 sles11 remove the bi_hw_segments
1664 AC_DEFUN([LC_BI_HW_SEGMENTS],
1665 [AC_MSG_CHECKING([struct bio has a bi_hw_segments field])
1666 LB_LINUX_TRY_COMPILE([
1667         #include <linux/bio.h>
1668 ],[
1669         struct bio io;
1670         io.bi_hw_segments = sizeof(io);
1671 ],[
1672         AC_DEFINE(HAVE_BI_HW_SEGMENTS, 1,
1673                 [struct bio has a bi_hw_segments field])
1674         AC_MSG_RESULT([yes])
1675 ],[
1676         AC_MSG_RESULT([no])
1677 ])
1678 ])
1679
1680 #
1681 # 2.6.27 sles11 move the quotaio_v1{2}.h from include/linux to fs
1682 # 2.6.32 move the quotaio_v1{2}.h from fs to fs/quota
1683 AC_DEFUN([LC_HAVE_QUOTAIO_H],
1684 [LB_CHECK_FILE([$LINUX/include/linux/quotaio_v2.h],[
1685         AC_DEFINE(HAVE_QUOTAIO_H, 1,
1686                 [kernel has include/linux/quotaio_v2.h])
1687 ],[LB_CHECK_FILE([$LINUX/fs/quotaio_v2.h],[
1688                AC_DEFINE(HAVE_FS_QUOTAIO_H, 1,
1689                 [kernel has fs/quotaio_v1.h])
1690 ],[LB_CHECK_FILE([$LINUX/fs/quota/quotaio_v2.h],[
1691                AC_DEFINE(HAVE_FS_QUOTA_QUOTAIO_H, 1,
1692                 [kernel has fs/quota/quotaio_v2.h])
1693 ],[
1694         AC_MSG_RESULT([no])
1695 ])
1696 ])
1697 ])
1698 ])
1699
1700 # sles10 sp2 need 5 parameter for vfs_symlink
1701 AC_DEFUN([LC_VFS_SYMLINK_5ARGS],
1702 [AC_MSG_CHECKING([vfs_symlink need 5 parameter])
1703 LB_LINUX_TRY_COMPILE([
1704         #include <linux/fs.h>
1705 ],[
1706         struct inode *dir = NULL;
1707         struct dentry *dentry = NULL;
1708         struct vfsmount *mnt = NULL;
1709         const char * path = NULL;
1710         vfs_symlink(dir, dentry, mnt, path, 0);
1711 ],[
1712         AC_DEFINE(HAVE_VFS_SYMLINK_5ARGS, 1,
1713                 [vfs_symlink need 5 parameteres])
1714         AC_MSG_RESULT([yes])
1715 ],[
1716         AC_MSG_RESULT([no])
1717 ])
1718 ])
1719
1720 # 2.6.27 sles11 has sb_any_quota_active
1721 AC_DEFUN([LC_SB_ANY_QUOTA_ACTIVE],
1722 [AC_MSG_CHECKING([Kernel has sb_any_quota_active])
1723 LB_LINUX_TRY_COMPILE([
1724         #include <linux/quotaops.h>
1725 ],[
1726         sb_any_quota_active(NULL);
1727 ],[
1728         AC_DEFINE(HAVE_SB_ANY_QUOTA_ACTIVE, 1,
1729                 [Kernel has a sb_any_quota_active])
1730         AC_MSG_RESULT([yes])
1731 ],[
1732         AC_MSG_RESULT([no])
1733 ])
1734 ])
1735
1736 # 2.6.27 sles11 has sb_has_quota_active
1737 AC_DEFUN([LC_SB_HAS_QUOTA_ACTIVE],
1738 [AC_MSG_CHECKING([Kernel has sb_has_quota_active])
1739 LB_LINUX_TRY_COMPILE([
1740         #include <linux/quotaops.h>
1741 ],[
1742         sb_has_quota_active(NULL, 0);
1743 ],[
1744         AC_DEFINE(HAVE_SB_HAS_QUOTA_ACTIVE, 1,
1745                 [Kernel has a sb_has_quota_active])
1746         AC_MSG_RESULT([yes])
1747 ],[
1748         AC_MSG_RESULT([no])
1749 ])
1750 ])
1751
1752 # 2.6.27 exported add_to_page_cache_lru.
1753 AC_DEFUN([LC_EXPORT_ADD_TO_PAGE_CACHE_LRU],
1754 [LB_CHECK_SYMBOL_EXPORT([add_to_page_cache_lru],
1755 [mm/filemap.c],[
1756         AC_DEFINE(HAVE_ADD_TO_PAGE_CACHE_LRU, 1,
1757                 [add_to_page_cache_lru functions are present])
1758 ],[
1759 ])
1760 ])
1761
1762 #
1763 # 2.6.29 introduce sb_any_quota_loaded.
1764 #
1765 AC_DEFUN([LC_SB_ANY_QUOTA_LOADED],
1766 [AC_MSG_CHECKING([Kernel has sb_any_quota_loaded])
1767 LB_LINUX_TRY_COMPILE([
1768         #include <linux/quotaops.h>
1769 ],[
1770         sb_any_quota_loaded(NULL);
1771 ],[
1772         AC_DEFINE(HAVE_SB_ANY_QUOTA_LOADED, 1,
1773                 [Kernel has a sb_any_quota_loaded])
1774         AC_MSG_RESULT([yes])
1775 ],[
1776         AC_MSG_RESULT([no])
1777 ])
1778 ])
1779
1780 # 2.6.30 x86 node_to_cpumask has been removed. must use cpumask_of_node
1781 AC_DEFUN([LC_EXPORT_CPUMASK_OF_NODE],
1782          [LB_CHECK_SYMBOL_EXPORT([node_to_cpumask_map],
1783                                  [arch/$LINUX_ARCH/mm/numa.c],
1784                                  [AC_DEFINE(HAVE_CPUMASK_OF_NODE, 1,
1785                                             [node_to_cpumask_map is exported by
1786                                              the kernel])]) # x86_64
1787          ])
1788
1789 # 2.6.31 replaces blk_queue_hardsect_size by blk_queue_logical_block_size function
1790 AC_DEFUN([LC_BLK_QUEUE_LOG_BLK_SIZE],
1791 [AC_MSG_CHECKING([if blk_queue_logical_block_size is defined])
1792 LB_LINUX_TRY_COMPILE([
1793         #include <linux/blkdev.h>
1794 ],[
1795         blk_queue_logical_block_size(NULL, 0);
1796 ],[
1797         AC_MSG_RESULT(yes)
1798         AC_DEFINE(HAVE_BLK_QUEUE_LOG_BLK_SIZE, 1,
1799                   [blk_queue_logical_block_size is defined])
1800 ],[
1801         AC_MSG_RESULT(no)
1802 ])
1803 ])
1804
1805 # 2.6.32
1806
1807 # 2.6.32 changes cache_detail's member cache_request to cache_upcall
1808 # in kernel commit bc74b4f5e63a09fb78e245794a0de1e5a2716bbe
1809 AC_DEFUN([LC_CACHE_UPCALL],
1810 [AC_MSG_CHECKING([if cache_detail has cache_upcall field])
1811         LB_LINUX_TRY_COMPILE([
1812                 #include <linux/sunrpc/cache.h>
1813         ],[
1814                 struct cache_detail cd;
1815                 cd.cache_upcall = NULL;
1816         ],[
1817                 AC_MSG_RESULT(yes)
1818                 AC_DEFINE(HAVE_CACHE_UPCALL, 1,
1819                           [cache_detail has cache_upcall field])
1820         ],[
1821                 AC_MSG_RESULT(no)
1822         ])
1823 ])
1824
1825 # 2.6.32 add a limits member in struct request_queue.
1826 AC_DEFUN([LC_REQUEST_QUEUE_LIMITS],
1827 [AC_MSG_CHECKING([if request_queue has a limits field])
1828 LB_LINUX_TRY_COMPILE([
1829         #include <linux/blkdev.h>
1830 ],[
1831         struct request_queue rq;
1832         rq.limits.io_min = 0;
1833 ],[
1834         AC_MSG_RESULT(yes)
1835         AC_DEFINE(HAVE_REQUEST_QUEUE_LIMITS, 1,
1836                   [request_queue has a limits field])
1837 ],[
1838         AC_MSG_RESULT(no)
1839 ])
1840 ])
1841
1842 # 2.6.32 has bdi_register() functions.
1843 AC_DEFUN([LC_EXPORT_BDI_REGISTER],
1844 [LB_CHECK_SYMBOL_EXPORT([bdi_register],
1845 [mm/backing-dev.c],[
1846         AC_DEFINE(HAVE_BDI_REGISTER, 1,
1847                 [bdi_register function is present])
1848 ],[
1849 ])
1850 ])
1851
1852 # 2.6.32 add s_bdi for super block
1853 AC_DEFUN([LC_SB_BDI],
1854 [AC_MSG_CHECKING([if super_block has s_bdi field])
1855 LB_LINUX_TRY_COMPILE([
1856         #include <linux/fs.h>
1857 ],[
1858         struct super_block sb;
1859         sb.s_bdi = NULL;
1860 ],[
1861         AC_MSG_RESULT(yes)
1862         AC_DEFINE(HAVE_SB_BDI, 1,
1863                   [super_block has s_bdi field])
1864 ],[
1865         AC_MSG_RESULT(no)
1866 ])
1867 ])
1868
1869 #  2.6.27.15-2 SuSE 11 sp0 kernels lack the name field for BDI
1870 AC_DEFUN([LC_BDI_NAME],
1871 [AC_MSG_CHECKING([if backing_device_info has name field])
1872 LB_LINUX_TRY_COMPILE([
1873         #include <linux/blkkdev.h>
1874 ],[
1875         struct backing_dev_info bdi;
1876         bdi.name = NULL;
1877 ],[
1878         AC_MSG_RESULT(yes)
1879         AC_DEFINE(HAVE_BDI_NAME, 1,
1880                   [backing_device_info has name field])
1881 ],[
1882         AC_MSG_RESULT(no)
1883 ])
1884 ])  
1885
1886 # 2.6.32 removes blk_queue_max_sectors and add blk_queue_max_hw_sectors
1887 # check blk_queue_max_sectors and use it until disappear.
1888 AC_DEFUN([LC_BLK_QUEUE_MAX_SECTORS],
1889 [AC_MSG_CHECKING([if blk_queue_max_sectors is defined])
1890 LB_LINUX_TRY_COMPILE([
1891         #include <linux/blkdev.h>
1892 ],[
1893         blk_queue_max_sectors(NULL, 0);
1894 ],[
1895         AC_MSG_RESULT(yes)
1896         AC_DEFINE(HAVE_BLK_QUEUE_MAX_SECTORS, 1,
1897                   [blk_queue_max_sectors is defined])
1898 ],[
1899         AC_MSG_RESULT(no)
1900 ])
1901 ])
1902
1903 # 2.6.32 replaces 2 functions blk_queue_max_phys_segments and blk_queue_max_hw_segments by blk_queue_max_segments
1904 AC_DEFUN([LC_BLK_QUEUE_MAX_SEGMENTS],
1905 [AC_MSG_CHECKING([if blk_queue_max_segments is defined])
1906 LB_LINUX_TRY_COMPILE([
1907         #include <linux/blkdev.h>
1908 ],[
1909         blk_queue_max_segments(NULL, 0);
1910 ],[
1911         AC_MSG_RESULT(yes)
1912         AC_DEFINE(HAVE_BLK_QUEUE_MAX_SEGMENTS, 1,
1913                   [blk_queue_max_segments is defined])
1914 ],[
1915         AC_MSG_RESULT(no)
1916 ])
1917 ])
1918
1919 #
1920 # LC_QUOTA64
1921 #
1922 # Check if kernel has been patched for 64-bit quota limits support.
1923 # The upstream version of this patch in RHEL6 2.6.32 kernels introduces
1924 # the constant QFMT_VFS_V1 in include/linux/quota.h, so we can check for
1925 # that in the absence of quotaio_v1.h in the kernel headers.
1926 #
1927 AC_DEFUN([LC_QUOTA64],[
1928         AC_MSG_CHECKING([if kernel has 64-bit quota limits support])
1929 tmp_flags="$EXTRA_KCFLAGS"
1930 EXTRA_KCFLAGS="-I$LINUX/fs"
1931         LB_LINUX_TRY_COMPILE([
1932                 #include <linux/kernel.h>
1933                 #include <linux/fs.h>
1934                 #ifdef HAVE_QUOTAIO_H
1935                 # include <linux/quotaio_v2.h>
1936                 int versions[] = V2_INITQVERSIONS_R1;
1937                 struct v2_disk_dqblk_r1 dqblk_r1;
1938                 #elif defined(HAVE_FS_QUOTA_QUOTAIO_H)
1939                 # include <quota/quotaio_v2.h>
1940                 struct v2r1_disk_dqblk dqblk_r1;
1941                 #elif defined(HAVE_FS_QUOTAIO_H)
1942                 # include <quotaio_v2.h>
1943                 struct v2r1_disk_dqblk dqblk_r1;
1944                 #else
1945                 #include <linux/quota.h>
1946                 int ver = QFMT_VFS_V1;
1947                 #endif
1948         ],[],[
1949                 AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
1950                 AC_MSG_RESULT([yes])
1951         ],[
1952                 LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
1953                         AC_MSG_ERROR([You have got no 64-bit kernel quota support.])
1954                 ],[])
1955                 AC_MSG_RESULT([no])
1956         ])
1957 EXTRA_KCFLAGS=$tmp_flags
1958 ])
1959
1960 # 2.6.32 set_cpus_allowed is no more defined if CONFIG_CPUMASK_OFFSTACK=yes
1961 AC_DEFUN([LC_SET_CPUS_ALLOWED],
1962          [AC_MSG_CHECKING([if kernel defines set_cpus_allowed])
1963           LB_LINUX_TRY_COMPILE(
1964                 [#include <linux/sched.h>],
1965                 [struct task_struct *p = NULL;
1966                  cpumask_t mask = { { 0 } };
1967                  (void) set_cpus_allowed(p, mask);],
1968                 [AC_MSG_RESULT([yes])
1969                  AC_DEFINE(HAVE_SET_CPUS_ALLOWED, 1,
1970                            [set_cpus_allowed is exported by the kernel])],
1971                 [AC_MSG_RESULT([no])] )])
1972
1973 #
1974 # LC_D_OBTAIN_ALIAS
1975 # starting from 2.6.28 kernel replaces d_alloc_anon() with
1976 # d_obtain_alias() for getting anonymous dentries
1977 #
1978 AC_DEFUN([LC_D_OBTAIN_ALIAS],
1979 [AC_MSG_CHECKING([d_obtain_alias exist in kernel])
1980 LB_LINUX_TRY_COMPILE([
1981         #include <linux/dcache.h>
1982 ],[
1983         d_obtain_alias(NULL);
1984 ],[
1985         AC_DEFINE(HAVE_D_OBTAIN_ALIAS, 1,
1986                 [d_obtain_alias exist in kernel])
1987         AC_MSG_RESULT([yes])
1988 ],[
1989         AC_MSG_RESULT([no])
1990 ])
1991 ])
1992
1993 #
1994 # 2.6.36 fs_struct.lock use spinlock instead of rwlock.
1995 #
1996 AC_DEFUN([LC_FS_STRUCT_RWLOCK],
1997 [AC_MSG_CHECKING([if fs_struct.lock use rwlock])
1998 LB_LINUX_TRY_COMPILE([
1999         #include <asm/atomic.h>
2000         #include <linux/spinlock.h>
2001         #include <linux/fs_struct.h>
2002 ],[
2003         ((struct fs_struct *)0)->lock = (rwlock_t){ 0 };
2004 ],[
2005         AC_DEFINE(HAVE_FS_STRUCT_RWLOCK, 1,
2006                   [fs_struct.lock use rwlock])
2007         AC_MSG_RESULT([yes])
2008 ],[
2009         AC_MSG_RESULT([no])
2010 ])
2011 ])
2012
2013 #
2014 # 2.6.36 super_operations add evict_inode method. it hybird of
2015 # delete_inode & clear_inode.
2016 #
2017 AC_DEFUN([LC_SBOPS_EVICT_INODE],
2018 [AC_MSG_CHECKING([if super_operations.evict_inode exist])
2019 LB_LINUX_TRY_COMPILE([
2020         #include <linux/fs.h>
2021 ],[
2022         ((struct super_operations *)0)->evict_inode(NULL);
2023 ],[
2024         AC_DEFINE(HAVE_SBOPS_EVICT_INODE, 1,
2025                 [super_operations.evict_inode() is exist in kernel])
2026         AC_MSG_RESULT([yes])
2027 ],[
2028         AC_MSG_RESULT([no])
2029 ])
2030 ])
2031
2032 #
2033 # 2.6.35 file_operations.fsync taken 2 arguments.
2034 #
2035 AC_DEFUN([LC_FILE_FSYNC],
2036 [AC_MSG_CHECKING([if file_operations.fsync taken 2 arguments])
2037 LB_LINUX_TRY_COMPILE([
2038         #include <linux/fs.h>
2039 ],[
2040         ((struct file_operations *)0)->fsync(NULL, 0);
2041 ],[
2042         AC_DEFINE(HAVE_FILE_FSYNC_2ARGS, 1,
2043                 [file_operations.fsync taken 2 arguments])
2044         AC_MSG_RESULT([yes])
2045 ],[
2046         AC_MSG_RESULT([no])
2047 ])
2048 ])
2049
2050 #
2051 # 2.6.38 export blkdev_get_by_dev
2052 #
2053 AC_DEFUN([LC_BLKDEV_GET_BY_DEV],
2054 [LB_CHECK_SYMBOL_EXPORT([blkdev_get_by_dev],
2055 [fs/block_dev.c],[
2056 AC_DEFINE(HAVE_BLKDEV_GET_BY_DEV, 1,
2057             [blkdev_get_by_dev is exported by the kernel])
2058 ],[
2059 ])
2060 ])
2061
2062 #
2063 # 2.6.38 vfsmount.mnt_count doesn't use atomic_t
2064 #
2065 AC_DEFUN([LC_ATOMIC_MNT_COUNT],
2066 [AC_MSG_CHECKING([if vfsmount.mnt_count is atomic_t])
2067 LB_LINUX_TRY_COMPILE([
2068         #include <asm/atomic.h>
2069         #include <linux/fs.h>
2070         #include <linux/mount.h>
2071 ],[
2072         ((struct vfsmount *)0)->mnt_count = ((atomic_t) { 0 });
2073 ],[
2074         AC_DEFINE(HAVE_ATOMIC_MNT_COUNT, 1,
2075                 [vfsmount.mnt_count is atomic_t])
2076         AC_MSG_RESULT([yes])
2077 ],[
2078         AC_MSG_RESULT([no])
2079 ])
2080 ])
2081
2082 #
2083 # 2.6.38 use path as 4th parameter in quota_on.
2084 #
2085 AC_DEFUN([LC_QUOTA_ON_USE_PATH],
2086 [AC_MSG_CHECKING([quota_on use path as parameter])
2087 tmp_flags="$EXTRA_KCFLAGS"
2088 EXTRA_KCFLAGS="-Werror"
2089 LB_LINUX_TRY_COMPILE([
2090         #include <linux/fs.h>
2091         #include <linux/quota.h>
2092 ],[
2093         ((struct quotactl_ops *)0)->quota_on(NULL, 0, 0, ((struct path*)0));
2094 ],[
2095         AC_DEFINE(HAVE_QUOTA_ON_USE_PATH, 1,
2096                 [quota_on use path as 4th paramter])
2097         AC_MSG_RESULT([yes])
2098 ],[
2099         AC_MSG_RESULT([no])
2100 ])
2101 EXTRA_KCFLAGS="$tmp_flags"
2102 ])
2103
2104 #
2105 # 2.6.39 remove unplug_fn from request_queue.
2106 #
2107 AC_DEFUN([LC_REQUEST_QUEUE_UNPLUG_FN],
2108 [AC_MSG_CHECKING([if request_queue has unplug_fn field])
2109 LB_LINUX_TRY_COMPILE([
2110         #include <linux/blkdev.h>
2111 ],[
2112         struct request_queue rq;
2113         memset(rq.unplug_fn, 0, sizeof(rq.unplug_fn));
2114 ],[
2115         AC_DEFINE(HAVE_REQUEST_QUEUE_UNPLUG_FN, 1,
2116                   [request_queue has unplug_fn field])
2117         AC_MSG_RESULT([yes])
2118 ],[
2119         AC_MSG_RESULT([no])
2120 ])
2121 ])
2122
2123 #
2124 # 2.6.38 generic_permission taken 4 paremater.
2125 # in fact, it means rcu-walk aware permission bring.
2126 #
2127 AC_DEFUN([LC_GENERIC_PERMISSION],
2128 [AC_MSG_CHECKING([if generic_permission take 4 arguments])
2129 LB_LINUX_TRY_COMPILE([
2130         #include <linux/fs.h>
2131 ],[
2132         generic_permission(NULL, 0, 0, NULL);
2133 ],[
2134         AC_DEFINE(HAVE_GENERIC_PERMISSION_4ARGS, 1,
2135                   [generic_permission taken 4 arguments])
2136         AC_MSG_RESULT([yes])
2137 ],[
2138         AC_MSG_RESULT([no])
2139 ])
2140 ])
2141
2142 #
2143 # 2.6.38 export simple_setattr
2144 #
2145 AC_DEFUN([LC_EXPORT_SIMPLE_SETATTR],
2146 [LB_CHECK_SYMBOL_EXPORT([simple_setattr],
2147 [fs/libfs.c],[
2148 AC_DEFINE(HAVE_SIMPLE_SETATTR, 1,
2149             [simple_setattr is exported by the kernel])
2150 ],[
2151 ])
2152 ])
2153
2154 #
2155 # LC_PROG_LINUX
2156 #
2157 # Lustre linux kernel checks
2158 #
2159 AC_DEFUN([LC_PROG_LINUX],
2160          [LC_LUSTRE_VERSION_H
2161          LC_CONFIG_PINGER
2162          LC_CONFIG_CHECKSUM
2163          LC_CONFIG_LIBLUSTRE_RECOVERY
2164          LC_CONFIG_HEALTH_CHECK_WRITE
2165          LC_CONFIG_LRU_RESIZE
2166          LC_QUOTA_MODULE
2167          LC_LLITE_LLOOP_MODULE
2168
2169          # RHEL4 patches
2170          LC_EXPORT_TRUNCATE_COMPLETE
2171          LC_EXPORT_D_REHASH_COND
2172          LC_EXPORT___D_REHASH
2173          LC_EXPORT_NODE_TO_CPUMASK
2174
2175          LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
2176          LC_FILEMAP_POPULATE
2177          LC_BIT_SPINLOCK_H
2178
2179          LC_CONST_ACL_SIZE
2180
2181          LC_STRUCT_INTENT_FILE
2182
2183          LC_CAPA_CRYPTO
2184          LC_CONFIG_RMTCLIENT
2185          LC_CONFIG_GSS
2186          LC_FUNC_HAVE_CAN_SLEEP_ARG
2187          LC_FUNC_F_OP_FLOCK
2188          LC_QUOTA_READ
2189          LC_COOKIE_FOLLOW_LINK
2190          LC_FUNC_RCU
2191          LC_PERCPU_COUNTER
2192          LC_TASK_CLENV_STORE
2193
2194          # ~2.6.11
2195          LC_S_TIME_GRAN
2196          LC_SB_TIME_GRAN
2197
2198          # 2.6.12
2199          LC_RW_TREE_LOCK
2200          LC_EXPORT_SYNCHRONIZE_RCU
2201
2202          # 2.6.15
2203          LC_INODE_I_MUTEX
2204
2205          # 2.6.16
2206          LC_SECURITY_PLUG  # for SLES10 SP2
2207
2208          # 2.6.17
2209          LC_INODE_IPRIVATE
2210          LC_DQUOTOFF_MUTEX
2211
2212          # 2.6.18
2213          LC_NR_PAGECACHE
2214          LC_STATFS_DENTRY_PARAM
2215          LC_VFS_KERN_MOUNT
2216          LC_INVALIDATEPAGE_RETURN_INT
2217          LC_UMOUNTBEGIN_HAS_VFSMOUNT
2218          LC_SEQ_LOCK
2219          LC_EXPORT_FILEMAP_FDATAWRITE_RANGE
2220          LC_FLUSH_OWNER_ID
2221          if test x$enable_server = xyes ; then
2222                 LC_EXPORT_INVALIDATE_MAPPING_PAGES
2223          fi
2224
2225          #2.6.18 + RHEL5 (fc6)
2226          LC_PG_FS_MISC
2227          LC_PAGE_CHECKED
2228          LC_LINUX_FIEMAP_H
2229
2230          # 2.6.19
2231          LC_INODE_BLKSIZE
2232          LC_FILE_WRITEV
2233          LC_FILE_READV
2234
2235          # 2.6.20
2236          LC_CANCEL_DIRTY_PAGE
2237
2238          # raid5-zerocopy patch
2239          LC_PAGE_CONSTANT
2240
2241          # 2.6.22
2242          LC_INVALIDATE_BDEV_2ARG
2243          LC_ASYNC_BLOCK_CIPHER
2244          LC_STRUCT_HASH_DESC
2245          LC_STRUCT_BLKCIPHER_DESC
2246          LC_FS_RENAME_DOES_D_MOVE
2247
2248          # 2.6.23
2249          LC_UNREGISTER_BLKDEV_RETURN_INT
2250          LC_KERNEL_SPLICE_READ
2251          LC_KERNEL_SENDFILE
2252          LC_HAVE_EXPORTFS_H
2253          LC_VM_OP_FAULT
2254          LC_PROCFS_USERS
2255          LC_EXPORTFS_DECODE_FH
2256
2257          # 2.6.24
2258          LC_HAVE_MMTYPES_H
2259          LC_BIO_ENDIO_2ARG
2260          LC_FH_TO_DENTRY
2261          LC_PROCFS_DELETED
2262          LC_EXPORT_BDI_INIT
2263
2264          #2.6.25
2265          LC_MAPPING_CAP_WRITEBACK_DIRTY
2266
2267          # 2.6.26
2268          LC_FS_STRUCT_USE_PATH
2269
2270          # 2.6.27
2271          LC_INODE_PERMISION_2ARGS
2272          LC_FILE_REMOVE_SUID
2273          LC_TRYLOCKPAGE
2274          LC_READ_INODE_IN_SBOPS
2275          LC_EXPORT_INODE_PERMISSION
2276          LC_QUOTA_ON_5ARGS
2277          LC_QUOTA_OFF_3ARGS
2278          LC_VFS_DQ_OFF
2279          LC_LOCK_MAP_ACQUIRE
2280
2281          # 2.6.27.15-2 sles11
2282          LC_BI_HW_SEGMENTS
2283          LC_HAVE_QUOTAIO_H
2284          LC_VFS_SYMLINK_5ARGS
2285          LC_BDI_NAME
2286          LC_SB_ANY_QUOTA_ACTIVE
2287          LC_SB_HAS_QUOTA_ACTIVE
2288          LC_EXPORT_ADD_TO_PAGE_CACHE_LRU
2289
2290          # 2.6.29
2291          LC_SB_ANY_QUOTA_LOADED
2292
2293          # 2.6.30
2294          LC_EXPORT_CPUMASK_OF_NODE
2295
2296          # 2.6.31
2297          LC_BLK_QUEUE_LOG_BLK_SIZE
2298
2299          # 2.6.32
2300          LC_REQUEST_QUEUE_LIMITS
2301          LC_EXPORT_BDI_REGISTER
2302          LC_SB_BDI
2303          LC_BLK_QUEUE_MAX_SECTORS
2304          LC_BLK_QUEUE_MAX_SEGMENTS
2305          LC_SET_CPUS_ALLOWED
2306          LC_CACHE_UPCALL
2307
2308          # 2.6.35
2309          LC_FILE_FSYNC
2310          LC_EXPORT_SIMPLE_SETATTR
2311
2312          # 2.6.36
2313          LC_FS_STRUCT_RWLOCK
2314          LC_SBOPS_EVICT_INODE
2315
2316          # 2.6.38
2317          LC_ATOMIC_MNT_COUNT
2318          LC_BLKDEV_GET_BY_DEV
2319          LC_GENERIC_PERMISSION
2320          LC_QUOTA_ON_USE_PATH
2321
2322          # 2.6.39
2323          LC_REQUEST_QUEUE_UNPLUG_FN
2324
2325          #
2326          if test x$enable_server = xyes ; then
2327              AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
2328              LC_FUNC_DEV_SET_RDONLY
2329              LC_STACK_SIZE
2330              LC_QUOTA64
2331          fi
2332 ])
2333
2334 #
2335 # LC_CONFIG_CLIENT_SERVER
2336 #
2337 # Build client/server sides of Lustre
2338 #
2339 AC_DEFUN([LC_CONFIG_CLIENT_SERVER],
2340 [AC_MSG_CHECKING([whether to build Lustre server support])
2341 AC_ARG_ENABLE([server],
2342         AC_HELP_STRING([--disable-server],
2343                         [disable Lustre server support]),
2344         [],[enable_server='yes'])
2345 AC_MSG_RESULT([$enable_server])
2346
2347 AC_MSG_CHECKING([whether to build Lustre client support])
2348 AC_ARG_ENABLE([client],
2349         AC_HELP_STRING([--disable-client],
2350                         [disable Lustre client support]),
2351         [],[enable_client='yes'])
2352 AC_MSG_RESULT([$enable_client])])
2353
2354 #
2355 # LC_CONFIG_LIBLUSTRE
2356 #
2357 # whether to build liblustre
2358 #
2359 AC_DEFUN([LC_CONFIG_LIBLUSTRE],
2360 [AC_MSG_CHECKING([whether to build Lustre library])
2361 AC_ARG_ENABLE([liblustre],
2362         AC_HELP_STRING([--disable-liblustre],
2363                         [disable building of Lustre library]),
2364         [],[enable_liblustre=$with_sysio])
2365 AC_MSG_RESULT([$enable_liblustre])
2366 # only build sysio if liblustre is built
2367 with_sysio="$enable_liblustre"
2368
2369 AC_MSG_CHECKING([whether to build liblustre tests])
2370 AC_ARG_ENABLE([liblustre-tests],
2371         AC_HELP_STRING([--enable-liblustre-tests],
2372                         [enable liblustre tests, if --disable-tests is used]),
2373         [],[enable_liblustre_tests=$enable_tests])
2374 if test x$enable_liblustre != xyes ; then
2375    enable_liblustre_tests='no'
2376 fi
2377 AC_MSG_RESULT([$enable_liblustre_tests])
2378
2379 AC_MSG_CHECKING([whether to enable liblustre acl])
2380 AC_ARG_ENABLE([liblustre-acl],
2381         AC_HELP_STRING([--disable-liblustre-acl],
2382                         [disable ACL support for liblustre]),
2383         [],[enable_liblustre_acl=yes])
2384 AC_MSG_RESULT([$enable_liblustre_acl])
2385 if test x$enable_liblustre_acl = xyes ; then
2386   AC_DEFINE(LIBLUSTRE_POSIX_ACL, 1, Liblustre Support ACL-enabled MDS)
2387 fi
2388
2389 # 2.6.29 change prepare/commit_write to write_begin/end
2390 AC_DEFUN([LC_WRITE_BEGIN_END],
2391 [AC_MSG_CHECKING([if kernel has .write_begin/end])
2392 LB_LINUX_TRY_COMPILE([
2393         #include <linux/fs.h>
2394         #include <linux/pagemap.h>
2395 #ifdef HAVE_LINUX_MMTYPES_H
2396         #include <linux/mm_types.h>
2397 #endif
2398 ],[
2399         struct address_space_operations aops;
2400         struct page *page;
2401
2402         aops.write_begin = NULL;
2403         aops.write_end = NULL;
2404         page = grab_cache_page_write_begin(NULL, 0, 0);
2405 ], [
2406         AC_MSG_RESULT([yes])
2407         AC_DEFINE(HAVE_KERNEL_WRITE_BEGIN_END, 1,
2408                 [kernel has .write_begin/end])
2409 ],[
2410         AC_MSG_RESULT([no])
2411 ])
2412 ])
2413
2414 # 2.6.29 blkdev_put has 2 arguments
2415 AC_DEFUN([LC_BLKDEV_PUT_2ARGS],
2416 [AC_MSG_CHECKING([blkdev_put needs 2 parameters])
2417 LB_LINUX_TRY_COMPILE([
2418         #include <linux/fs.h>
2419 ],[
2420         blkdev_put(NULL, 0);
2421 ],[
2422         AC_DEFINE(HAVE_BLKDEV_PUT_2ARGS, 1,
2423                 [blkdev_put needs 2 paramters])
2424         AC_MSG_RESULT([yes])
2425 ],[
2426         AC_MSG_RESULT([no])
2427 ])
2428 ])
2429
2430 # 2.6.29 dentry_open has 4 arguments
2431 AC_DEFUN([LC_DENTRY_OPEN_4ARGS],
2432 [AC_MSG_CHECKING([dentry_open needs 4 parameters])
2433 LB_LINUX_TRY_COMPILE([
2434         #include <linux/fs.h>
2435 ],[
2436         dentry_open(NULL, NULL, 0, NULL);
2437 ],[
2438         AC_DEFINE(HAVE_DENTRY_OPEN_4ARGS, 1,
2439                 [dentry_open needs 4 paramters])
2440         AC_MSG_RESULT([yes])
2441 ],[
2442         AC_MSG_RESULT([no])
2443 ])
2444 ])
2445
2446 # 2.6.29 split file and anonymous page queues
2447 AC_DEFUN([LC_PAGEVEC_LRU_ADD_FILE],
2448 [AC_MSG_CHECKING([if kernel has .pagevec_lru_add_file])
2449 LB_LINUX_TRY_COMPILE([
2450         #include <linux/mm.h>
2451         #include <linux/pagevec.h>
2452 ],[
2453         struct pagevec lru_pagevec;
2454
2455         pagevec_init(&lru_pagevec, 0);
2456         pagevec_lru_add_file(&lru_pagevec);
2457 ],[
2458         AC_MSG_RESULT([yes])
2459         AC_DEFINE(HAVE_PAGEVEC_LRU_ADD_FILE, 1,
2460                 [kernel has .pagevec_lru_add_file])
2461 ],[
2462         AC_MSG_RESULT([no])
2463 ])
2464 ])
2465
2466 #
2467 # --enable-mpitest
2468 #
2469 AC_ARG_ENABLE(mpitests,
2470         AC_HELP_STRING([--enable-mpitests=yes|no|mpicc wrapper],
2471                            [include mpi tests]),
2472         [
2473          enable_mpitests=yes
2474          case $enableval in
2475          yes)
2476                 MPICC_WRAPPER=mpicc
2477                 ;;
2478          no)
2479                 enable_mpitests=no
2480                 ;;
2481          *)
2482                 MPICC_WRAPPER=$enableval
2483                  ;;
2484          esac
2485         ],
2486         [
2487         MPICC_WRAPPER=mpicc
2488         enable_mpitests=yes
2489         ]
2490 )
2491
2492 if test x$enable_mpitests != xno; then
2493         AC_MSG_CHECKING([whether mpitests can be built])
2494         oldcc=$CC
2495         CC=$MPICC_WRAPPER
2496         AC_LINK_IFELSE(
2497             [AC_LANG_PROGRAM([[
2498                     #include <mpi.h>
2499                 ]],[[
2500                     int flag;
2501                     MPI_Initialized(&flag);
2502                 ]])],
2503             [
2504                     AC_MSG_RESULT([yes])
2505             ],[
2506                     AC_MSG_RESULT([no])
2507                     enable_mpitests=no
2508         ])
2509         CC=$oldcc
2510 fi
2511 AC_SUBST(MPICC_WRAPPER)
2512
2513 AC_MSG_NOTICE([Enabling Lustre configure options for libsysio])
2514 ac_configure_args="$ac_configure_args --with-lustre-hack --with-sockets"
2515
2516 LC_CONFIG_PINGER
2517 LC_CONFIG_LIBLUSTRE_RECOVERY
2518 ])
2519
2520 #
2521 # LC_CONFIG_QUOTA
2522 #
2523 # whether to enable quota support global control
2524 #
2525 AC_DEFUN([LC_CONFIG_QUOTA],
2526 [AC_ARG_ENABLE([quota],
2527         AC_HELP_STRING([--enable-quota],
2528                         [enable quota support]),
2529         [],[enable_quota='yes'])
2530 ])
2531
2532 AC_DEFUN([LC_QUOTA],
2533 [#check global
2534 LC_CONFIG_QUOTA
2535 #check for utils
2536 AC_CHECK_HEADER(sys/quota.h,
2537                 [AC_DEFINE(HAVE_SYS_QUOTA_H, 1, [Define to 1 if you have <sys/quota.h>.])],
2538                 [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
2539 ])
2540
2541 #
2542 # LC_CONFIG_SPLIT
2543 #
2544 # whether to enable split support
2545 #
2546 AC_DEFUN([LC_CONFIG_SPLIT],
2547 [AC_MSG_CHECKING([whether to enable split support])
2548 AC_ARG_ENABLE([split],
2549         AC_HELP_STRING([--enable-split],
2550                         [enable split support]),
2551         [],[enable_split='no'])
2552 AC_MSG_RESULT([$enable_split])
2553 if test x$enable_split != xno; then
2554    AC_DEFINE(HAVE_SPLIT_SUPPORT, 1, [enable split support])
2555 fi
2556 ])
2557
2558 AC_DEFUN([LC_TASK_CLENV_TUX_INFO],
2559 [AC_MSG_CHECKING([tux_info])
2560 LB_LINUX_TRY_COMPILE([
2561         #include <linux/sched.h>
2562 ],[
2563         struct task_struct task;
2564         &task.tux_info;
2565 ],[
2566         AC_MSG_RESULT([yes])
2567         AC_DEFINE(LL_TASK_CL_ENV, tux_info, [have tux_info])
2568         have_task_clenv_store='yes'
2569 ],[
2570         AC_MSG_RESULT([no])
2571 ])
2572 ])
2573
2574 #
2575 # LC_LLITE_LLOOP_MODULE
2576 # lloop_llite.ko does not currently work with page sizes
2577 # of 64k or larger.
2578 #
2579 AC_DEFUN([LC_LLITE_LLOOP_MODULE],
2580 [AC_MSG_CHECKING([whether to enable llite_lloop module])
2581 LB_LINUX_TRY_COMPILE([
2582         #include <asm/page.h>
2583 ],[
2584         #if PAGE_SIZE >= 65536
2585         #error "PAGE_SIZE >= 65536"
2586         #endif
2587 ],[
2588         enable_llite_lloop_module='yes'
2589         AC_MSG_RESULT([yes])
2590 ],[
2591         enable_llite_lloop_module='no'
2592         AC_MSG_RESULT([no])
2593 ])
2594 ])
2595
2596 #
2597 # LC_CONFIGURE
2598 #
2599 # other configure checks
2600 #
2601 AC_DEFUN([LC_CONFIGURE],
2602 [LC_CONFIG_OBD_BUFFER_SIZE
2603
2604 if test $target_cpu == "i686" -o $target_cpu == "x86_64"; then
2605         CFLAGS="$CFLAGS -Werror"
2606 fi
2607
2608 # maximum MDS thread count
2609 LC_MDS_MAX_THREADS
2610
2611 # include/liblustre.h
2612 AC_CHECK_HEADERS([sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
2613
2614 # liblustre/llite_lib.h
2615 AC_CHECK_HEADERS([xtio.h file.h])
2616
2617 # liblustre/dir.c
2618 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
2619
2620 # liblustre/lutil.c
2621 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h catamount/data.h])
2622 AC_CHECK_FUNCS([inet_ntoa])
2623
2624 # libsysio/src/readlink.c
2625 LC_READLINK_SSIZE_T
2626
2627 # lvfs/prng.c - depends on linux/types.h from liblustre/dir.c
2628 AC_CHECK_HEADERS([linux/random.h], [], [],
2629                  [#ifdef HAVE_LINUX_TYPES_H
2630                   # include <linux/types.h>
2631                   #endif
2632                  ])
2633
2634 # utils/llverfs.c
2635 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
2636
2637 # check for -lz support
2638 ZLIB=""
2639 AC_CHECK_LIB([z],
2640              [adler32],
2641              [AC_CHECK_HEADERS([zlib.h],
2642                                [ZLIB="-lz"
2643                                 AC_DEFINE([HAVE_ADLER], 1,
2644                                           [support alder32 checksum type])],
2645                                [AC_MSG_WARN([No zlib-devel package found,
2646                                              unable to use adler32 checksum])])],
2647              [AC_MSG_WARN([No zlib package found, unable to use adler32 checksum])]
2648 )
2649 AC_SUBST(ZLIB)
2650
2651 # Super safe df
2652 AC_ARG_ENABLE([mindf],
2653       AC_HELP_STRING([--enable-mindf],
2654                       [Make statfs report the minimum available space on any single OST instead of the sum of free space on all OSTs]),
2655       [],[])
2656 if test "$enable_mindf" = "yes" ;  then
2657       AC_DEFINE([MIN_DF], 1, [Report minimum OST free space])
2658 fi
2659
2660 AC_ARG_ENABLE([fail_alloc],
2661         AC_HELP_STRING([--disable-fail-alloc],
2662                 [disable randomly alloc failure]),
2663         [],[enable_fail_alloc=yes])
2664 AC_MSG_CHECKING([whether to randomly failing memory alloc])
2665 AC_MSG_RESULT([$enable_fail_alloc])
2666 if test x$enable_fail_alloc != xno ; then
2667         AC_DEFINE([RANDOM_FAIL_ALLOC], 1, [enable randomly alloc failure])
2668 fi
2669
2670 AC_ARG_ENABLE([invariants],
2671         AC_HELP_STRING([--enable-invariants],
2672                 [enable invariant checking (cpu intensive)]),
2673         [],[])
2674 AC_MSG_CHECKING([whether to check invariants (expensive cpu-wise)])
2675 AC_MSG_RESULT([$enable_invariants])
2676 if test x$enable_invariants = xyes ; then
2677         AC_DEFINE([INVARIANT_CHECK], 1, [enable invariant checking])
2678 fi
2679
2680 AC_ARG_ENABLE([lu_ref],
2681         AC_HELP_STRING([--enable-lu_ref],
2682                 [enable lu_ref reference tracking code]),
2683         [],[])
2684 AC_MSG_CHECKING([whether to track references with lu_ref])
2685 AC_MSG_RESULT([$enable_lu_ref])
2686 if test x$enable_lu_ref = xyes ; then
2687         AC_DEFINE([USE_LU_REF], 1, [enable lu_ref reference tracking code])
2688 fi
2689
2690 AC_ARG_ENABLE([pgstate-track],
2691               AC_HELP_STRING([--enable-pgstate-track],
2692                              [enable page state tracking]),
2693               [enable_pgstat_track='yes'],[])
2694 AC_MSG_CHECKING([whether to enable page state tracking])
2695 AC_MSG_RESULT([$enable_pgstat_track])
2696 if test x$enable_pgstat_track = xyes ; then
2697         AC_DEFINE([LUSTRE_PAGESTATE_TRACKING], 1,
2698                   [enable page state tracking code])
2699 fi
2700
2701          #2.6.29
2702          LC_WRITE_BEGIN_END
2703          LC_D_OBTAIN_ALIAS
2704          LC_BLKDEV_PUT_2ARGS
2705          LC_DENTRY_OPEN_4ARGS
2706          LC_PAGEVEC_LRU_ADD_FILE
2707
2708 ])
2709
2710 #
2711 # LC_CONDITIONALS
2712 #
2713 # AM_CONDITIONALS for lustre
2714 #
2715 AC_DEFUN([LC_CONDITIONALS],
2716 [AM_CONDITIONAL(LIBLUSTRE, test x$enable_liblustre = xyes)
2717 AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
2718 AM_CONDITIONAL(LIBLUSTRE_TESTS, test x$enable_liblustre_tests = xyes)
2719 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
2720 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
2721 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
2722 AM_CONDITIONAL(QUOTA, test x$enable_quota_module = xyes)
2723 AM_CONDITIONAL(SPLIT, test x$enable_split = xyes)
2724 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
2725 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
2726 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
2727 AM_CONDITIONAL(GSS_KEYRING, test x$enable_gss_keyring = xyes)
2728 AM_CONDITIONAL(GSS_PIPEFS, test x$enable_gss_pipefs = xyes)
2729 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
2730 AM_CONDITIONAL(LLITE_LLOOP, test x$enable_llite_lloop_module = xyes)
2731 ])
2732
2733 #
2734 # LC_CONFIG_FILES
2735 #
2736 # files that should be generated with AC_OUTPUT
2737 #
2738 AC_DEFUN([LC_CONFIG_FILES],
2739 [AC_CONFIG_FILES([
2740 lustre/Makefile
2741 lustre/autoMakefile
2742 lustre/autoconf/Makefile
2743 lustre/conf/Makefile
2744 lustre/contrib/Makefile
2745 lustre/doc/Makefile
2746 lustre/include/Makefile
2747 lustre/include/lustre_ver.h
2748 lustre/include/linux/Makefile
2749 lustre/include/lustre/Makefile
2750 lustre/kernel_patches/targets/2.6-rhel6.target
2751 lustre/kernel_patches/targets/2.6-rhel5.target
2752 lustre/kernel_patches/targets/2.6-sles10.target
2753 lustre/kernel_patches/targets/2.6-sles11.target
2754 lustre/kernel_patches/targets/2.6-oel5.target
2755 lustre/kernel_patches/targets/2.6-fc11.target
2756 lustre/kernel_patches/targets/2.6-fc12.target
2757 lustre/ldlm/Makefile
2758 lustre/fid/Makefile
2759 lustre/fid/autoMakefile
2760 lustre/liblustre/Makefile
2761 lustre/liblustre/tests/Makefile
2762 lustre/liblustre/tests/mpi/Makefile
2763 lustre/llite/Makefile
2764 lustre/llite/autoMakefile
2765 lustre/lclient/Makefile
2766 lustre/lov/Makefile
2767 lustre/lov/autoMakefile
2768 lustre/lvfs/Makefile
2769 lustre/lvfs/autoMakefile
2770 lustre/mdc/Makefile
2771 lustre/mdc/autoMakefile
2772 lustre/lmv/Makefile
2773 lustre/lmv/autoMakefile
2774 lustre/mds/Makefile
2775 lustre/mds/autoMakefile
2776 lustre/mdt/Makefile
2777 lustre/mdt/autoMakefile
2778 lustre/cmm/Makefile
2779 lustre/cmm/autoMakefile
2780 lustre/mdd/Makefile
2781 lustre/mdd/autoMakefile
2782 lustre/fld/Makefile
2783 lustre/fld/autoMakefile
2784 lustre/obdclass/Makefile
2785 lustre/obdclass/autoMakefile
2786 lustre/obdclass/linux/Makefile
2787 lustre/obdecho/Makefile
2788 lustre/obdecho/autoMakefile
2789 lustre/obdfilter/Makefile
2790 lustre/obdfilter/autoMakefile
2791 lustre/osc/Makefile
2792 lustre/osc/autoMakefile
2793 lustre/ost/Makefile
2794 lustre/ost/autoMakefile
2795 lustre/osd-ldiskfs/Makefile
2796 lustre/osd-ldiskfs/autoMakefile
2797 lustre/mgc/Makefile
2798 lustre/mgc/autoMakefile
2799 lustre/mgs/Makefile
2800 lustre/mgs/autoMakefile
2801 lustre/ptlrpc/Makefile
2802 lustre/ptlrpc/autoMakefile
2803 lustre/ptlrpc/gss/Makefile
2804 lustre/ptlrpc/gss/autoMakefile
2805 lustre/quota/Makefile
2806 lustre/quota/autoMakefile
2807 lustre/scripts/Makefile
2808 lustre/tests/Makefile
2809 lustre/tests/mpi/Makefile
2810 lustre/utils/Makefile
2811 lustre/utils/gss/Makefile
2812 lustre/obdclass/darwin/Makefile
2813 ])
2814 ])