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