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