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