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