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