]> git.proxmox.com Git - mirror_spl-debian.git/blob - config/spl-build.m4
Linux 3.1 compat, vfs_fsync()
[mirror_spl-debian.git] / config / spl-build.m4
1 ###############################################################################
2 # Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 # Copyright (C) 2007 The Regents of the University of California.
4 # Written by Brian Behlendorf <behlendorf1@llnl.gov>.
5 ###############################################################################
6 # SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration.
7 ###############################################################################
8
9 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
10 SPL_AC_KERNEL
11 SPL_AC_KERNEL_CONFIG
12
13 if test "${LINUX_OBJ}" != "${LINUX}"; then
14 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
15 fi
16 AC_SUBST(KERNELMAKE_PARAMS)
17
18 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
19 AC_SUBST(KERNELCPPFLAGS)
20
21 SPL_AC_DEBUG
22 SPL_AC_DEBUG_KMEM
23 SPL_AC_DEBUG_KMEM_TRACKING
24 SPL_AC_ATOMIC_SPINLOCK
25 SPL_AC_TYPE_ATOMIC64_CMPXCHG
26 SPL_AC_TYPE_ATOMIC64_XCHG
27 SPL_AC_TYPE_UINTPTR_T
28 SPL_AC_3ARGS_INIT_WORK
29 SPL_AC_2ARGS_REGISTER_SYSCTL
30 SPL_AC_SET_SHRINKER
31 SPL_AC_3ARGS_SHRINKER_CALLBACK
32 SPL_AC_PATH_IN_NAMEIDATA
33 SPL_AC_TASK_CURR
34 SPL_AC_CTL_UNNUMBERED
35 SPL_AC_CTL_NAME
36 SPL_AC_FLS64
37 SPL_AC_DEVICE_CREATE
38 SPL_AC_5ARGS_DEVICE_CREATE
39 SPL_AC_CLASS_DEVICE_CREATE
40 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
41 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
42 SPL_AC_TIMESPEC_SUB
43 SPL_AC_INIT_UTSNAME
44 SPL_AC_FDTABLE_HEADER
45 SPL_AC_FILES_FDTABLE
46 SPL_AC_UACCESS_HEADER
47 SPL_AC_KMALLOC_NODE
48 SPL_AC_MONOTONIC_CLOCK
49 SPL_AC_INODE_I_MUTEX
50 SPL_AC_MUTEX_OWNER
51 SPL_AC_MUTEX_OWNER_TASK_STRUCT
52 SPL_AC_MUTEX_LOCK_NESTED
53 SPL_AC_3ARGS_ON_EACH_CPU
54 SPL_AC_KALLSYMS_LOOKUP_NAME
55 SPL_AC_GET_VMALLOC_INFO
56 SPL_AC_PGDAT_HELPERS
57 SPL_AC_FIRST_ONLINE_PGDAT
58 SPL_AC_NEXT_ONLINE_PGDAT
59 SPL_AC_NEXT_ZONE
60 SPL_AC_PGDAT_LIST
61 SPL_AC_GLOBAL_PAGE_STATE
62 SPL_AC_ZONE_STAT_ITEM_FREE
63 SPL_AC_ZONE_STAT_ITEM_INACTIVE
64 SPL_AC_ZONE_STAT_ITEM_ACTIVE
65 SPL_AC_GET_ZONE_COUNTS
66 SPL_AC_USER_PATH_DIR
67 SPL_AC_SET_FS_PWD
68 SPL_AC_2ARGS_SET_FS_PWD
69 SPL_AC_2ARGS_VFS_UNLINK
70 SPL_AC_4ARGS_VFS_RENAME
71 SPL_AC_VFS_FSYNC
72 SPL_AC_2ARGS_VFS_FSYNC
73 SPL_AC_FS_STRUCT_SPINLOCK
74 SPL_AC_CRED_STRUCT
75 SPL_AC_GROUPS_SEARCH
76 SPL_AC_PUT_TASK_STRUCT
77 SPL_AC_5ARGS_PROC_HANDLER
78 SPL_AC_KVASPRINTF
79 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
80 SPL_AC_KERNEL_INVALIDATE_INODES
81 SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES
82 SPL_AC_SHRINK_DCACHE_MEMORY
83 SPL_AC_SHRINK_ICACHE_MEMORY
84 SPL_AC_KERN_PATH_PARENT_HEADER
85 SPL_AC_KERN_PATH_PARENT_SYMBOL
86 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
87 SPL_AC_SHRINK_CONTROL_STRUCT
88 ])
89
90 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
91 modpost=$LINUX/scripts/Makefile.modpost
92 AC_MSG_CHECKING([kernel file name for module symbols])
93 if test -f "$modpost"; then
94 if grep -q Modules.symvers $modpost; then
95 LINUX_SYMBOLS=Modules.symvers
96 else
97 LINUX_SYMBOLS=Module.symvers
98 fi
99
100 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
101 AC_MSG_ERROR([
102 *** Please make sure the kernel devel package for your distribution
103 *** is installed. If your building with a custom kernel make sure the
104 *** kernel is configured, built, and the '--with-linux=PATH' configure
105 *** option refers to the location of the kernel source.])
106 fi
107 else
108 LINUX_SYMBOLS=NONE
109 fi
110 AC_MSG_RESULT($LINUX_SYMBOLS)
111 AC_SUBST(LINUX_SYMBOLS)
112 ])
113
114 AC_DEFUN([SPL_AC_KERNEL], [
115 AC_ARG_WITH([linux],
116 AS_HELP_STRING([--with-linux=PATH],
117 [Path to kernel source]),
118 [kernelsrc="$withval"])
119
120 AC_ARG_WITH([linux-obj],
121 AS_HELP_STRING([--with-linux-obj=PATH],
122 [Path to kernel build objects]),
123 [kernelbuild="$withval"])
124
125 AC_MSG_CHECKING([kernel source directory])
126 if test -z "$kernelsrc"; then
127 if test -e "/lib/modules/$(uname -r)/source"; then
128 headersdir="/lib/modules/$(uname -r)/source"
129 sourcelink=$(readlink -f "$headersdir")
130 elif test -e "/lib/modules/$(uname -r)/build"; then
131 headersdir="/lib/modules/$(uname -r)/build"
132 sourcelink=$(readlink -f "$headersdir")
133 else
134 sourcelink=$(ls -1d /usr/src/kernels/* \
135 /usr/src/linux-* \
136 2>/dev/null | grep -v obj | tail -1)
137 fi
138
139 if test -n "$sourcelink" && test -e ${sourcelink}; then
140 kernelsrc=`readlink -f ${sourcelink}`
141 else
142 AC_MSG_RESULT([Not found])
143 AC_MSG_ERROR([
144 *** Please make sure the kernel devel package for your distribution
145 *** is installed then try again. If that fails you can specify the
146 *** location of the kernel source with the '--with-linux=PATH' option.])
147 fi
148 else
149 if test "$kernelsrc" = "NONE"; then
150 kernsrcver=NONE
151 fi
152 fi
153
154 AC_MSG_RESULT([$kernelsrc])
155 AC_MSG_CHECKING([kernel build directory])
156 if test -z "$kernelbuild"; then
157 if test -e "/lib/modules/$(uname -r)/build"; then
158 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
159 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
160 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
161 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
162 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
163 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
164 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
165 else
166 kernelbuild=${kernelsrc}
167 fi
168 fi
169 AC_MSG_RESULT([$kernelbuild])
170
171 AC_MSG_CHECKING([kernel source version])
172 utsrelease1=$kernelbuild/include/linux/version.h
173 utsrelease2=$kernelbuild/include/linux/utsrelease.h
174 utsrelease3=$kernelbuild/include/generated/utsrelease.h
175 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
176 utsrelease=linux/version.h
177 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
178 utsrelease=linux/utsrelease.h
179 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
180 utsrelease=generated/utsrelease.h
181 fi
182
183 if test "$utsrelease"; then
184 kernsrcver=`(echo "#include <$utsrelease>";
185 echo "kernsrcver=UTS_RELEASE") |
186 cpp -I $kernelbuild/include |
187 grep "^kernsrcver=" | cut -d \" -f 2`
188
189 if test -z "$kernsrcver"; then
190 AC_MSG_RESULT([Not found])
191 AC_MSG_ERROR([*** Cannot determine kernel version.])
192 fi
193 else
194 AC_MSG_RESULT([Not found])
195 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
196 fi
197
198 AC_MSG_RESULT([$kernsrcver])
199
200 LINUX=${kernelsrc}
201 LINUX_OBJ=${kernelbuild}
202 LINUX_VERSION=${kernsrcver}
203
204 AC_SUBST(LINUX)
205 AC_SUBST(LINUX_OBJ)
206 AC_SUBST(LINUX_VERSION)
207
208 SPL_AC_MODULE_SYMVERS
209 ])
210
211 AC_DEFUN([SPL_AC_KERNEL_CONFIG], [
212 SPL_LINUX_CONFIG([PREEMPT],
213 AC_MSG_ERROR([
214 *** Kernel built with CONFIG_PREEMPT which is not supported.
215 ** You must rebuild your kernel without this option.]), [])
216 ])
217
218 dnl #
219 dnl # Default SPL user configuration
220 dnl #
221 AC_DEFUN([SPL_AC_CONFIG_USER], [])
222
223 dnl #
224 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
225 dnl # are missing it is non-fatal but you will not be able to build
226 dnl # RPM packages and will be warned if you try too.
227 dnl #
228 AC_DEFUN([SPL_AC_RPM], [
229 RPM=rpm
230 RPMBUILD=rpmbuild
231
232 AC_MSG_CHECKING([whether $RPM is available])
233 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
234 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
235 HAVE_RPM=yes
236 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
237 ],[
238 HAVE_RPM=no
239 AC_MSG_RESULT([$HAVE_RPM])
240 ])
241
242 AC_MSG_CHECKING([whether $RPMBUILD is available])
243 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
244 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
245 HAVE_RPMBUILD=yes
246 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
247 ],[
248 HAVE_RPMBUILD=no
249 AC_MSG_RESULT([$HAVE_RPMBUILD])
250 ])
251
252 AC_SUBST(HAVE_RPM)
253 AC_SUBST(RPM)
254 AC_SUBST(RPM_VERSION)
255
256 AC_SUBST(HAVE_RPMBUILD)
257 AC_SUBST(RPMBUILD)
258 AC_SUBST(RPMBUILD_VERSION)
259 ])
260
261 dnl #
262 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
263 dnl # tools are missing it is non-fatal but you will not be able to build
264 dnl # DEB packages and will be warned if you try too.
265 dnl #
266 AC_DEFUN([SPL_AC_DPKG], [
267 DPKG=dpkg
268 DPKGBUILD=dpkg-buildpackage
269
270 AC_MSG_CHECKING([whether $DPKG is available])
271 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
272 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
273 HAVE_DPKG=yes
274 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
275 ],[
276 HAVE_DPKG=no
277 AC_MSG_RESULT([$HAVE_DPKG])
278 ])
279
280 AC_MSG_CHECKING([whether $DPKGBUILD is available])
281 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
282 DPKGBUILD_VERSION=$(echo $tmp | \
283 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
284 HAVE_DPKGBUILD=yes
285 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
286 ],[
287 HAVE_DPKGBUILD=no
288 AC_MSG_RESULT([$HAVE_DPKGBUILD])
289 ])
290
291 AC_SUBST(HAVE_DPKG)
292 AC_SUBST(DPKG)
293 AC_SUBST(DPKG_VERSION)
294
295 AC_SUBST(HAVE_DPKGBUILD)
296 AC_SUBST(DPKGBUILD)
297 AC_SUBST(DPKGBUILD_VERSION)
298 ])
299
300 dnl #
301 dnl # Until native packaging for various different packing systems
302 dnl # can be added the least we can do is attempt to use alien to
303 dnl # convert the RPM packages to the needed package type. This is
304 dnl # a hack but so far it has worked reasonable well.
305 dnl #
306 AC_DEFUN([SPL_AC_ALIEN], [
307 ALIEN=alien
308
309 AC_MSG_CHECKING([whether $ALIEN is available])
310 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
311 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
312 HAVE_ALIEN=yes
313 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
314 ],[
315 HAVE_ALIEN=no
316 AC_MSG_RESULT([$HAVE_ALIEN])
317 ])
318
319 AC_SUBST(HAVE_ALIEN)
320 AC_SUBST(ALIEN)
321 AC_SUBST(ALIEN_VERSION)
322 ])
323
324 dnl #
325 dnl # Using the VENDOR tag from config.guess set the default
326 dnl # package type for 'make pkg': (rpm | deb | tgz)
327 dnl #
328 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
329 AC_MSG_CHECKING([linux distribution])
330 if test -f /etc/redhat-release ; then
331 VENDOR=redhat ;
332 elif test -f /etc/fedora-release ; then
333 VENDOR=fedora ;
334 elif test -f /etc/lsb-release ; then
335 VENDOR=ubuntu ;
336 elif test -f /etc/debian_version ; then
337 VENDOR=debian ;
338 elif test -f /etc/SuSE-release ; then
339 VENDOR=sles ;
340 elif test -f /etc/slackware-version ; then
341 VENDOR=slackware ;
342 elif test -f /etc/gentoo-release ; then
343 VENDOR=gentoo ;
344 else
345 VENDOR= ;
346 fi
347 AC_MSG_RESULT([$VENDOR])
348 AC_SUBST(VENDOR)
349
350 AC_MSG_CHECKING([default package type])
351 case "$VENDOR" in
352 fedora) DEFAULT_PACKAGE=rpm ;;
353 redhat) DEFAULT_PACKAGE=rpm ;;
354 sles) DEFAULT_PACKAGE=rpm ;;
355 ubuntu) DEFAULT_PACKAGE=deb ;;
356 debian) DEFAULT_PACKAGE=deb ;;
357 slackware) DEFAULT_PACKAGE=tgz ;;
358 *) DEFAULT_PACKAGE=rpm ;;
359 esac
360
361 AC_MSG_RESULT([$DEFAULT_PACKAGE])
362 AC_SUBST(DEFAULT_PACKAGE)
363 ])
364
365 dnl #
366 dnl # Default SPL user configuration
367 dnl #
368 AC_DEFUN([SPL_AC_PACKAGE], [
369 SPL_AC_RPM
370 SPL_AC_DPKG
371 SPL_AC_ALIEN
372 SPL_AC_DEFAULT_PACKAGE
373 ])
374
375 AC_DEFUN([SPL_AC_LICENSE], [
376 AC_MSG_CHECKING([spl license])
377 LICENSE=GPL
378 AC_MSG_RESULT([$LICENSE])
379 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
380 AC_SUBST(LICENSE)
381 ])
382
383 AC_DEFUN([SPL_AC_CONFIG], [
384 SPL_CONFIG=all
385 AC_ARG_WITH([config],
386 AS_HELP_STRING([--with-config=CONFIG],
387 [Config file 'kernel|user|all|srpm']),
388 [SPL_CONFIG="$withval"])
389
390 AC_MSG_CHECKING([spl config])
391 AC_MSG_RESULT([$SPL_CONFIG]);
392 AC_SUBST(SPL_CONFIG)
393
394 case "$SPL_CONFIG" in
395 kernel) SPL_AC_CONFIG_KERNEL ;;
396 user) SPL_AC_CONFIG_USER ;;
397 all) SPL_AC_CONFIG_KERNEL
398 SPL_AC_CONFIG_USER ;;
399 srpm) ;;
400 *)
401 AC_MSG_RESULT([Error!])
402 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
403 user kernel|user|all|srpm]) ;;
404 esac
405
406 AM_CONDITIONAL([CONFIG_USER],
407 [test "$SPL_CONFIG" = user] ||
408 [test "$SPL_CONFIG" = all])
409 AM_CONDITIONAL([CONFIG_KERNEL],
410 [test "$SPL_CONFIG" = kernel] ||
411 [test "$SPL_CONFIG" = all])
412 ])
413
414 dnl #
415 dnl # Enable if the SPL should be compiled with internal debugging enabled.
416 dnl # By default this support is disabled.
417 dnl #
418 AC_DEFUN([SPL_AC_DEBUG], [
419 AC_MSG_CHECKING([whether debugging is enabled])
420 AC_ARG_ENABLE([debug],
421 [AS_HELP_STRING([--enable-debug],
422 [Enable generic debug support @<:@default=no@:>@])],
423 [],
424 [enable_debug=no])
425
426 AS_IF([test "x$enable_debug" = xyes],
427 [
428 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
429 DEBUG_CFLAGS="-DDEBUG -Werror"
430 ],
431 [
432 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
433 DEBUG_CFLAGS="-DNDEBUG"
434 ])
435
436 AC_SUBST(DEBUG_CFLAGS)
437 AC_MSG_RESULT([$enable_debug])
438 ])
439
440 dnl #
441 dnl # Enabled by default it provides a minimal level of memory tracking.
442 dnl # A total count of bytes allocated is kept for each alloc and free.
443 dnl # Then at module unload time a report to the console will be printed
444 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
445 dnl # and provide an easy way to inspect the kmem based slab.
446 dnl #
447 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
448 AC_ARG_ENABLE([debug-kmem],
449 [AS_HELP_STRING([--enable-debug-kmem],
450 [Enable basic kmem accounting @<:@default=yes@:>@])],
451 [],
452 [enable_debug_kmem=yes])
453
454 AS_IF([test "x$enable_debug_kmem" = xyes],
455 [AC_DEFINE([DEBUG_KMEM], [1],
456 [Define to 1 to enable basic kmem accounting])
457 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
458
459 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
460 AC_MSG_RESULT([$enable_debug_kmem])
461 ])
462
463 dnl #
464 dnl # Disabled by default it provides detailed memory tracking. This
465 dnl # feature also requires --enable-debug-kmem to be set. When enabled
466 dnl # not only will total bytes be tracked but also the location of every
467 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
468 dnl # addresses and where they were allocated will be dumped to the console.
469 dnl # Enabling this feature has a significant impact on performance but it
470 dnl # makes finding memory leaks pretty straight forward.
471 dnl #
472 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
473 AC_ARG_ENABLE([debug-kmem-tracking],
474 [AS_HELP_STRING([--enable-debug-kmem-tracking],
475 [Enable detailed kmem tracking @<:@default=no@:>@])],
476 [],
477 [enable_debug_kmem_tracking=no])
478
479 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
480 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
481 [Define to 1 to enable detailed kmem tracking])
482 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
483
484 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
485 AC_MSG_RESULT([$enable_debug_kmem_tracking])
486 ])
487
488 dnl #
489 dnl # SPL_LINUX_CONFTEST
490 dnl #
491 AC_DEFUN([SPL_LINUX_CONFTEST], [
492 cat confdefs.h - <<_ACEOF >conftest.c
493 $1
494 _ACEOF
495 ])
496
497 dnl #
498 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
499 dnl #
500 m4_define([SPL_LANG_PROGRAM], [
501 $1
502 int
503 main (void)
504 {
505 dnl Do *not* indent the following line: there may be CPP directives.
506 dnl Don't move the `;' right after for the same reason.
507 $2
508 ;
509 return 0;
510 }
511 ])
512
513 dnl #
514 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
515 dnl #
516 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
517 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
518 rm -Rf build && mkdir -p build
519 echo "obj-m := conftest.o" >build/Makefile
520 AS_IF(
521 [AC_TRY_COMMAND(cp conftest.c build && make [$2] -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
522 [$4],
523 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
524 )
525 rm -Rf build
526 ])
527
528 dnl #
529 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
530 dnl #
531 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
532 [SPL_LINUX_COMPILE_IFELSE(
533 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
534 [modules],
535 [test -s build/conftest.o],
536 [$3], [$4])
537 ])
538
539 dnl #
540 dnl # SPL_LINUX_CONFIG
541 dnl #
542 AC_DEFUN([SPL_LINUX_CONFIG],
543 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
544 SPL_LINUX_TRY_COMPILE([
545 #include <linux/module.h>
546 ],[
547 #ifndef CONFIG_$1
548 #error CONFIG_$1 not #defined
549 #endif
550 ],[
551 AC_MSG_RESULT([yes])
552 $2
553 ],[
554 AC_MSG_RESULT([no])
555 $3
556 ])
557 ])
558
559 dnl #
560 dnl # SPL_CHECK_SYMBOL_EXPORT
561 dnl # check symbol exported or not
562 dnl #
563 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
564 [AC_MSG_CHECKING([whether symbol $1 is exported])
565 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
566 $LINUX_OBJ/Module*.symvers 2>/dev/null
567 rc=$?
568 if test $rc -ne 0; then
569 export=0
570 for file in $2; do
571 grep -q -E "EXPORT_SYMBOL.*($1)" \
572 "$LINUX_OBJ/$file" 2>/dev/null
573 rc=$?
574 if test $rc -eq 0; then
575 export=1
576 break;
577 fi
578 done
579 if test $export -eq 0; then
580 AC_MSG_RESULT([no])
581 $4
582 else
583 AC_MSG_RESULT([yes])
584 $3
585 fi
586 else
587 AC_MSG_RESULT([yes])
588 $3
589 fi
590 ])
591
592 dnl #
593 dnl # SPL_CHECK_SYMBOL_HEADER
594 dnl # check if a symbol prototype is defined in listed headers.
595 dnl #
596 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
597 AC_MSG_CHECKING([whether symbol $1 exists in header])
598 header=0
599 for file in $3; do
600 grep -q "$2" "$LINUX/$file" 2>/dev/null
601 rc=$?
602 if test $rc -eq 0; then
603 header=1
604 break;
605 fi
606 done
607 if test $header -eq 0; then
608 AC_MSG_RESULT([no])
609 $5
610 else
611 AC_MSG_RESULT([yes])
612 $4
613 fi
614 ])
615
616 dnl #
617 dnl # SPL_CHECK_HEADER
618 dnl # check whether header exists and define HAVE_$2_HEADER
619 dnl #
620 AC_DEFUN([SPL_CHECK_HEADER],
621 [AC_MSG_CHECKING([whether header $1 exists])
622 SPL_LINUX_TRY_COMPILE([
623 #include <$1>
624 ],[
625 return 0;
626 ],[
627 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
628 AC_MSG_RESULT(yes)
629 $3
630 ],[
631 AC_MSG_RESULT(no)
632 $4
633 ])
634 ])
635
636 dnl #
637 dnl # Use the atomic implemenation based on global spinlocks. This
638 dnl # should only be needed by 32-bit kernels which do not provide
639 dnl # the atomic64_* API. It may be optionally enabled as a fallback
640 dnl # if problems are observed with the direct mapping to the native
641 dnl # Linux atomic operations. You may not disable atomic spinlocks
642 dnl # if you kernel does not an atomic64_* API.
643 dnl #
644 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
645 AC_ARG_ENABLE([atomic-spinlocks],
646 [AS_HELP_STRING([--enable-atomic-spinlocks],
647 [Atomic types use spinlocks @<:@default=check@:>@])],
648 [],
649 [enable_atomic_spinlocks=check])
650
651 SPL_LINUX_TRY_COMPILE([
652 #include <asm/atomic.h>
653 ],[
654 atomic64_t *ptr __attribute__ ((unused));
655 ],[
656 have_atomic64_t=yes
657 AC_DEFINE(HAVE_ATOMIC64_T, 1,
658 [kernel defines atomic64_t])
659 ],[
660 have_atomic64_t=no
661 ])
662
663 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
664 AS_IF([test "x$have_atomic64_t" = xyes], [
665 enable_atomic_spinlocks=no
666 ],[
667 enable_atomic_spinlocks=yes
668 ])
669 ])
670
671 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
672 AC_DEFINE([ATOMIC_SPINLOCK], [1],
673 [Atomic types use spinlocks])
674 ],[
675 AS_IF([test "x$have_atomic64_t" = xno], [
676 AC_MSG_FAILURE(
677 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
678 ])
679 ])
680
681 AC_MSG_CHECKING([whether atomic types use spinlocks])
682 AC_MSG_RESULT([$enable_atomic_spinlocks])
683
684 AC_MSG_CHECKING([whether kernel defines atomic64_t])
685 AC_MSG_RESULT([$have_atomic64_t])
686 ])
687
688 dnl #
689 dnl # 2.6.24 API change,
690 dnl # check if atomic64_cmpxchg is defined
691 dnl #
692 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
693 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
694 SPL_LINUX_TRY_COMPILE([
695 #include <asm/atomic.h>
696 #include <asm/system.h>
697 ],[
698 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
699 ],[
700 AC_MSG_RESULT([yes])
701 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
702 [kernel defines atomic64_cmpxchg])
703 ],[
704 AC_MSG_RESULT([no])
705 ])
706 ])
707
708 dnl #
709 dnl # 2.6.24 API change,
710 dnl # check if atomic64_xchg is defined
711 dnl #
712 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
713 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
714 SPL_LINUX_TRY_COMPILE([
715 #include <asm/atomic.h>
716 ],[
717 atomic64_xchg((atomic64_t *)NULL, 0);
718 ],[
719 AC_MSG_RESULT([yes])
720 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
721 [kernel defines atomic64_xchg])
722 ],[
723 AC_MSG_RESULT([no])
724 ])
725 ])
726
727 dnl #
728 dnl # 2.6.24 API change,
729 dnl # check if uintptr_t typedef is defined
730 dnl #
731 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
732 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
733 SPL_LINUX_TRY_COMPILE([
734 #include <linux/types.h>
735 ],[
736 uintptr_t *ptr __attribute__ ((unused));
737 ],[
738 AC_MSG_RESULT([yes])
739 AC_DEFINE(HAVE_UINTPTR_T, 1,
740 [kernel defines uintptr_t])
741 ],[
742 AC_MSG_RESULT([no])
743 ])
744 ])
745
746 dnl #
747 dnl # 2.6.20 API change,
748 dnl # INIT_WORK use 2 args and not store data inside
749 dnl #
750 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
751 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
752 SPL_LINUX_TRY_COMPILE([
753 #include <linux/workqueue.h>
754 ],[
755 struct work_struct work __attribute__ ((unused));
756 INIT_WORK(&work, NULL, NULL);
757 ],[
758 AC_MSG_RESULT(yes)
759 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
760 [INIT_WORK wants 3 args])
761 ],[
762 AC_MSG_RESULT(no)
763 ])
764 ])
765
766 dnl #
767 dnl # 2.6.21 API change,
768 dnl # 'register_sysctl_table' use only one argument instead of two
769 dnl #
770 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
771 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
772 SPL_LINUX_TRY_COMPILE([
773 #include <linux/sysctl.h>
774 ],[
775 (void) register_sysctl_table(NULL, 0);
776 ],[
777 AC_MSG_RESULT(yes)
778 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
779 [register_sysctl_table() wants 2 args])
780 ],[
781 AC_MSG_RESULT(no)
782 ])
783 ])
784
785 dnl #
786 dnl # 2.6.23 API change
787 dnl # Old set_shrinker API replaced with register_shrinker
788 dnl #
789 AC_DEFUN([SPL_AC_SET_SHRINKER], [
790 AC_MSG_CHECKING([whether set_shrinker() available])
791 SPL_LINUX_TRY_COMPILE([
792 #include <linux/mm.h>
793 ],[
794 return set_shrinker(DEFAULT_SEEKS, NULL);
795 ],[
796 AC_MSG_RESULT([yes])
797 AC_DEFINE(HAVE_SET_SHRINKER, 1,
798 [set_shrinker() available])
799 ],[
800 AC_MSG_RESULT([no])
801 ])
802 ])
803
804 dnl #
805 dnl # 2.6.35 API change,
806 dnl # Add context to shrinker callback
807 dnl #
808 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
809 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
810 tmp_flags="$EXTRA_KCFLAGS"
811 EXTRA_KCFLAGS="-Werror"
812 SPL_LINUX_TRY_COMPILE([
813 #include <linux/mm.h>
814
815 int shrinker_cb(struct shrinker *, int, unsigned int);
816 ],[
817 struct shrinker cache_shrinker = {
818 .shrink = shrinker_cb,
819 .seeks = DEFAULT_SEEKS,
820 };
821 register_shrinker(&cache_shrinker);
822 ],[
823 AC_MSG_RESULT(yes)
824 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
825 [shrinker callback wants 3 args])
826 ],[
827 AC_MSG_RESULT(no)
828 ])
829 EXTRA_KCFLAGS="$tmp_flags"
830 ])
831
832 dnl #
833 dnl # 2.6.25 API change,
834 dnl # struct path entry added to struct nameidata
835 dnl #
836 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
837 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
838 SPL_LINUX_TRY_COMPILE([
839 #include <linux/namei.h>
840 ],[
841 struct nameidata nd __attribute__ ((unused));
842
843 nd.path.mnt = NULL;
844 nd.path.dentry = NULL;
845 ],[
846 AC_MSG_RESULT(yes)
847 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
848 [struct path used in struct nameidata])
849 ],[
850 AC_MSG_RESULT(no)
851 ])
852 ])
853
854 dnl #
855 dnl # Custom SPL patch may export this system it is not required
856 dnl #
857 AC_DEFUN([SPL_AC_TASK_CURR], [
858 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
859 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
860 [])
861 ])
862
863 dnl #
864 dnl # 2.6.19 API change,
865 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
866 dnl #
867 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
868 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
869 SPL_LINUX_TRY_COMPILE([
870 #include <linux/sysctl.h>
871 ],[
872 #ifndef CTL_UNNUMBERED
873 #error CTL_UNNUMBERED undefined
874 #endif
875 ],[
876 AC_MSG_RESULT(yes)
877 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
878 [unnumbered sysctl support exists])
879 ],[
880 AC_MSG_RESULT(no)
881 ])
882 ])
883
884 dnl #
885 dnl # 2.6.33 API change,
886 dnl # Removed .ctl_name from struct ctl_table.
887 dnl #
888 AC_DEFUN([SPL_AC_CTL_NAME], [
889 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
890 SPL_LINUX_TRY_COMPILE([
891 #include <linux/sysctl.h>
892 ],[
893 struct ctl_table ctl __attribute__ ((unused));
894 ctl.ctl_name = 0;
895 ],[
896 AC_MSG_RESULT(yes)
897 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
898 ],[
899 AC_MSG_RESULT(no)
900 ])
901 ])
902
903 dnl #
904 dnl # 2.6.16 API change.
905 dnl # Check if 'fls64()' is available
906 dnl #
907 AC_DEFUN([SPL_AC_FLS64],
908 [AC_MSG_CHECKING([whether fls64() is available])
909 SPL_LINUX_TRY_COMPILE([
910 #include <linux/bitops.h>
911 ],[
912 return fls64(0);
913 ],[
914 AC_MSG_RESULT(yes)
915 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
916 ],[
917 AC_MSG_RESULT(no)
918 ])
919 ])
920
921 dnl #
922 dnl # 2.6.18 API change, check whether device_create() is available.
923 dnl # Device_create() was introduced in 2.6.18 and depricated
924 dnl # class_device_create() which was fully removed in 2.6.26.
925 dnl #
926 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
927 SPL_CHECK_SYMBOL_EXPORT(
928 [device_create],
929 [drivers/base/core.c],
930 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
931 [device_create() is available])],
932 [])
933 ])
934
935 dnl #
936 dnl # 2.6.27 API change,
937 dnl # device_create() uses 5 args, new 'drvdata' argument.
938 dnl #
939 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
940 AC_MSG_CHECKING([whether device_create() wants 5 args])
941 tmp_flags="$EXTRA_KCFLAGS"
942 EXTRA_KCFLAGS="-Werror"
943 SPL_LINUX_TRY_COMPILE([
944 #include <linux/device.h>
945 ],[
946 device_create(NULL, NULL, 0, NULL, "%d", 1);
947 ],[
948 AC_MSG_RESULT(yes)
949 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
950 [device_create wants 5 args])
951 ],[
952 AC_MSG_RESULT(no)
953 ])
954 EXTRA_KCFLAGS="$tmp_flags"
955 ])
956
957 dnl #
958 dnl # 2.6.13 API change, check whether class_device_create() is available.
959 dnl # Class_device_create() was introduced in 2.6.13 and depricated
960 dnl # class_simple_device_add() which was fully removed in 2.6.13.
961 dnl #
962 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
963 SPL_CHECK_SYMBOL_EXPORT(
964 [class_device_create],
965 [drivers/base/class.c],
966 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
967 [class_device_create() is available])],
968 [])
969 ])
970
971 dnl #
972 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
973 dnl #
974 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
975 SPL_CHECK_SYMBOL_EXPORT(
976 [set_normalized_timespec],
977 [kernel/time.c],
978 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
979 [set_normalized_timespec() is available as export])],
980 [])
981 ])
982
983 dnl #
984 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
985 dnl # previously it was available in time.h as an inline.
986 dnl #
987 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
988 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
989 SPL_LINUX_TRY_COMPILE([
990 #include <linux/time.h>
991 void set_normalized_timespec(struct timespec *ts,
992 time_t sec, long nsec) { }
993 ],
994 [],
995 [
996 AC_MSG_RESULT(no)
997 ],[
998 AC_MSG_RESULT(yes)
999 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1000 [set_normalized_timespec() is available as inline])
1001 ])
1002 ])
1003
1004 dnl #
1005 dnl # 2.6.18 API change,
1006 dnl # timespec_sub() inline function available in linux/time.h
1007 dnl #
1008 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1009 AC_MSG_CHECKING([whether timespec_sub() is available])
1010 SPL_LINUX_TRY_COMPILE([
1011 #include <linux/time.h>
1012 ],[
1013 struct timespec a = { 0 };
1014 struct timespec b = { 0 };
1015 struct timespec c __attribute__ ((unused));
1016 c = timespec_sub(a, b);
1017 ],[
1018 AC_MSG_RESULT(yes)
1019 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1020 ],[
1021 AC_MSG_RESULT(no)
1022 ])
1023 ])
1024
1025 dnl #
1026 dnl # 2.6.19 API change,
1027 dnl # check if init_utsname() is available in linux/utsname.h
1028 dnl #
1029 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1030 AC_MSG_CHECKING([whether init_utsname() is available])
1031 SPL_LINUX_TRY_COMPILE([
1032 #include <linux/utsname.h>
1033 ],[
1034 struct new_utsname *a __attribute__ ((unused));
1035 a = init_utsname();
1036 ],[
1037 AC_MSG_RESULT(yes)
1038 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1039 ],[
1040 AC_MSG_RESULT(no)
1041 ])
1042 ])
1043
1044 dnl #
1045 dnl # 2.6.26 API change,
1046 dnl # definition of struct fdtable relocated to linux/fdtable.h
1047 dnl #
1048 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1049 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1050 ])
1051
1052 dnl #
1053 dnl # 2.6.14 API change,
1054 dnl # check whether 'files_fdtable()' exists
1055 dnl #
1056 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1057 AC_MSG_CHECKING([whether files_fdtable() is available])
1058 SPL_LINUX_TRY_COMPILE([
1059 #include <linux/sched.h>
1060 #include <linux/file.h>
1061 #ifdef HAVE_FDTABLE_HEADER
1062 #include <linux/fdtable.h>
1063 #endif
1064 ],[
1065 struct files_struct *files = current->files;
1066 struct fdtable *fdt __attribute__ ((unused));
1067 fdt = files_fdtable(files);
1068 ],[
1069 AC_MSG_RESULT(yes)
1070 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1071 ],[
1072 AC_MSG_RESULT(no)
1073 ])
1074 ])
1075
1076 dnl #
1077 dnl # 2.6.18 API change,
1078 dnl # added linux/uaccess.h
1079 dnl #
1080 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1081 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1082 ])
1083
1084 dnl #
1085 dnl # 2.6.12 API change,
1086 dnl # check whether 'kmalloc_node()' is available.
1087 dnl #
1088 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1089 AC_MSG_CHECKING([whether kmalloc_node() is available])
1090 SPL_LINUX_TRY_COMPILE([
1091 #include <linux/slab.h>
1092 ],[
1093 void *a __attribute__ ((unused));
1094 a = kmalloc_node(1, GFP_KERNEL, 0);
1095 ],[
1096 AC_MSG_RESULT(yes)
1097 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1098 ],[
1099 AC_MSG_RESULT(no)
1100 ])
1101 ])
1102
1103 dnl #
1104 dnl # 2.6.9 API change,
1105 dnl # check whether 'monotonic_clock()' is available it may
1106 dnl # be available for some archs but not others.
1107 dnl #
1108 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1109 SPL_CHECK_SYMBOL_EXPORT(
1110 [monotonic_clock],
1111 [],
1112 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1113 [monotonic_clock() is available])],
1114 [])
1115 ])
1116
1117 dnl #
1118 dnl # 2.6.16 API change,
1119 dnl # check whether 'struct inode' has i_mutex
1120 dnl #
1121 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1122 AC_MSG_CHECKING([whether struct inode has i_mutex])
1123 SPL_LINUX_TRY_COMPILE([
1124 #include <linux/fs.h>
1125 #include <linux/mutex.h>
1126 ],[
1127 struct inode i;
1128 mutex_init(&i.i_mutex);
1129 ],[
1130 AC_MSG_RESULT(yes)
1131 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1132 ],[
1133 AC_MSG_RESULT(no)
1134 ])
1135 ])
1136
1137 dnl #
1138 dnl # 2.6.29 API change,
1139 dnl # Adaptive mutexs introduced.
1140 dnl #
1141 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1142 AC_MSG_CHECKING([whether struct mutex has owner])
1143 SPL_LINUX_TRY_COMPILE([
1144 #include <linux/mutex.h>
1145 ],[
1146 struct mutex mtx __attribute__ ((unused));
1147 mtx.owner = NULL;
1148 ],[
1149 AC_MSG_RESULT(yes)
1150 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1151 ],[
1152 AC_MSG_RESULT(no)
1153 ])
1154 ])
1155
1156 dnl #
1157 dnl # 2.6.39 API change,
1158 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1159 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1160 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1161 dnl # pointer which frankly makes a lot more sense.
1162 dnl #
1163 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1164 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1165 tmp_flags="$EXTRA_KCFLAGS"
1166 EXTRA_KCFLAGS="-Werror"
1167 SPL_LINUX_TRY_COMPILE([
1168 #include <linux/mutex.h>
1169 ],[
1170 struct mutex mtx __attribute__ ((unused));
1171 mtx.owner = current;
1172 ],[
1173 AC_MSG_RESULT(yes)
1174 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1175 [struct mutex owner is a task_struct])
1176 ],[
1177 AC_MSG_RESULT(no)
1178 ])
1179 EXTRA_KCFLAGS="$tmp_flags"
1180 ])
1181
1182 dnl #
1183 dnl # 2.6.18 API change,
1184 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1185 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1186 dnl # if the mutex validator is disabled or otherwise unavailable.
1187 dnl #
1188 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1189 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1190 SPL_LINUX_TRY_COMPILE([
1191 #include <linux/mutex.h>
1192 ],[
1193 struct mutex mutex;
1194 mutex_init(&mutex);
1195 mutex_lock_nested(&mutex, 0);
1196 ],[
1197 AC_MSG_RESULT(yes)
1198 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1199 [mutex_lock_nested() is available])
1200 ],[
1201 AC_MSG_RESULT(no)
1202 ])
1203 ])
1204
1205 dnl #
1206 dnl # 2.6.27 API change,
1207 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1208 dnl #
1209 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1210 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1211 SPL_LINUX_TRY_COMPILE([
1212 #include <linux/smp.h>
1213 ],[
1214 on_each_cpu(NULL, NULL, 0);
1215 ],[
1216 AC_MSG_RESULT(yes)
1217 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1218 [on_each_cpu wants 3 args])
1219 ],[
1220 AC_MSG_RESULT(no)
1221 ])
1222 ])
1223
1224 dnl #
1225 dnl # 2.6.18 API change,
1226 dnl # kallsyms_lookup_name no longer exported
1227 dnl #
1228 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1229 SPL_CHECK_SYMBOL_EXPORT(
1230 [kallsyms_lookup_name],
1231 [],
1232 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1233 [kallsyms_lookup_name() is available])],
1234 [])
1235 ])
1236
1237 dnl #
1238 dnl # Proposed API change,
1239 dnl # This symbol is not available in stock kernels. You may build a
1240 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1241 dnl # these symbols for use. If your already rolling a custom kernel for
1242 dnl # your environment this is recommended.
1243 dnl #
1244 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1245 SPL_CHECK_SYMBOL_EXPORT(
1246 [get_vmalloc_info],
1247 [],
1248 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1249 [get_vmalloc_info() is available])],
1250 [])
1251 ])
1252
1253 dnl #
1254 dnl # 2.6.17 API change
1255 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1256 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1257 dnl # were exported in 2.6.17 for use by modules which was consistent with
1258 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1259 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1260 dnl # were dropped entirely leaving modules no way to directly iterate over
1261 dnl # the zone list. Because we need access to the zone helpers we check
1262 dnl # if the kernel contains the old or new implementation. Then we check
1263 dnl # to see if the symbols we need for each version are available. If they
1264 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1265 dnl #
1266 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1267 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1268 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1269 rc=$?
1270 if test $rc -eq 0; then
1271 AC_MSG_RESULT([yes])
1272 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1273 else
1274 AC_MSG_RESULT([no])
1275 fi
1276 ])
1277
1278 dnl #
1279 dnl # Proposed API change,
1280 dnl # This symbol is not available in stock kernels. You may build a
1281 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1282 dnl # these symbols for use. If your already rolling a custom kernel for
1283 dnl # your environment this is recommended.
1284 dnl #
1285 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1286 SPL_CHECK_SYMBOL_EXPORT(
1287 [first_online_pgdat],
1288 [],
1289 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1290 [first_online_pgdat() is available])],
1291 [])
1292 ])
1293
1294 dnl #
1295 dnl # Proposed API change,
1296 dnl # This symbol is not available in stock kernels. You may build a
1297 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1298 dnl # these symbols for use. If your already rolling a custom kernel for
1299 dnl # your environment this is recommended.
1300 dnl #
1301 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1302 SPL_CHECK_SYMBOL_EXPORT(
1303 [next_online_pgdat],
1304 [],
1305 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1306 [next_online_pgdat() is available])],
1307 [])
1308 ])
1309
1310 dnl #
1311 dnl # Proposed API change,
1312 dnl # This symbol is not available in stock kernels. You may build a
1313 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1314 dnl # these symbols for use. If your already rolling a custom kernel for
1315 dnl # your environment this is recommended.
1316 dnl #
1317 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1318 SPL_CHECK_SYMBOL_EXPORT(
1319 [next_zone],
1320 [],
1321 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1322 [next_zone() is available])],
1323 [])
1324 ])
1325
1326 dnl #
1327 dnl # 2.6.17 API change,
1328 dnl # See SPL_AC_PGDAT_HELPERS for details.
1329 dnl #
1330 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1331 SPL_CHECK_SYMBOL_EXPORT(
1332 [pgdat_list],
1333 [],
1334 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1335 [pgdat_list is available])],
1336 [])
1337 ])
1338
1339 dnl #
1340 dnl # 2.6.18 API change,
1341 dnl # First introduced global_page_state() support as an inline.
1342 dnl #
1343 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1344 AC_MSG_CHECKING([whether global_page_state() is available])
1345 SPL_LINUX_TRY_COMPILE([
1346 #include <linux/mm.h>
1347 ],[
1348 unsigned long state __attribute__ ((unused));
1349 state = global_page_state(0);
1350 ],[
1351 AC_MSG_RESULT(yes)
1352 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1353 [global_page_state() is available])
1354 ],[
1355 AC_MSG_RESULT(no)
1356 ])
1357 ])
1358
1359 dnl #
1360 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1361 dnl # Public global zone stats now include a free page count. However
1362 dnl # the enumerated names of the counters have changed since this API
1363 dnl # was introduced. We need to deduce the corrent name to use. This
1364 dnl # replaces the priviate get_zone_counts() interface.
1365 dnl #
1366 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1367 dnl # is 2.6.30 as of when this was written.
1368 dnl #
1369 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1370 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1371 SPL_LINUX_TRY_COMPILE([
1372 #include <linux/mm.h>
1373 ],[
1374 enum zone_stat_item zsi __attribute__ ((unused));
1375 zsi = NR_FREE_PAGES;
1376 ],[
1377 AC_MSG_RESULT(yes)
1378 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1379 [Page state NR_FREE_PAGES is available])
1380 ],[
1381 AC_MSG_RESULT(no)
1382 ])
1383 ])
1384
1385 dnl #
1386 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1387 dnl # Public global zone stats now include an inactive page count. However
1388 dnl # the enumerated names of the counters have changed since this API
1389 dnl # was introduced. We need to deduce the corrent name to use. This
1390 dnl # replaces the priviate get_zone_counts() interface.
1391 dnl #
1392 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1393 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1394 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1395 dnl #
1396 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1397 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1398 SPL_LINUX_TRY_COMPILE([
1399 #include <linux/mm.h>
1400 ],[
1401 enum zone_stat_item zsi __attribute__ ((unused));
1402 zsi = NR_INACTIVE;
1403 ],[
1404 AC_MSG_RESULT(yes)
1405 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1406 [Page state NR_INACTIVE is available])
1407 ],[
1408 AC_MSG_RESULT(no)
1409 ])
1410
1411 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1412 SPL_LINUX_TRY_COMPILE([
1413 #include <linux/mm.h>
1414 ],[
1415 enum zone_stat_item zsi __attribute__ ((unused));
1416 zsi = NR_INACTIVE_ANON;
1417 ],[
1418 AC_MSG_RESULT(yes)
1419 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1420 [Page state NR_INACTIVE_ANON is available])
1421 ],[
1422 AC_MSG_RESULT(no)
1423 ])
1424
1425 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1426 SPL_LINUX_TRY_COMPILE([
1427 #include <linux/mm.h>
1428 ],[
1429 enum zone_stat_item zsi __attribute__ ((unused));
1430 zsi = NR_INACTIVE_FILE;
1431 ],[
1432 AC_MSG_RESULT(yes)
1433 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1434 [Page state NR_INACTIVE_FILE is available])
1435 ],[
1436 AC_MSG_RESULT(no)
1437 ])
1438 ])
1439
1440 dnl #
1441 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1442 dnl # Public global zone stats now include an active page count. However
1443 dnl # the enumerated names of the counters have changed since this API
1444 dnl # was introduced. We need to deduce the corrent name to use. This
1445 dnl # replaces the priviate get_zone_counts() interface.
1446 dnl #
1447 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1448 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1449 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1450 dnl #
1451 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1452 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1453 SPL_LINUX_TRY_COMPILE([
1454 #include <linux/mm.h>
1455 ],[
1456 enum zone_stat_item zsi __attribute__ ((unused));
1457 zsi = NR_ACTIVE;
1458 ],[
1459 AC_MSG_RESULT(yes)
1460 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1461 [Page state NR_ACTIVE is available])
1462 ],[
1463 AC_MSG_RESULT(no)
1464 ])
1465
1466 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1467 SPL_LINUX_TRY_COMPILE([
1468 #include <linux/mm.h>
1469 ],[
1470 enum zone_stat_item zsi __attribute__ ((unused));
1471 zsi = NR_ACTIVE_ANON;
1472 ],[
1473 AC_MSG_RESULT(yes)
1474 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1475 [Page state NR_ACTIVE_ANON is available])
1476 ],[
1477 AC_MSG_RESULT(no)
1478 ])
1479
1480 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1481 SPL_LINUX_TRY_COMPILE([
1482 #include <linux/mm.h>
1483 ],[
1484 enum zone_stat_item zsi __attribute__ ((unused));
1485 zsi = NR_ACTIVE_FILE;
1486 ],[
1487 AC_MSG_RESULT(yes)
1488 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1489 [Page state NR_ACTIVE_FILE is available])
1490 ],[
1491 AC_MSG_RESULT(no)
1492 ])
1493 ])
1494
1495 dnl #
1496 dnl # Proposed API change for legacy kernels.
1497 dnl # This symbol is not available in older kernels. For kernels post
1498 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1499 dnl # page state information. This symbol is only used in legacy kernels
1500 dnl # any only as a last resort.
1501 dnl
1502 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1503 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1504 SPL_LINUX_TRY_COMPILE([
1505 ],[
1506 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1507 #error "global_page_state needs NR_FREE_PAGES"
1508 #endif
1509
1510 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1511 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1512 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1513 #error "global_page_state needs NR_ACTIVE*"
1514 #endif
1515
1516 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1517 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1518 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1519 #error "global_page_state needs NR_INACTIVE*"
1520 #endif
1521 ],[
1522 AC_MSG_RESULT(no)
1523 ],[
1524 AC_MSG_RESULT(yes)
1525 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1526 [get_zone_counts() is needed])
1527
1528 SPL_CHECK_SYMBOL_EXPORT(
1529 [get_zone_counts],
1530 [],
1531 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1532 [get_zone_counts() is available])],
1533 [])
1534 ])
1535 ])
1536
1537 dnl #
1538 dnl # 2.6.27 API change,
1539 dnl # The user_path_dir() replaces __user_walk()
1540 dnl #
1541 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1542 SPL_CHECK_SYMBOL_EXPORT(
1543 [user_path_at],
1544 [],
1545 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1546 [user_path_dir() is available])],
1547 [])
1548 ])
1549
1550 dnl #
1551 dnl # Symbol available in RHEL kernels not in stock kernels.
1552 dnl #
1553 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1554 SPL_CHECK_SYMBOL_EXPORT(
1555 [set_fs_pwd],
1556 [],
1557 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1558 [set_fs_pwd() is available])],
1559 [])
1560 ])
1561
1562 dnl #
1563 dnl # 2.6.25 API change,
1564 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1565 dnl #
1566 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1567 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1568 SPL_LINUX_TRY_COMPILE([
1569 #include <linux/sched.h>
1570 #include <linux/fs_struct.h>
1571 ],[
1572 set_fs_pwd(NULL, NULL);
1573 ],[
1574 AC_MSG_RESULT(yes)
1575 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1576 [set_fs_pwd() wants 2 args])
1577 ],[
1578 AC_MSG_RESULT(no)
1579 ])
1580 ])
1581
1582 dnl #
1583 dnl # SLES API change, never adopted in mainline,
1584 dnl # Third 'struct vfsmount *' argument removed.
1585 dnl #
1586 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1587 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1588 SPL_LINUX_TRY_COMPILE([
1589 #include <linux/fs.h>
1590 ],[
1591 vfs_unlink(NULL, NULL);
1592 ],[
1593 AC_MSG_RESULT(yes)
1594 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1595 [vfs_unlink() wants 2 args])
1596 ],[
1597 AC_MSG_RESULT(no)
1598 ])
1599 ])
1600
1601 dnl #
1602 dnl # SLES API change, never adopted in mainline,
1603 dnl # Third and sixth 'struct vfsmount *' argument removed.
1604 dnl #
1605 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1606 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1607 SPL_LINUX_TRY_COMPILE([
1608 #include <linux/fs.h>
1609 ],[
1610 vfs_rename(NULL, NULL, NULL, NULL);
1611 ],[
1612 AC_MSG_RESULT(yes)
1613 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1614 [vfs_rename() wants 4 args])
1615 ],[
1616 AC_MSG_RESULT(no)
1617 ])
1618 ])
1619
1620 dnl #
1621 dnl # 2.6.36 API change,
1622 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1623 dnl # a spinlock_t to improve the fastpath performance.
1624 dnl #
1625 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1626 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1627 tmp_flags="$EXTRA_KCFLAGS"
1628 EXTRA_KCFLAGS="-Werror"
1629 SPL_LINUX_TRY_COMPILE([
1630 #include <linux/sched.h>
1631 #include <linux/fs_struct.h>
1632 ],[
1633 struct fs_struct fs;
1634 spin_lock_init(&fs.lock);
1635 ],[
1636 AC_MSG_RESULT(yes)
1637 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1638 [struct fs_struct uses spinlock_t])
1639 ],[
1640 AC_MSG_RESULT(no)
1641 ])
1642 EXTRA_KCFLAGS="$tmp_flags"
1643 ])
1644
1645 dnl #
1646 dnl # 2.6.29 API change,
1647 dnl # check whether 'struct cred' exists
1648 dnl #
1649 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1650 AC_MSG_CHECKING([whether struct cred exists])
1651 SPL_LINUX_TRY_COMPILE([
1652 #include <linux/cred.h>
1653 ],[
1654 struct cred *cr __attribute__ ((unused));
1655 cr = NULL;
1656 ],[
1657 AC_MSG_RESULT(yes)
1658 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1659 ],[
1660 AC_MSG_RESULT(no)
1661 ])
1662 ])
1663
1664 dnl #
1665 dnl # Custom SPL patch may export this symbol.
1666 dnl #
1667 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1668 SPL_CHECK_SYMBOL_EXPORT(
1669 [groups_search],
1670 [],
1671 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1672 [groups_search() is available])],
1673 [])
1674 ])
1675
1676 dnl #
1677 dnl # 2.6.x API change,
1678 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1679 dnl #
1680 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1681 SPL_CHECK_SYMBOL_EXPORT(
1682 [__put_task_struct],
1683 [],
1684 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1685 [__put_task_struct() is available])],
1686 [])
1687 ])
1688
1689 dnl #
1690 dnl # 2.6.32 API change,
1691 dnl # Unused 'struct file *' removed from prototype.
1692 dnl #
1693 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1694 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1695 SPL_LINUX_TRY_COMPILE([
1696 #include <linux/sysctl.h>
1697 ],[
1698 proc_dostring(NULL, 0, NULL, NULL, NULL);
1699 ],[
1700 AC_MSG_RESULT(yes)
1701 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1702 [proc_handler() wants 5 args])
1703 ],[
1704 AC_MSG_RESULT(no)
1705 ])
1706 ])
1707
1708 dnl #
1709 dnl # 2.6.x API change,
1710 dnl # kvasprintf() function added.
1711 dnl #
1712 AC_DEFUN([SPL_AC_KVASPRINTF], [
1713 SPL_CHECK_SYMBOL_EXPORT(
1714 [kvasprintf],
1715 [],
1716 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1717 [kvasprintf() is available])],
1718 [])
1719 ])
1720
1721 dnl #
1722 dnl # 2.6.29 API change,
1723 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1724 dnl #
1725 AC_DEFUN([SPL_AC_VFS_FSYNC], [
1726 SPL_CHECK_SYMBOL_EXPORT(
1727 [vfs_fsync],
1728 [fs/sync.c],
1729 [AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])],
1730 [])
1731 ])
1732
1733 dnl #
1734 dnl # 2.6.35 API change,
1735 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1736 dnl #
1737 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1738 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1739 SPL_LINUX_TRY_COMPILE([
1740 #include <linux/fs.h>
1741 ],[
1742 vfs_fsync(NULL, 0);
1743 ],[
1744 AC_MSG_RESULT(yes)
1745 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1746 ],[
1747 AC_MSG_RESULT(no)
1748 ])
1749 ])
1750
1751 dnl #
1752 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1753 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1754 dnl # condition. The fixed version is exported as a symbol. The race
1755 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1756 dnl # call that version while holding sem->wait_lock.
1757 dnl #
1758 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1759 SPL_CHECK_SYMBOL_EXPORT(
1760 [rwsem_is_locked],
1761 [lib/rwsem-spinlock.c],
1762 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1763 [rwsem_is_locked() acquires sem->wait_lock])],
1764 [])
1765 ])
1766
1767 dnl #
1768 dnl # 2.6.37 API compat,
1769 dnl # The function invalidate_inodes() is no longer exported by the kernel.
1770 dnl # The prototype however is still available which means it is safe
1771 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
1772 dnl #
1773 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
1774 SPL_CHECK_SYMBOL_EXPORT(
1775 [invalidate_inodes],
1776 [],
1777 [AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
1778 [invalidate_inodes() is available])],
1779 [])
1780 ])
1781
1782 dnl #
1783 dnl # 2.6.39 API compat,
1784 dnl # The function invalidate_inodes() now take 2 arguments. The second
1785 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
1786 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
1787 dnl # otherwise they will be handled as busy.
1788 dnl #
1789 dnl # Unfortunately, we don't have access to the invalidate_inodes()
1790 dnl # prototype so it's not easy to check how many arguments it takes.
1791 dnl # However, this change was done for the benefit of invalidate_device()
1792 dnl # which also added an argument. The invalidate_device() symbol does
1793 dnl # exist in the development headers so if it takes two arguments we
1794 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
1795 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
1796 dnl #
1797 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
1798 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
1799 SPL_LINUX_TRY_COMPILE([
1800 #include <linux/fs.h>
1801 ],[
1802 return __invalidate_device(NULL, 0);
1803 ],[
1804 AC_MSG_RESULT(yes)
1805 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
1806 [invalidate_inodes() wants 2 args])
1807 ],[
1808 AC_MSG_RESULT(no)
1809 ])
1810 ])
1811
1812 dnl #
1813 dnl # 2.6.xx API compat,
1814 dnl # There currently exists no exposed API to partially shrink the dcache.
1815 dnl # The expected mechanism to shrink the cache is a registered shrinker
1816 dnl # which is called during memory pressure.
1817 dnl #
1818 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [
1819 SPL_CHECK_SYMBOL_EXPORT(
1820 [shrink_dcache_memory],
1821 [fs/dcache.c],
1822 [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1823 [shrink_dcache_memory() is available])],
1824 [])
1825 ])
1826
1827 dnl #
1828 dnl # 2.6.xx API compat,
1829 dnl # There currently exists no exposed API to partially shrink the icache.
1830 dnl # The expected mechanism to shrink the cache is a registered shrinker
1831 dnl # which is called during memory pressure.
1832 dnl #
1833 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [
1834 SPL_CHECK_SYMBOL_EXPORT(
1835 [shrink_icache_memory],
1836 [fs/inode.c],
1837 [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1838 [shrink_icache_memory() is available])],
1839 [])
1840 ])
1841
1842 dnl #
1843 dnl # 2.6.39 API compat,
1844 dnl # The path_lookup() function has been renamed to kern_path_parent()
1845 dnl # and the flags argument has been removed. The only behavior now
1846 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
1847 dnl # this flag so dropping the flag does not impact us.
1848 dnl #
1849 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
1850 SPL_CHECK_SYMBOL_HEADER(
1851 [kern_path_parent],
1852 [int kern_path_parent(const char \*, struct nameidata \*)],
1853 [include/linux/namei.h],
1854 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
1855 [kern_path_parent() is available])],
1856 [])
1857 ])
1858
1859 dnl #
1860 dnl # 3.1 API compat,
1861 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
1862 dnl # However, it remains the prefered interface and since we still have
1863 dnl # access to the prototype we dynamically lookup the required address.
1864 dnl #
1865 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL], [
1866 SPL_CHECK_SYMBOL_EXPORT(
1867 [kern_path_parent],
1868 [fs/namei.c],
1869 [AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
1870 [kern_path_parent() is available])],
1871 [])
1872 ])
1873
1874 dnl #
1875 dnl # 2.6.39 API compat,
1876 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1877 dnl # This was done to avoid always having to allocate the maximum size
1878 dnl # workspace (268K). The caller can now specific the windowBits and
1879 dnl # memLevel compression parameters to get a smaller workspace.
1880 dnl #
1881 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1882 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1883 SPL_LINUX_TRY_COMPILE([
1884 #include <linux/zlib.h>
1885 ],[
1886 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1887 ],[
1888 AC_MSG_RESULT(yes)
1889 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1890 [zlib_deflate_workspacesize() wants 2 args])
1891 ],[
1892 AC_MSG_RESULT(no)
1893 ])
1894 ])
1895
1896 dnl #
1897 dnl # 2.6.39 API change,
1898 dnl # Shrinker adjust to use common shrink_control structure.
1899 dnl #
1900 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1901 AC_MSG_CHECKING([whether struct shrink_control exists])
1902 SPL_LINUX_TRY_COMPILE([
1903 #include <linux/mm.h>
1904 ],[
1905 struct shrink_control sc __attribute__ ((unused));
1906
1907 sc.nr_to_scan = 0;
1908 sc.gfp_mask = GFP_KERNEL;
1909 ],[
1910 AC_MSG_RESULT(yes)
1911 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1912 [struct shrink_control exists])
1913 ],[
1914 AC_MSG_RESULT(no)
1915 ])
1916 ])