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