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