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