]>
Commit | Line | Data |
---|---|---|
87d546d8 TG |
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_KMEM | |
22 | SPL_AC_DEBUG_KMEM_TRACKING | |
23 | SPL_AC_TEST_MODULE | |
24 | SPL_AC_ATOMIC_SPINLOCK | |
25 | SPL_AC_SHRINKER_CALLBACK | |
26 | SPL_AC_CTL_NAME | |
27 | SPL_AC_CONFIG_TRIM_UNUSED_KSYMS | |
28 | SPL_AC_PDE_DATA | |
29 | SPL_AC_SET_FS_PWD_WITH_CONST | |
30 | SPL_AC_2ARGS_VFS_UNLINK | |
31 | SPL_AC_4ARGS_VFS_RENAME | |
32 | SPL_AC_2ARGS_VFS_FSYNC | |
33 | SPL_AC_INODE_TRUNCATE_RANGE | |
34 | SPL_AC_FS_STRUCT_SPINLOCK | |
35 | SPL_AC_KUIDGID_T | |
87d546d8 TG |
36 | SPL_AC_KERNEL_FALLOCATE |
37 | SPL_AC_CONFIG_ZLIB_INFLATE | |
38 | SPL_AC_CONFIG_ZLIB_DEFLATE | |
39 | SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE | |
40 | SPL_AC_SHRINK_CONTROL_STRUCT | |
41 | SPL_AC_RWSEM_SPINLOCK_IS_RAW | |
42 | SPL_AC_RWSEM_ACTIVITY | |
43 | SPL_AC_RWSEM_ATOMIC_LONG_COUNT | |
44 | SPL_AC_SCHED_RT_HEADER | |
3e990ae0 CIK |
45 | SPL_AC_SCHED_SIGNAL_HEADER |
46 | SPL_AC_4ARGS_VFS_GETATTR | |
47 | SPL_AC_3ARGS_VFS_GETATTR | |
87d546d8 TG |
48 | SPL_AC_2ARGS_VFS_GETATTR |
49 | SPL_AC_USLEEP_RANGE | |
50 | SPL_AC_KMEM_CACHE_ALLOCFLAGS | |
51 | SPL_AC_WAIT_ON_BIT | |
52 | SPL_AC_INODE_LOCK | |
53 | SPL_AC_MUTEX_OWNER | |
54 | SPL_AC_GROUP_INFO_GID | |
55 | ]) | |
56 | ||
57 | AC_DEFUN([SPL_AC_MODULE_SYMVERS], [ | |
58 | modpost=$LINUX/scripts/Makefile.modpost | |
59 | AC_MSG_CHECKING([kernel file name for module symbols]) | |
60 | if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then | |
61 | if grep -q Modules.symvers $modpost; then | |
62 | LINUX_SYMBOLS=Modules.symvers | |
63 | else | |
64 | LINUX_SYMBOLS=Module.symvers | |
65 | fi | |
66 | ||
67 | if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then | |
68 | AC_MSG_ERROR([ | |
69 | *** Please make sure the kernel devel package for your distribution | |
70 | *** is installed. If you are building with a custom kernel, make sure the | |
71 | *** kernel is configured, built, and the '--with-linux=PATH' configure | |
72 | *** option refers to the location of the kernel source.]) | |
73 | fi | |
74 | else | |
75 | LINUX_SYMBOLS=NONE | |
76 | fi | |
77 | AC_MSG_RESULT($LINUX_SYMBOLS) | |
78 | AC_SUBST(LINUX_SYMBOLS) | |
79 | ]) | |
80 | ||
81 | AC_DEFUN([SPL_AC_KERNEL], [ | |
82 | AC_ARG_WITH([linux], | |
83 | AS_HELP_STRING([--with-linux=PATH], | |
84 | [Path to kernel source]), | |
85 | [kernelsrc="$withval"]) | |
86 | ||
87 | AC_ARG_WITH([linux-obj], | |
88 | AS_HELP_STRING([--with-linux-obj=PATH], | |
89 | [Path to kernel build objects]), | |
90 | [kernelbuild="$withval"]) | |
91 | ||
92 | AC_MSG_CHECKING([kernel source directory]) | |
93 | if test -z "$kernelsrc"; then | |
94 | if test -e "/lib/modules/$(uname -r)/source"; then | |
95 | headersdir="/lib/modules/$(uname -r)/source" | |
96 | sourcelink=$(readlink -f "$headersdir") | |
97 | elif test -e "/lib/modules/$(uname -r)/build"; then | |
98 | headersdir="/lib/modules/$(uname -r)/build" | |
99 | sourcelink=$(readlink -f "$headersdir") | |
100 | else | |
101 | sourcelink=$(ls -1d /usr/src/kernels/* \ | |
102 | /usr/src/linux-* \ | |
103 | 2>/dev/null | grep -v obj | tail -1) | |
104 | fi | |
105 | ||
106 | if test -n "$sourcelink" && test -e ${sourcelink}; then | |
107 | kernelsrc=`readlink -f ${sourcelink}` | |
108 | else | |
109 | kernelsrc="[Not found]" | |
110 | fi | |
111 | else | |
112 | if test "$kernelsrc" = "NONE"; then | |
113 | kernsrcver=NONE | |
114 | fi | |
115 | fi | |
116 | ||
117 | AC_MSG_RESULT([$kernelsrc]) | |
118 | if test ! -d "$kernelsrc"; then | |
119 | AC_MSG_ERROR([ | |
120 | *** Please make sure the kernel devel package for your distribution | |
121 | *** is installed and then try again. If that fails, you can specify the | |
122 | *** location of the kernel source with the '--with-linux=PATH' option.]) | |
123 | fi | |
124 | ||
125 | AC_MSG_CHECKING([kernel build directory]) | |
126 | if test -z "$kernelbuild"; then | |
127 | if test -e "/lib/modules/$(uname -r)/build"; then | |
128 | kernelbuild=`readlink -f /lib/modules/$(uname -r)/build` | |
129 | elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then | |
130 | kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu} | |
131 | elif test -d ${kernelsrc}-obj/${target_cpu}/default; then | |
132 | kernelbuild=${kernelsrc}-obj/${target_cpu}/default | |
133 | elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then | |
134 | kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu} | |
135 | else | |
136 | kernelbuild=${kernelsrc} | |
137 | fi | |
138 | fi | |
139 | AC_MSG_RESULT([$kernelbuild]) | |
140 | ||
141 | AC_MSG_CHECKING([kernel source version]) | |
142 | utsrelease1=$kernelbuild/include/linux/version.h | |
143 | utsrelease2=$kernelbuild/include/linux/utsrelease.h | |
144 | utsrelease3=$kernelbuild/include/generated/utsrelease.h | |
145 | if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then | |
146 | utsrelease=linux/version.h | |
147 | elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then | |
148 | utsrelease=linux/utsrelease.h | |
149 | elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then | |
150 | utsrelease=generated/utsrelease.h | |
151 | fi | |
152 | ||
153 | if test "$utsrelease"; then | |
154 | kernsrcver=`(echo "#include <$utsrelease>"; | |
155 | echo "kernsrcver=UTS_RELEASE") | | |
156 | cpp -I $kernelbuild/include | | |
157 | grep "^kernsrcver=" | cut -d \" -f 2` | |
158 | ||
159 | if test -z "$kernsrcver"; then | |
160 | AC_MSG_RESULT([Not found]) | |
161 | AC_MSG_ERROR([*** Cannot determine kernel version.]) | |
162 | fi | |
163 | else | |
164 | AC_MSG_RESULT([Not found]) | |
165 | if test "x$enable_linux_builtin" != xyes; then | |
166 | AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.]) | |
167 | else | |
168 | AC_MSG_ERROR([ | |
169 | *** Cannot find UTS_RELEASE definition. | |
170 | *** Please run 'make prepare' inside the kernel source tree.]) | |
171 | fi | |
172 | fi | |
173 | ||
174 | AC_MSG_RESULT([$kernsrcver]) | |
175 | ||
176 | LINUX=${kernelsrc} | |
177 | LINUX_OBJ=${kernelbuild} | |
178 | LINUX_VERSION=${kernsrcver} | |
179 | ||
180 | AC_SUBST(LINUX) | |
181 | AC_SUBST(LINUX_OBJ) | |
182 | AC_SUBST(LINUX_VERSION) | |
183 | ||
184 | SPL_AC_MODULE_SYMVERS | |
185 | ]) | |
186 | ||
187 | dnl # | |
188 | dnl # Default SPL user configuration | |
189 | dnl # | |
190 | AC_DEFUN([SPL_AC_CONFIG_USER], []) | |
191 | ||
192 | dnl # | |
193 | dnl # Check for rpm+rpmbuild to build RPM packages. If these tools | |
194 | dnl # are missing, it is non-fatal, but you will not be able to build | |
195 | dnl # RPM packages and will be warned if you try too. | |
196 | dnl # | |
197 | dnl # By default, the generic spec file will be used because it requires | |
198 | dnl # minimal dependencies. Distribution specific spec files can be | |
199 | dnl # placed under the 'rpm/<distribution>' directory and enabled using | |
200 | dnl # the --with-spec=<distribution> configure option. | |
201 | dnl # | |
202 | AC_DEFUN([SPL_AC_RPM], [ | |
203 | RPM=rpm | |
204 | RPMBUILD=rpmbuild | |
205 | ||
206 | AC_MSG_CHECKING([whether $RPM is available]) | |
207 | AS_IF([tmp=$($RPM --version 2>/dev/null)], [ | |
208 | RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }') | |
209 | HAVE_RPM=yes | |
210 | AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)]) | |
211 | ],[ | |
212 | HAVE_RPM=no | |
213 | AC_MSG_RESULT([$HAVE_RPM]) | |
214 | ]) | |
215 | ||
216 | AC_MSG_CHECKING([whether $RPMBUILD is available]) | |
217 | AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [ | |
218 | RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }') | |
219 | HAVE_RPMBUILD=yes | |
220 | AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)]) | |
221 | ],[ | |
222 | HAVE_RPMBUILD=no | |
223 | AC_MSG_RESULT([$HAVE_RPMBUILD]) | |
224 | ]) | |
225 | ||
226 | RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"' | |
227 | RPM_DEFINE_UTIL= | |
228 | RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"' | |
229 | RPM_DEFINE_DKMS= | |
230 | ||
231 | SRPM_DEFINE_COMMON='--define "build_src_rpm 1"' | |
232 | SRPM_DEFINE_UTIL= | |
233 | SRPM_DEFINE_KMOD= | |
234 | SRPM_DEFINE_DKMS= | |
235 | ||
236 | RPM_SPEC_DIR="rpm/generic" | |
237 | AC_ARG_WITH([spec], | |
238 | AS_HELP_STRING([--with-spec=SPEC], | |
239 | [Spec files 'generic|redhat']), | |
240 | [RPM_SPEC_DIR="rpm/$withval"]) | |
241 | ||
242 | AC_MSG_CHECKING([whether spec files are available]) | |
243 | AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)]) | |
244 | ||
245 | AC_SUBST(HAVE_RPM) | |
246 | AC_SUBST(RPM) | |
247 | AC_SUBST(RPM_VERSION) | |
248 | ||
249 | AC_SUBST(HAVE_RPMBUILD) | |
250 | AC_SUBST(RPMBUILD) | |
251 | AC_SUBST(RPMBUILD_VERSION) | |
252 | ||
253 | AC_SUBST(RPM_SPEC_DIR) | |
254 | AC_SUBST(RPM_DEFINE_UTIL) | |
255 | AC_SUBST(RPM_DEFINE_KMOD) | |
256 | AC_SUBST(RPM_DEFINE_DKMS) | |
257 | AC_SUBST(RPM_DEFINE_COMMON) | |
258 | AC_SUBST(SRPM_DEFINE_UTIL) | |
259 | AC_SUBST(SRPM_DEFINE_KMOD) | |
260 | AC_SUBST(SRPM_DEFINE_DKMS) | |
261 | AC_SUBST(SRPM_DEFINE_COMMON) | |
262 | ]) | |
263 | ||
264 | dnl # | |
265 | dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these | |
266 | dnl # tools are missing it is non-fatal but you will not be able to build | |
267 | dnl # DEB packages and will be warned if you try too. | |
268 | dnl # | |
269 | AC_DEFUN([SPL_AC_DPKG], [ | |
270 | DPKG=dpkg | |
271 | DPKGBUILD=dpkg-buildpackage | |
272 | ||
273 | AC_MSG_CHECKING([whether $DPKG is available]) | |
274 | AS_IF([tmp=$($DPKG --version 2>/dev/null)], [ | |
275 | DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }') | |
276 | HAVE_DPKG=yes | |
277 | AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)]) | |
278 | ],[ | |
279 | HAVE_DPKG=no | |
280 | AC_MSG_RESULT([$HAVE_DPKG]) | |
281 | ]) | |
282 | ||
283 | AC_MSG_CHECKING([whether $DPKGBUILD is available]) | |
284 | AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [ | |
285 | DPKGBUILD_VERSION=$(echo $tmp | \ | |
286 | $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.') | |
287 | HAVE_DPKGBUILD=yes | |
288 | AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)]) | |
289 | ],[ | |
290 | HAVE_DPKGBUILD=no | |
291 | AC_MSG_RESULT([$HAVE_DPKGBUILD]) | |
292 | ]) | |
293 | ||
294 | AC_SUBST(HAVE_DPKG) | |
295 | AC_SUBST(DPKG) | |
296 | AC_SUBST(DPKG_VERSION) | |
297 | ||
298 | AC_SUBST(HAVE_DPKGBUILD) | |
299 | AC_SUBST(DPKGBUILD) | |
300 | AC_SUBST(DPKGBUILD_VERSION) | |
301 | ]) | |
302 | ||
303 | dnl # | |
304 | dnl # Until native packaging for various different packing systems | |
305 | dnl # can be added the least we can do is attempt to use alien to | |
306 | dnl # convert the RPM packages to the needed package type. This is | |
307 | dnl # a hack but so far it has worked reasonable well. | |
308 | dnl # | |
309 | AC_DEFUN([SPL_AC_ALIEN], [ | |
310 | ALIEN=alien | |
311 | ||
312 | AC_MSG_CHECKING([whether $ALIEN is available]) | |
313 | AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [ | |
314 | ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }') | |
315 | HAVE_ALIEN=yes | |
316 | AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)]) | |
317 | ],[ | |
318 | HAVE_ALIEN=no | |
319 | AC_MSG_RESULT([$HAVE_ALIEN]) | |
320 | ]) | |
321 | ||
322 | AC_SUBST(HAVE_ALIEN) | |
323 | AC_SUBST(ALIEN) | |
324 | AC_SUBST(ALIEN_VERSION) | |
325 | ]) | |
326 | ||
327 | dnl # | |
328 | dnl # Using the VENDOR tag from config.guess set the default | |
329 | dnl # package type for 'make pkg': (rpm | deb | tgz) | |
330 | dnl # | |
331 | AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [ | |
332 | AC_MSG_CHECKING([linux distribution]) | |
333 | if test -f /etc/toss-release ; then | |
334 | VENDOR=toss ; | |
335 | elif test -f /etc/fedora-release ; then | |
336 | VENDOR=fedora ; | |
337 | elif test -f /etc/redhat-release ; then | |
338 | VENDOR=redhat ; | |
339 | elif test -f /etc/gentoo-release ; then | |
340 | VENDOR=gentoo ; | |
341 | elif test -f /etc/arch-release ; then | |
342 | VENDOR=arch ; | |
343 | elif test -f /etc/SuSE-release ; then | |
344 | VENDOR=sles ; | |
345 | elif test -f /etc/slackware-version ; then | |
346 | VENDOR=slackware ; | |
347 | elif test -f /etc/lunar.release ; then | |
348 | VENDOR=lunar ; | |
349 | elif test -f /etc/lsb-release ; then | |
350 | VENDOR=ubuntu ; | |
351 | elif test -f /etc/debian_version ; then | |
352 | VENDOR=debian ; | |
353 | else | |
354 | VENDOR= ; | |
355 | fi | |
356 | AC_MSG_RESULT([$VENDOR]) | |
357 | AC_SUBST(VENDOR) | |
358 | ||
359 | AC_MSG_CHECKING([default package type]) | |
360 | case "$VENDOR" in | |
361 | toss) DEFAULT_PACKAGE=rpm ;; | |
362 | redhat) DEFAULT_PACKAGE=rpm ;; | |
363 | fedora) DEFAULT_PACKAGE=rpm ;; | |
364 | gentoo) DEFAULT_PACKAGE=tgz ;; | |
365 | arch) DEFAULT_PACKAGE=tgz ;; | |
366 | sles) DEFAULT_PACKAGE=rpm ;; | |
367 | slackware) DEFAULT_PACKAGE=tgz ;; | |
368 | lunar) DEFAULT_PACKAGE=tgz ;; | |
369 | ubuntu) DEFAULT_PACKAGE=deb ;; | |
370 | debian) DEFAULT_PACKAGE=deb ;; | |
371 | *) DEFAULT_PACKAGE=rpm ;; | |
372 | esac | |
373 | ||
374 | AC_MSG_RESULT([$DEFAULT_PACKAGE]) | |
375 | AC_SUBST(DEFAULT_PACKAGE) | |
376 | ]) | |
377 | ||
378 | dnl # | |
379 | dnl # Default SPL user configuration | |
380 | dnl # | |
381 | AC_DEFUN([SPL_AC_PACKAGE], [ | |
382 | SPL_AC_DEFAULT_PACKAGE | |
383 | SPL_AC_RPM | |
384 | SPL_AC_DPKG | |
385 | SPL_AC_ALIEN | |
386 | ]) | |
387 | ||
388 | AC_DEFUN([SPL_AC_LICENSE], [ | |
389 | AC_MSG_CHECKING([spl author]) | |
390 | AC_MSG_RESULT([$SPL_META_AUTHOR]) | |
391 | ||
392 | AC_MSG_CHECKING([spl license]) | |
393 | AC_MSG_RESULT([$SPL_META_LICENSE]) | |
394 | ]) | |
395 | ||
396 | AC_DEFUN([SPL_AC_CONFIG], [ | |
397 | SPL_CONFIG=all | |
398 | AC_ARG_WITH([config], | |
399 | AS_HELP_STRING([--with-config=CONFIG], | |
400 | [Config file 'kernel|user|all|srpm']), | |
401 | [SPL_CONFIG="$withval"]) | |
402 | AC_ARG_ENABLE([linux-builtin], | |
403 | [AC_HELP_STRING([--enable-linux-builtin], | |
404 | [Configure for builtin in-tree kernel modules @<:@default=no@:>@])], | |
405 | [], | |
406 | [enable_linux_builtin=no]) | |
407 | ||
408 | AC_MSG_CHECKING([spl config]) | |
409 | AC_MSG_RESULT([$SPL_CONFIG]); | |
410 | AC_SUBST(SPL_CONFIG) | |
411 | ||
412 | case "$SPL_CONFIG" in | |
413 | kernel) SPL_AC_CONFIG_KERNEL ;; | |
414 | user) SPL_AC_CONFIG_USER ;; | |
415 | all) SPL_AC_CONFIG_KERNEL | |
416 | SPL_AC_CONFIG_USER ;; | |
417 | srpm) ;; | |
418 | *) | |
419 | AC_MSG_RESULT([Error!]) | |
420 | AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config, | |
421 | user kernel|user|all|srpm]) ;; | |
422 | esac | |
423 | ||
424 | AM_CONDITIONAL([CONFIG_USER], | |
425 | [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all]) | |
426 | AM_CONDITIONAL([CONFIG_KERNEL], | |
427 | [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] && | |
428 | [test "x$enable_linux_builtin" != xyes ]) | |
429 | ]) | |
430 | ||
431 | dnl # | |
432 | dnl # Enable if the SPL should be compiled with internal debugging enabled. | |
433 | dnl # By default this support is disabled. | |
434 | dnl # | |
435 | AC_DEFUN([SPL_AC_DEBUG], [ | |
436 | AC_MSG_CHECKING([whether debugging is enabled]) | |
437 | AC_ARG_ENABLE([debug], | |
438 | [AS_HELP_STRING([--enable-debug], | |
439 | [Enable generic debug support @<:@default=no@:>@])], | |
440 | [], | |
441 | [enable_debug=no]) | |
442 | ||
443 | AS_IF([test "x$enable_debug" = xyes], | |
444 | [ | |
445 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror" | |
446 | DEBUG_CFLAGS="-DDEBUG -Werror" | |
447 | DEBUG_SPL="_with_debug" | |
448 | ], [ | |
449 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG" | |
450 | DEBUG_CFLAGS="-DNDEBUG" | |
451 | DEBUG_SPL="_without_debug" | |
452 | ]) | |
453 | ||
454 | AC_SUBST(DEBUG_CFLAGS) | |
455 | AC_SUBST(DEBUG_SPL) | |
456 | AC_MSG_RESULT([$enable_debug]) | |
457 | ]) | |
458 | ||
459 | dnl # | |
460 | dnl # Enabled by default it provides a minimal level of memory tracking. | |
461 | dnl # A total count of bytes allocated is kept for each alloc and free. | |
462 | dnl # Then at module unload time a report to the console will be printed | |
463 | dnl # if memory was leaked. | |
464 | dnl # | |
465 | AC_DEFUN([SPL_AC_DEBUG_KMEM], [ | |
466 | AC_ARG_ENABLE([debug-kmem], | |
467 | [AS_HELP_STRING([--enable-debug-kmem], | |
468 | [Enable basic kmem accounting @<:@default=no@:>@])], | |
469 | [], | |
470 | [enable_debug_kmem=no]) | |
471 | ||
472 | AS_IF([test "x$enable_debug_kmem" = xyes], | |
473 | [ | |
474 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM" | |
475 | DEBUG_KMEM="_with_debug_kmem" | |
476 | AC_DEFINE([DEBUG_KMEM], [1], | |
477 | [Define to 1 to enable basic kmem accounting]) | |
478 | ], [ | |
479 | DEBUG_KMEM="_without_debug_kmem" | |
480 | ]) | |
481 | ||
482 | AC_SUBST(DEBUG_KMEM) | |
483 | AC_MSG_CHECKING([whether basic kmem accounting is enabled]) | |
484 | AC_MSG_RESULT([$enable_debug_kmem]) | |
485 | ]) | |
486 | ||
487 | dnl # | |
488 | dnl # Disabled by default it provides detailed memory tracking. This | |
489 | dnl # feature also requires --enable-debug-kmem to be set. When enabled | |
490 | dnl # not only will total bytes be tracked but also the location of every | |
491 | dnl # alloc and free. When the SPL module is unloaded a list of all leaked | |
492 | dnl # addresses and where they were allocated will be dumped to the console. | |
493 | dnl # Enabling this feature has a significant impact on performance but it | |
494 | dnl # makes finding memory leaks pretty straight forward. | |
495 | dnl # | |
496 | AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [ | |
497 | AC_ARG_ENABLE([debug-kmem-tracking], | |
498 | [AS_HELP_STRING([--enable-debug-kmem-tracking], | |
499 | [Enable detailed kmem tracking @<:@default=no@:>@])], | |
500 | [], | |
501 | [enable_debug_kmem_tracking=no]) | |
502 | ||
503 | AS_IF([test "x$enable_debug_kmem_tracking" = xyes], | |
504 | [ | |
505 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING" | |
506 | DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking" | |
507 | AC_DEFINE([DEBUG_KMEM_TRACKING], [1], | |
508 | [Define to 1 to enable detailed kmem tracking]) | |
509 | ], [ | |
510 | DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking" | |
511 | ]) | |
512 | ||
513 | AC_SUBST(DEBUG_KMEM_TRACKING) | |
514 | AC_MSG_CHECKING([whether detailed kmem tracking is enabled]) | |
515 | AC_MSG_RESULT([$enable_debug_kmem_tracking]) | |
516 | ]) | |
517 | ||
518 | dnl # | |
519 | dnl # SPL_LINUX_CONFTEST | |
520 | dnl # | |
521 | AC_DEFUN([SPL_LINUX_CONFTEST], [ | |
522 | cat confdefs.h - <<_ACEOF >conftest.c | |
523 | $1 | |
524 | _ACEOF | |
525 | ]) | |
526 | ||
527 | dnl # | |
528 | dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY]) | |
529 | dnl # | |
530 | m4_define([SPL_LANG_PROGRAM], [ | |
531 | $1 | |
532 | int | |
533 | main (void) | |
534 | { | |
535 | dnl Do *not* indent the following line: there may be CPP directives. | |
536 | dnl Don't move the `;' right after for the same reason. | |
537 | $2 | |
538 | ; | |
539 | return 0; | |
540 | } | |
541 | ]) | |
542 | ||
543 | dnl # | |
544 | dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE | |
545 | dnl # | |
546 | AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [ | |
547 | m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])]) | |
548 | rm -Rf build && mkdir -p build && touch build/conftest.mod.c | |
549 | echo "obj-m := conftest.o" >build/Makefile | |
550 | modpost_flag='' | |
551 | test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage | |
552 | AS_IF( | |
553 | [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])], | |
554 | [$4], | |
555 | [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])] | |
556 | ) | |
557 | rm -Rf build | |
558 | ]) | |
559 | ||
560 | dnl # | |
561 | dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE | |
562 | dnl # | |
563 | AC_DEFUN([SPL_LINUX_TRY_COMPILE], | |
564 | [SPL_LINUX_COMPILE_IFELSE( | |
565 | [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])], | |
566 | [modules], | |
567 | [test -s build/conftest.o], | |
568 | [$3], [$4]) | |
569 | ]) | |
570 | ||
571 | dnl # | |
572 | dnl # SPL_CHECK_SYMBOL_EXPORT | |
573 | dnl # check symbol exported or not | |
574 | dnl # | |
575 | AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [ | |
576 | grep -q -E '[[[:space:]]]$1[[[:space:]]]' \ | |
577 | $LINUX_OBJ/Module*.symvers 2>/dev/null | |
578 | rc=$? | |
579 | if test $rc -ne 0; then | |
580 | export=0 | |
581 | for file in $2; do | |
582 | grep -q -E "EXPORT_SYMBOL.*($1)" \ | |
583 | "$LINUX_OBJ/$file" 2>/dev/null | |
584 | rc=$? | |
585 | if test $rc -eq 0; then | |
586 | export=1 | |
587 | break; | |
588 | fi | |
589 | done | |
590 | if test $export -eq 0; then : | |
591 | $4 | |
592 | else : | |
593 | $3 | |
594 | fi | |
595 | else : | |
596 | $3 | |
597 | fi | |
598 | ]) | |
599 | ||
600 | dnl # | |
601 | dnl # SPL_LINUX_TRY_COMPILE_SYMBOL | |
602 | dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT | |
603 | dnl # is called if not compiling for builtin | |
604 | dnl # | |
605 | AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [ | |
606 | SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1]) | |
607 | if test $rc -ne 0; then : | |
608 | $6 | |
609 | else | |
610 | if test "x$enable_linux_builtin" != xyes; then | |
611 | SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1]) | |
612 | fi | |
613 | if test $rc -ne 0; then : | |
614 | $6 | |
615 | else : | |
616 | $5 | |
617 | fi | |
618 | fi | |
619 | ]) | |
620 | ||
621 | dnl # | |
622 | dnl # SPL_CHECK_SYMBOL_HEADER | |
623 | dnl # check if a symbol prototype is defined in listed headers. | |
624 | dnl # | |
625 | AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [ | |
626 | AC_MSG_CHECKING([whether symbol $1 exists in header]) | |
627 | header=0 | |
628 | for file in $3; do | |
629 | grep -q "$2" "$LINUX/$file" 2>/dev/null | |
630 | rc=$? | |
631 | if test $rc -eq 0; then | |
632 | header=1 | |
633 | break; | |
634 | fi | |
635 | done | |
636 | if test $header -eq 0; then | |
637 | AC_MSG_RESULT([no]) | |
638 | $5 | |
639 | else | |
640 | AC_MSG_RESULT([yes]) | |
641 | $4 | |
642 | fi | |
643 | ]) | |
644 | ||
645 | dnl # | |
646 | dnl # SPL_CHECK_HEADER | |
647 | dnl # check whether header exists and define HAVE_$2_HEADER | |
648 | dnl # | |
649 | AC_DEFUN([SPL_CHECK_HEADER], | |
650 | [AC_MSG_CHECKING([whether header $1 exists]) | |
651 | SPL_LINUX_TRY_COMPILE([ | |
652 | #include <$1> | |
653 | ],[ | |
654 | return 0; | |
655 | ],[ | |
656 | AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists]) | |
657 | AC_MSG_RESULT(yes) | |
658 | $3 | |
659 | ],[ | |
660 | AC_MSG_RESULT(no) | |
661 | $4 | |
662 | ]) | |
663 | ]) | |
664 | ||
665 | dnl # | |
666 | dnl # Basic toolchain sanity check. Verify that kernel modules can | |
667 | dnl # be built and which symbols can be used. | |
668 | dnl # | |
669 | AC_DEFUN([SPL_AC_TEST_MODULE], | |
670 | [AC_MSG_CHECKING([whether modules can be built]) | |
671 | SPL_LINUX_TRY_COMPILE([],[],[ | |
672 | AC_MSG_RESULT([yes]) | |
673 | ],[ | |
674 | AC_MSG_RESULT([no]) | |
675 | if test "x$enable_linux_builtin" != xyes; then | |
676 | AC_MSG_ERROR([*** Unable to build an empty module.]) | |
677 | else | |
678 | AC_MSG_ERROR([ | |
679 | *** Unable to build an empty module. | |
680 | *** Please run 'make scripts' inside the kernel source tree.]) | |
681 | fi | |
682 | ]) | |
683 | ||
684 | AS_IF([test "x$cross_compiling" != xyes], [ | |
685 | AC_RUN_IFELSE([ | |
686 | AC_LANG_PROGRAM([ | |
687 | #include "$LINUX/include/linux/license.h" | |
688 | ], [ | |
689 | return !license_is_gpl_compatible( | |
690 | "$SPL_META_LICENSE"); | |
691 | ]) | |
692 | ], [ | |
693 | AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1], | |
694 | [Define to 1 if GPL-only symbols can be used]) | |
695 | ], [ | |
696 | ]) | |
697 | ]) | |
698 | ]) | |
699 | ||
700 | dnl # | |
701 | dnl # Use the atomic implemenation based on global spinlocks. This | |
702 | dnl # should only be needed by 32-bit kernels which do not provide | |
703 | dnl # the atomic64_* API. It may be optionally enabled as a fallback | |
704 | dnl # if problems are observed with the direct mapping to the native | |
705 | dnl # Linux atomic operations. You may not disable atomic spinlocks | |
706 | dnl # if you kernel does not an atomic64_* API. | |
707 | dnl # | |
708 | AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [ | |
709 | AC_ARG_ENABLE([atomic-spinlocks], | |
710 | [AS_HELP_STRING([--enable-atomic-spinlocks], | |
711 | [Atomic types use spinlocks @<:@default=check@:>@])], | |
712 | [], | |
713 | [enable_atomic_spinlocks=check]) | |
714 | ||
715 | SPL_LINUX_TRY_COMPILE([ | |
716 | #include <linux/fs.h> | |
717 | ],[ | |
718 | atomic64_t *ptr __attribute__ ((unused)); | |
719 | ],[ | |
720 | have_atomic64_t=yes | |
721 | AC_DEFINE(HAVE_ATOMIC64_T, 1, | |
722 | [kernel defines atomic64_t]) | |
723 | ],[ | |
724 | have_atomic64_t=no | |
725 | ]) | |
726 | ||
727 | AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [ | |
728 | AS_IF([test "x$have_atomic64_t" = xyes], [ | |
729 | enable_atomic_spinlocks=no | |
730 | ],[ | |
731 | enable_atomic_spinlocks=yes | |
732 | ]) | |
733 | ]) | |
734 | ||
735 | AS_IF([test "x$enable_atomic_spinlocks" = xyes], [ | |
736 | AC_DEFINE([ATOMIC_SPINLOCK], [1], | |
737 | [Atomic types use spinlocks]) | |
738 | ],[ | |
739 | AS_IF([test "x$have_atomic64_t" = xno], [ | |
740 | AC_MSG_FAILURE( | |
741 | [--disable-atomic-spinlocks given but required atomic64 support is unavailable]) | |
742 | ]) | |
743 | ]) | |
744 | ||
745 | AC_MSG_CHECKING([whether atomic types use spinlocks]) | |
746 | AC_MSG_RESULT([$enable_atomic_spinlocks]) | |
747 | ||
748 | AC_MSG_CHECKING([whether kernel defines atomic64_t]) | |
749 | AC_MSG_RESULT([$have_atomic64_t]) | |
750 | ]) | |
751 | ||
752 | AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[ | |
753 | tmp_flags="$EXTRA_KCFLAGS" | |
754 | EXTRA_KCFLAGS="-Werror" | |
755 | dnl # | |
756 | dnl # 2.6.23 to 2.6.34 API change | |
757 | dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask) | |
758 | dnl # | |
759 | AC_MSG_CHECKING([whether old 2-argument shrinker exists]) | |
760 | SPL_LINUX_TRY_COMPILE([ | |
761 | #include <linux/mm.h> | |
762 | ||
763 | int shrinker_cb(int nr_to_scan, gfp_t gfp_mask); | |
764 | ],[ | |
765 | struct shrinker cache_shrinker = { | |
766 | .shrink = shrinker_cb, | |
767 | .seeks = DEFAULT_SEEKS, | |
768 | }; | |
769 | register_shrinker(&cache_shrinker); | |
770 | ],[ | |
771 | AC_MSG_RESULT(yes) | |
772 | AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1, | |
773 | [old shrinker callback wants 2 args]) | |
774 | ],[ | |
775 | AC_MSG_RESULT(no) | |
776 | dnl # | |
777 | dnl # 2.6.35 - 2.6.39 API change | |
778 | dnl # ->shrink(struct shrinker *, | |
779 | dnl # int nr_to_scan, gfp_t gfp_mask) | |
780 | dnl # | |
781 | AC_MSG_CHECKING([whether old 3-argument shrinker exists]) | |
782 | SPL_LINUX_TRY_COMPILE([ | |
783 | #include <linux/mm.h> | |
784 | ||
785 | int shrinker_cb(struct shrinker *, int nr_to_scan, | |
786 | gfp_t gfp_mask); | |
787 | ],[ | |
788 | struct shrinker cache_shrinker = { | |
789 | .shrink = shrinker_cb, | |
790 | .seeks = DEFAULT_SEEKS, | |
791 | }; | |
792 | register_shrinker(&cache_shrinker); | |
793 | ],[ | |
794 | AC_MSG_RESULT(yes) | |
795 | AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1, | |
796 | [old shrinker callback wants 3 args]) | |
797 | ],[ | |
798 | AC_MSG_RESULT(no) | |
799 | dnl # | |
800 | dnl # 3.0 - 3.11 API change | |
801 | dnl # ->shrink(struct shrinker *, | |
802 | dnl # struct shrink_control *sc) | |
803 | dnl # | |
804 | AC_MSG_CHECKING( | |
805 | [whether new 2-argument shrinker exists]) | |
806 | SPL_LINUX_TRY_COMPILE([ | |
807 | #include <linux/mm.h> | |
808 | ||
809 | int shrinker_cb(struct shrinker *, | |
810 | struct shrink_control *sc); | |
811 | ],[ | |
812 | struct shrinker cache_shrinker = { | |
813 | .shrink = shrinker_cb, | |
814 | .seeks = DEFAULT_SEEKS, | |
815 | }; | |
816 | register_shrinker(&cache_shrinker); | |
817 | ],[ | |
818 | AC_MSG_RESULT(yes) | |
819 | AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1, | |
820 | [new shrinker callback wants 2 args]) | |
821 | ],[ | |
822 | AC_MSG_RESULT(no) | |
823 | dnl # | |
824 | dnl # 3.12 API change, | |
825 | dnl # ->shrink() is logically split in to | |
826 | dnl # ->count_objects() and ->scan_objects() | |
827 | dnl # | |
828 | AC_MSG_CHECKING( | |
829 | [whether ->count_objects callback exists]) | |
830 | SPL_LINUX_TRY_COMPILE([ | |
831 | #include <linux/mm.h> | |
832 | ||
833 | unsigned long shrinker_cb( | |
834 | struct shrinker *, | |
835 | struct shrink_control *sc); | |
836 | ],[ | |
837 | struct shrinker cache_shrinker = { | |
838 | .count_objects = shrinker_cb, | |
839 | .scan_objects = shrinker_cb, | |
840 | .seeks = DEFAULT_SEEKS, | |
841 | }; | |
842 | register_shrinker(&cache_shrinker); | |
843 | ],[ | |
844 | AC_MSG_RESULT(yes) | |
845 | AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, | |
846 | 1, [->count_objects exists]) | |
847 | ],[ | |
848 | AC_MSG_ERROR(error) | |
849 | ]) | |
850 | ]) | |
851 | ]) | |
852 | ]) | |
853 | EXTRA_KCFLAGS="$tmp_flags" | |
854 | ]) | |
855 | ||
856 | dnl # | |
857 | dnl # 2.6.33 API change, | |
858 | dnl # Removed .ctl_name from struct ctl_table. | |
859 | dnl # | |
860 | AC_DEFUN([SPL_AC_CTL_NAME], [ | |
861 | AC_MSG_CHECKING([whether struct ctl_table has ctl_name]) | |
862 | SPL_LINUX_TRY_COMPILE([ | |
863 | #include <linux/sysctl.h> | |
864 | ],[ | |
865 | struct ctl_table ctl __attribute__ ((unused)); | |
866 | ctl.ctl_name = 0; | |
867 | ],[ | |
868 | AC_MSG_RESULT(yes) | |
869 | AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name]) | |
870 | ],[ | |
871 | AC_MSG_RESULT(no) | |
872 | ]) | |
873 | ]) | |
874 | ||
875 | dnl # | |
876 | dnl # 3.10 API change, | |
877 | dnl # PDE is replaced by PDE_DATA | |
878 | dnl # | |
879 | AC_DEFUN([SPL_AC_PDE_DATA], [ | |
880 | AC_MSG_CHECKING([whether PDE_DATA() is available]) | |
881 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
882 | #include <linux/proc_fs.h> | |
883 | ], [ | |
884 | PDE_DATA(NULL); | |
885 | ], [PDE_DATA], [], [ | |
886 | AC_MSG_RESULT(yes) | |
887 | AC_DEFINE(HAVE_PDE_DATA, 1, [yes]) | |
888 | ],[ | |
889 | AC_MSG_RESULT(no) | |
890 | ]) | |
891 | ]) | |
892 | ||
893 | dnl # | |
894 | dnl # 3.9 API change | |
895 | dnl # set_fs_pwd takes const struct path * | |
896 | dnl # | |
897 | AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST], | |
898 | tmp_flags="$EXTRA_KCFLAGS" | |
899 | EXTRA_KCFLAGS="-Werror" | |
900 | [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *]) | |
901 | SPL_LINUX_TRY_COMPILE([ | |
902 | #include <linux/spinlock.h> | |
903 | #include <linux/fs_struct.h> | |
904 | #include <linux/path.h> | |
905 | void (*const set_fs_pwd_func) | |
906 | (struct fs_struct *, const struct path *) | |
907 | = set_fs_pwd; | |
908 | ],[ | |
909 | return 0; | |
910 | ],[ | |
911 | AC_MSG_RESULT(yes) | |
912 | AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1, | |
913 | [set_fs_pwd() needs const path *]) | |
914 | ],[ | |
915 | SPL_LINUX_TRY_COMPILE([ | |
916 | #include <linux/spinlock.h> | |
917 | #include <linux/fs_struct.h> | |
918 | #include <linux/path.h> | |
919 | void (*const set_fs_pwd_func) | |
920 | (struct fs_struct *, struct path *) | |
921 | = set_fs_pwd; | |
922 | ],[ | |
923 | return 0; | |
924 | ],[ | |
925 | AC_MSG_RESULT(no) | |
926 | ],[ | |
927 | AC_MSG_ERROR(unknown) | |
928 | ]) | |
929 | ]) | |
930 | EXTRA_KCFLAGS="$tmp_flags" | |
931 | ]) | |
932 | ||
933 | dnl # | |
934 | dnl # 3.13 API change | |
935 | dnl # vfs_unlink() updated to take a third delegated_inode argument. | |
936 | dnl # | |
937 | AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK], | |
938 | [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args]) | |
939 | SPL_LINUX_TRY_COMPILE([ | |
940 | #include <linux/fs.h> | |
941 | ],[ | |
942 | vfs_unlink((struct inode *) NULL, (struct dentry *) NULL); | |
943 | ],[ | |
944 | AC_MSG_RESULT(yes) | |
945 | AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1, | |
946 | [vfs_unlink() wants 2 args]) | |
947 | ],[ | |
948 | AC_MSG_RESULT(no) | |
949 | dnl # | |
950 | dnl # Linux 3.13 API change | |
951 | dnl # Added delegated inode | |
952 | dnl # | |
953 | AC_MSG_CHECKING([whether vfs_unlink() wants 3 args]) | |
954 | SPL_LINUX_TRY_COMPILE([ | |
955 | #include <linux/fs.h> | |
956 | ],[ | |
957 | vfs_unlink((struct inode *) NULL, | |
958 | (struct dentry *) NULL, | |
959 | (struct inode **) NULL); | |
960 | ],[ | |
961 | AC_MSG_RESULT(yes) | |
962 | AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1, | |
963 | [vfs_unlink() wants 3 args]) | |
964 | ],[ | |
965 | AC_MSG_ERROR(no) | |
966 | ]) | |
967 | ||
968 | ]) | |
969 | ]) | |
970 | ||
971 | dnl # | |
972 | dnl # 3.13 and 3.15 API changes | |
973 | dnl # Added delegated inode and flags argument. | |
974 | dnl # | |
975 | AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME], | |
976 | [AC_MSG_CHECKING([whether vfs_rename() wants 4 args]) | |
977 | SPL_LINUX_TRY_COMPILE([ | |
978 | #include <linux/fs.h> | |
979 | ],[ | |
980 | vfs_rename((struct inode *) NULL, (struct dentry *) NULL, | |
981 | (struct inode *) NULL, (struct dentry *) NULL); | |
982 | ],[ | |
983 | AC_MSG_RESULT(yes) | |
984 | AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1, | |
985 | [vfs_rename() wants 4 args]) | |
986 | ],[ | |
987 | AC_MSG_RESULT(no) | |
988 | dnl # | |
989 | dnl # Linux 3.13 API change | |
990 | dnl # Added delegated inode | |
991 | dnl # | |
992 | AC_MSG_CHECKING([whether vfs_rename() wants 5 args]) | |
993 | SPL_LINUX_TRY_COMPILE([ | |
994 | #include <linux/fs.h> | |
995 | ],[ | |
996 | vfs_rename((struct inode *) NULL, | |
997 | (struct dentry *) NULL, | |
998 | (struct inode *) NULL, | |
999 | (struct dentry *) NULL, | |
1000 | (struct inode **) NULL); | |
1001 | ],[ | |
1002 | AC_MSG_RESULT(yes) | |
1003 | AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1, | |
1004 | [vfs_rename() wants 5 args]) | |
1005 | ],[ | |
1006 | AC_MSG_RESULT(no) | |
1007 | dnl # | |
1008 | dnl # Linux 3.15 API change | |
1009 | dnl # Added flags | |
1010 | dnl # | |
1011 | AC_MSG_CHECKING([whether vfs_rename() wants 6 args]) | |
1012 | SPL_LINUX_TRY_COMPILE([ | |
1013 | #include <linux/fs.h> | |
1014 | ],[ | |
1015 | vfs_rename((struct inode *) NULL, | |
1016 | (struct dentry *) NULL, | |
1017 | (struct inode *) NULL, | |
1018 | (struct dentry *) NULL, | |
1019 | (struct inode **) NULL, | |
1020 | (unsigned int) 0); | |
1021 | ],[ | |
1022 | AC_MSG_RESULT(yes) | |
1023 | AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1, | |
1024 | [vfs_rename() wants 6 args]) | |
1025 | ],[ | |
1026 | AC_MSG_ERROR(no) | |
1027 | ]) | |
1028 | ]) | |
1029 | ]) | |
1030 | ]) | |
1031 | ||
1032 | dnl # | |
1033 | dnl # 2.6.36 API change, | |
1034 | dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to | |
1035 | dnl # a spinlock_t to improve the fastpath performance. | |
1036 | dnl # | |
1037 | AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [ | |
1038 | AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t]) | |
1039 | tmp_flags="$EXTRA_KCFLAGS" | |
1040 | EXTRA_KCFLAGS="-Werror" | |
1041 | SPL_LINUX_TRY_COMPILE([ | |
1042 | #include <linux/sched.h> | |
1043 | #include <linux/fs_struct.h> | |
1044 | ],[ | |
1045 | static struct fs_struct fs; | |
1046 | spin_lock_init(&fs.lock); | |
1047 | ],[ | |
1048 | AC_MSG_RESULT(yes) | |
1049 | AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1, | |
1050 | [struct fs_struct uses spinlock_t]) | |
1051 | ],[ | |
1052 | AC_MSG_RESULT(no) | |
1053 | ]) | |
1054 | EXTRA_KCFLAGS="$tmp_flags" | |
1055 | ]) | |
1056 | ||
1057 | dnl # | |
1058 | dnl # User namespaces, use kuid_t in place of uid_t | |
1059 | dnl # where available. Not strictly a user namespaces thing | |
1060 | dnl # but it should prevent surprises | |
1061 | dnl # | |
1062 | AC_DEFUN([SPL_AC_KUIDGID_T], [ | |
1063 | AC_MSG_CHECKING([whether kuid_t/kgid_t is available]) | |
1064 | SPL_LINUX_TRY_COMPILE([ | |
1065 | #include <linux/uidgid.h> | |
1066 | ], [ | |
1067 | kuid_t userid = KUIDT_INIT(0); | |
1068 | kgid_t groupid = KGIDT_INIT(0); | |
1069 | ],[ | |
1070 | SPL_LINUX_TRY_COMPILE([ | |
1071 | #include <linux/uidgid.h> | |
1072 | ], [ | |
1073 | kuid_t userid = 0; | |
1074 | kgid_t groupid = 0; | |
1075 | ],[ | |
1076 | AC_MSG_RESULT(yes; optional) | |
1077 | ],[ | |
1078 | AC_MSG_RESULT(yes; mandatory) | |
1079 | AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use]) | |
1080 | ]) | |
1081 | ],[ | |
1082 | AC_MSG_RESULT(no) | |
1083 | ]) | |
1084 | ]) | |
1085 | ||
87d546d8 TG |
1086 | dnl # |
1087 | dnl # 2.6.35 API change, | |
1088 | dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype. | |
1089 | dnl # | |
1090 | AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [ | |
1091 | AC_MSG_CHECKING([whether vfs_fsync() wants 2 args]) | |
1092 | SPL_LINUX_TRY_COMPILE([ | |
1093 | #include <linux/fs.h> | |
1094 | ],[ | |
1095 | vfs_fsync(NULL, 0); | |
1096 | ],[ | |
1097 | AC_MSG_RESULT(yes) | |
1098 | AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args]) | |
1099 | ],[ | |
1100 | AC_MSG_RESULT(no) | |
1101 | ]) | |
1102 | ]) | |
1103 | ||
1104 | dnl # | |
1105 | dnl # 3.5 API change, | |
1106 | dnl # inode_operations.truncate_range removed | |
1107 | dnl # | |
1108 | AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [ | |
1109 | AC_MSG_CHECKING([whether truncate_range() inode operation is available]) | |
1110 | SPL_LINUX_TRY_COMPILE([ | |
1111 | #include <linux/fs.h> | |
1112 | ],[ | |
1113 | struct inode_operations ops; | |
1114 | ops.truncate_range = NULL; | |
1115 | ],[ | |
1116 | AC_MSG_RESULT(yes) | |
1117 | AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1, | |
1118 | [truncate_range() inode operation is available]) | |
1119 | ],[ | |
1120 | AC_MSG_RESULT(no) | |
1121 | ]) | |
1122 | ]) | |
1123 | ||
1124 | dnl # | |
1125 | dnl # Linux 2.6.38 - 3.x API | |
1126 | dnl # | |
1127 | AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [ | |
1128 | AC_MSG_CHECKING([whether fops->fallocate() exists]) | |
1129 | SPL_LINUX_TRY_COMPILE([ | |
1130 | #include <linux/fs.h> | |
1131 | ],[ | |
1132 | long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL; | |
1133 | struct file_operations fops __attribute__ ((unused)) = { | |
1134 | .fallocate = fallocate, | |
1135 | }; | |
1136 | ],[ | |
1137 | AC_MSG_RESULT(yes) | |
1138 | AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists]) | |
1139 | ],[ | |
1140 | AC_MSG_RESULT(no) | |
1141 | ]) | |
1142 | ]) | |
1143 | ||
1144 | dnl # | |
1145 | dnl # Linux 2.6.x - 2.6.37 API | |
1146 | dnl # | |
1147 | AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [ | |
1148 | AC_MSG_CHECKING([whether iops->fallocate() exists]) | |
1149 | SPL_LINUX_TRY_COMPILE([ | |
1150 | #include <linux/fs.h> | |
1151 | ],[ | |
1152 | long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL; | |
1153 | struct inode_operations fops __attribute__ ((unused)) = { | |
1154 | .fallocate = fallocate, | |
1155 | }; | |
1156 | ],[ | |
1157 | AC_MSG_RESULT(yes) | |
1158 | AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists]) | |
1159 | ],[ | |
1160 | AC_MSG_RESULT(no) | |
1161 | ]) | |
1162 | ]) | |
1163 | ||
1164 | dnl # | |
1165 | dnl # PaX Linux 2.6.38 - 3.x API | |
1166 | dnl # | |
1167 | AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [ | |
1168 | AC_MSG_CHECKING([whether fops->fallocate() exists]) | |
1169 | SPL_LINUX_TRY_COMPILE([ | |
1170 | #include <linux/fs.h> | |
1171 | ],[ | |
1172 | long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL; | |
1173 | struct file_operations_no_const fops __attribute__ ((unused)) = { | |
1174 | .fallocate = fallocate, | |
1175 | }; | |
1176 | ],[ | |
1177 | AC_MSG_RESULT(yes) | |
1178 | AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists]) | |
1179 | ],[ | |
1180 | AC_MSG_RESULT(no) | |
1181 | ]) | |
1182 | ]) | |
1183 | ||
1184 | dnl # | |
1185 | dnl # The fallocate callback was moved from the inode_operations | |
1186 | dnl # structure to the file_operations structure. | |
1187 | dnl # | |
1188 | AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [ | |
1189 | SPL_AC_KERNEL_FILE_FALLOCATE | |
1190 | SPL_AC_KERNEL_INODE_FALLOCATE | |
1191 | SPL_AC_PAX_KERNEL_FILE_FALLOCATE | |
1192 | ]) | |
1193 | ||
1194 | dnl # | |
1195 | dnl # zlib inflate compat, | |
1196 | dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled. | |
1197 | dnl # | |
1198 | AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [ | |
1199 | AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined]) | |
1200 | SPL_LINUX_TRY_COMPILE([ | |
1201 | #if !defined(CONFIG_ZLIB_INFLATE) && \ | |
1202 | !defined(CONFIG_ZLIB_INFLATE_MODULE) | |
1203 | #error CONFIG_ZLIB_INFLATE not defined | |
1204 | #endif | |
1205 | ],[ ],[ | |
1206 | AC_MSG_RESULT([yes]) | |
1207 | ],[ | |
1208 | AC_MSG_RESULT([no]) | |
1209 | AC_MSG_ERROR([ | |
1210 | *** This kernel does not include the required zlib inflate support. | |
1211 | *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.]) | |
1212 | ]) | |
1213 | ]) | |
1214 | ||
1215 | dnl # | |
1216 | dnl # zlib deflate compat, | |
1217 | dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled. | |
1218 | dnl # | |
1219 | AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [ | |
1220 | AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined]) | |
1221 | SPL_LINUX_TRY_COMPILE([ | |
1222 | #if !defined(CONFIG_ZLIB_DEFLATE) && \ | |
1223 | !defined(CONFIG_ZLIB_DEFLATE_MODULE) | |
1224 | #error CONFIG_ZLIB_DEFLATE not defined | |
1225 | #endif | |
1226 | ],[ ],[ | |
1227 | AC_MSG_RESULT([yes]) | |
1228 | ],[ | |
1229 | AC_MSG_RESULT([no]) | |
1230 | AC_MSG_ERROR([ | |
1231 | *** This kernel does not include the required zlib deflate support. | |
1232 | *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.]) | |
1233 | ]) | |
1234 | ]) | |
1235 | ||
1236 | dnl # | |
1237 | dnl # config trim unused symbols, | |
1238 | dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS DISABLED. | |
1239 | dnl # | |
1240 | AC_DEFUN([SPL_AC_CONFIG_TRIM_UNUSED_KSYMS], [ | |
1241 | AC_MSG_CHECKING([whether CONFIG_TRIM_UNUSED_KSYM is disabled]) | |
1242 | SPL_LINUX_TRY_COMPILE([ | |
1243 | #if defined(CONFIG_TRIM_UNUSED_KSYMS) | |
1244 | #error CONFIG_TRIM_UNUSED_KSYMS not defined | |
1245 | #endif | |
1246 | ],[ ],[ | |
1247 | AC_MSG_RESULT([yes]) | |
1248 | ],[ | |
1249 | AC_MSG_RESULT([no]) | |
1250 | AC_MSG_ERROR([ | |
1251 | *** This kernel has unused symbols trimming enabled, please disable. | |
1252 | *** Rebuild the kernel with CONFIG_TRIM_UNUSED_KSYMS=n set.]) | |
1253 | ]) | |
1254 | ]) | |
1255 | ||
1256 | dnl # | |
1257 | dnl # 2.6.39 API compat, | |
1258 | dnl # The function zlib_deflate_workspacesize() now take 2 arguments. | |
1259 | dnl # This was done to avoid always having to allocate the maximum size | |
1260 | dnl # workspace (268K). The caller can now specific the windowBits and | |
1261 | dnl # memLevel compression parameters to get a smaller workspace. | |
1262 | dnl # | |
1263 | AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE], | |
1264 | [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args]) | |
1265 | SPL_LINUX_TRY_COMPILE([ | |
1266 | #include <linux/zlib.h> | |
1267 | ],[ | |
1268 | return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL); | |
1269 | ],[ | |
1270 | AC_MSG_RESULT(yes) | |
1271 | AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1, | |
1272 | [zlib_deflate_workspacesize() wants 2 args]) | |
1273 | ],[ | |
1274 | AC_MSG_RESULT(no) | |
1275 | ]) | |
1276 | ]) | |
1277 | ||
1278 | dnl # | |
1279 | dnl # 2.6.39 API change, | |
1280 | dnl # Shrinker adjust to use common shrink_control structure. | |
1281 | dnl # | |
1282 | AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [ | |
1283 | AC_MSG_CHECKING([whether struct shrink_control exists]) | |
1284 | SPL_LINUX_TRY_COMPILE([ | |
1285 | #include <linux/mm.h> | |
1286 | ],[ | |
1287 | struct shrink_control sc __attribute__ ((unused)); | |
1288 | ||
1289 | sc.nr_to_scan = 0; | |
1290 | sc.gfp_mask = GFP_KERNEL; | |
1291 | ],[ | |
1292 | AC_MSG_RESULT(yes) | |
1293 | AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1, | |
1294 | [struct shrink_control exists]) | |
1295 | ],[ | |
1296 | AC_MSG_RESULT(no) | |
1297 | ]) | |
1298 | ]) | |
1299 | ||
1300 | dnl # | |
1301 | dnl # 3.1 API Change | |
1302 | dnl # | |
1303 | dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to | |
1304 | dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1. | |
1305 | dnl # | |
1306 | AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [ | |
1307 | AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw]) | |
1308 | tmp_flags="$EXTRA_KCFLAGS" | |
1309 | EXTRA_KCFLAGS="-Werror" | |
1310 | SPL_LINUX_TRY_COMPILE([ | |
1311 | #include <linux/rwsem.h> | |
1312 | ],[ | |
1313 | struct rw_semaphore dummy_semaphore __attribute__ ((unused)); | |
1314 | raw_spinlock_t dummy_lock __attribute__ ((unused)); | |
1315 | dummy_semaphore.wait_lock = dummy_lock; | |
1316 | ],[ | |
1317 | AC_MSG_RESULT(yes) | |
1318 | AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1, | |
1319 | [struct rw_semaphore member wait_lock is raw_spinlock_t]) | |
1320 | ],[ | |
1321 | AC_MSG_RESULT(no) | |
1322 | ]) | |
1323 | EXTRA_KCFLAGS="$tmp_flags" | |
1324 | ]) | |
1325 | ||
1326 | dnl # | |
1327 | dnl # 3.16 API Change | |
1328 | dnl # | |
1329 | dnl # rwsem-spinlock "->activity" changed to "->count" | |
1330 | dnl # | |
1331 | AC_DEFUN([SPL_AC_RWSEM_ACTIVITY], [ | |
1332 | AC_MSG_CHECKING([whether struct rw_semaphore has member activity]) | |
1333 | tmp_flags="$EXTRA_KCFLAGS" | |
1334 | EXTRA_KCFLAGS="-Werror" | |
1335 | SPL_LINUX_TRY_COMPILE([ | |
1336 | #include <linux/rwsem.h> | |
1337 | ],[ | |
1338 | struct rw_semaphore dummy_semaphore __attribute__ ((unused)); | |
1339 | dummy_semaphore.activity = 0; | |
1340 | ],[ | |
1341 | AC_MSG_RESULT(yes) | |
1342 | AC_DEFINE(HAVE_RWSEM_ACTIVITY, 1, | |
1343 | [struct rw_semaphore has member activity]) | |
1344 | ],[ | |
1345 | AC_MSG_RESULT(no) | |
1346 | ]) | |
1347 | EXTRA_KCFLAGS="$tmp_flags" | |
1348 | ]) | |
1349 | ||
1350 | dnl # | |
1351 | dnl # 4.8 API Change | |
1352 | dnl # | |
1353 | dnl # rwsem "->count" changed to atomic_long_t type | |
1354 | dnl # | |
1355 | AC_DEFUN([SPL_AC_RWSEM_ATOMIC_LONG_COUNT], [ | |
1356 | AC_MSG_CHECKING( | |
1357 | [whether struct rw_semaphore has atomic_long_t member count]) | |
1358 | tmp_flags="$EXTRA_KCFLAGS" | |
1359 | EXTRA_KCFLAGS="-Werror" | |
1360 | SPL_LINUX_TRY_COMPILE([ | |
1361 | #include <linux/rwsem.h> | |
1362 | ],[ | |
1363 | DECLARE_RWSEM(dummy_semaphore); | |
1364 | (void) atomic_long_read(&dummy_semaphore.count); | |
1365 | ],[ | |
1366 | AC_MSG_RESULT(yes) | |
1367 | AC_DEFINE(HAVE_RWSEM_ATOMIC_LONG_COUNT, 1, | |
1368 | [struct rw_semaphore has atomic_long_t member count]) | |
1369 | ],[ | |
1370 | AC_MSG_RESULT(no) | |
1371 | ]) | |
1372 | EXTRA_KCFLAGS="$tmp_flags" | |
1373 | ]) | |
1374 | ||
1375 | dnl # | |
1376 | dnl # 3.9 API change, | |
1377 | dnl # Moved things from linux/sched.h to linux/sched/rt.h | |
1378 | dnl # | |
1379 | AC_DEFUN([SPL_AC_SCHED_RT_HEADER], | |
1380 | [AC_MSG_CHECKING([whether header linux/sched/rt.h exists]) | |
1381 | SPL_LINUX_TRY_COMPILE([ | |
1382 | #include <linux/sched.h> | |
1383 | #include <linux/sched/rt.h> | |
1384 | ],[ | |
1385 | return 0; | |
1386 | ],[ | |
1387 | AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists]) | |
1388 | AC_MSG_RESULT(yes) | |
1389 | ],[ | |
1390 | AC_MSG_RESULT(no) | |
1391 | ]) | |
1392 | ]) | |
1393 | ||
1394 | dnl # | |
3e990ae0 CIK |
1395 | dnl # 4.11 API change, |
1396 | dnl # Moved things from linux/sched.h to linux/sched/signal.h | |
1397 | dnl # | |
1398 | AC_DEFUN([SPL_AC_SCHED_SIGNAL_HEADER], | |
1399 | [AC_MSG_CHECKING([whether header linux/sched/signal.h exists]) | |
1400 | SPL_LINUX_TRY_COMPILE([ | |
1401 | #include <linux/sched.h> | |
1402 | #include <linux/sched/signal.h> | |
1403 | ],[ | |
1404 | return 0; | |
1405 | ],[ | |
1406 | AC_DEFINE(HAVE_SCHED_SIGNAL_HEADER, 1, [linux/sched/signal.h exists]) | |
1407 | AC_MSG_RESULT(yes) | |
1408 | ],[ | |
1409 | AC_MSG_RESULT(no) | |
1410 | ]) | |
1411 | ]) | |
1412 | ||
1413 | dnl # | |
1414 | dnl # 4.11 API, a528d35e@torvalds/linux | |
1415 | dnl # vfs_getattr(const struct path *p, struct kstat *s, u32 m, unsigned int f) | |
1416 | dnl # | |
1417 | AC_DEFUN([SPL_AC_4ARGS_VFS_GETATTR], [ | |
1418 | AC_MSG_CHECKING([whether vfs_getattr() wants 4 args]) | |
1419 | SPL_LINUX_TRY_COMPILE([ | |
1420 | #include <linux/fs.h> | |
1421 | ],[ | |
1422 | vfs_getattr((const struct path *)NULL, | |
1423 | (struct kstat *)NULL, | |
1424 | (u32)0, | |
1425 | (unsigned int)0); | |
1426 | ],[ | |
1427 | AC_MSG_RESULT(yes) | |
1428 | AC_DEFINE(HAVE_4ARGS_VFS_GETATTR, 1, | |
1429 | [vfs_getattr wants 4 args]) | |
1430 | ],[ | |
1431 | AC_MSG_RESULT(no) | |
1432 | ]) | |
1433 | ]) | |
1434 | ||
1435 | dnl # | |
1436 | dnl # 3.9 API | |
1437 | dnl # vfs_getattr(struct path *p, struct kstat *s) | |
87d546d8 TG |
1438 | dnl # |
1439 | AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [ | |
3e990ae0 | 1440 | AC_MSG_CHECKING([whether vfs_getattr() wants 2 args]) |
87d546d8 TG |
1441 | SPL_LINUX_TRY_COMPILE([ |
1442 | #include <linux/fs.h> | |
1443 | ],[ | |
1444 | vfs_getattr((struct path *) NULL, | |
1445 | (struct kstat *)NULL); | |
1446 | ],[ | |
3e990ae0 | 1447 | AC_MSG_RESULT(yes) |
87d546d8 | 1448 | AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1, |
3e990ae0 | 1449 | [vfs_getattr wants 2 args]) |
87d546d8 | 1450 | ],[ |
3e990ae0 CIK |
1451 | AC_MSG_RESULT(no) |
1452 | ]) | |
1453 | ]) | |
1454 | ||
1455 | dnl # | |
1456 | dnl # <3.9 API | |
1457 | dnl # vfs_getattr(struct vfsmount *v, struct dentry *d, struct kstat *k) | |
1458 | dnl # | |
1459 | AC_DEFUN([SPL_AC_3ARGS_VFS_GETATTR], [ | |
1460 | AC_MSG_CHECKING([whether vfs_getattr() wants 3 args]) | |
1461 | SPL_LINUX_TRY_COMPILE([ | |
1462 | #include <linux/fs.h> | |
1463 | ],[ | |
1464 | vfs_getattr((struct vfsmount *)NULL, | |
1465 | (struct dentry *)NULL, | |
1466 | (struct kstat *)NULL); | |
1467 | ],[ | |
1468 | AC_MSG_RESULT(yes) | |
1469 | AC_DEFINE(HAVE_3ARGS_VFS_GETATTR, 1, | |
1470 | [vfs_getattr wants 3 args]) | |
1471 | ],[ | |
1472 | AC_MSG_RESULT(no) | |
87d546d8 TG |
1473 | ]) |
1474 | ]) | |
1475 | ||
1476 | dnl # | |
1477 | dnl # 2.6.36 API compatibility. | |
1478 | dnl # Added usleep_range timer. | |
1479 | dnl # usleep_range is a finer precision implementation of msleep | |
1480 | dnl # designed to be a drop-in replacement for udelay where a precise | |
1481 | dnl # sleep / busy-wait is unnecessary. | |
1482 | dnl # | |
1483 | AC_DEFUN([SPL_AC_USLEEP_RANGE], [ | |
1484 | AC_MSG_CHECKING([whether usleep_range() is available]) | |
1485 | SPL_LINUX_TRY_COMPILE([ | |
1486 | #include <linux/delay.h> | |
1487 | ],[ | |
1488 | usleep_range(0, 0); | |
1489 | ],[ | |
1490 | AC_MSG_RESULT(yes) | |
1491 | AC_DEFINE(HAVE_USLEEP_RANGE, 1, | |
1492 | [usleep_range is available]) | |
1493 | ],[ | |
1494 | AC_MSG_RESULT(no) | |
1495 | ]) | |
1496 | ]) | |
1497 | ||
1498 | dnl # | |
1499 | dnl # 2.6.35 API change, | |
1500 | dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are | |
1501 | dnl # private allocation flags which are applied when allocating a new slab | |
1502 | dnl # in kmem_getpages(). Unfortunately there is no public API for setting | |
1503 | dnl # non-default flags. | |
1504 | dnl # | |
1505 | AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [ | |
1506 | AC_MSG_CHECKING([whether struct kmem_cache has allocflags]) | |
1507 | SPL_LINUX_TRY_COMPILE([ | |
1508 | #include <linux/slab.h> | |
1509 | ],[ | |
1510 | struct kmem_cache cachep __attribute__ ((unused)); | |
1511 | cachep.allocflags = GFP_KERNEL; | |
1512 | ],[ | |
1513 | AC_MSG_RESULT(yes) | |
1514 | AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1, | |
1515 | [struct kmem_cache has allocflags]) | |
1516 | ],[ | |
1517 | AC_MSG_RESULT(no) | |
1518 | ||
1519 | AC_MSG_CHECKING([whether struct kmem_cache has gfpflags]) | |
1520 | SPL_LINUX_TRY_COMPILE([ | |
1521 | #include <linux/slab.h> | |
1522 | ],[ | |
1523 | struct kmem_cache cachep __attribute__ ((unused)); | |
1524 | cachep.gfpflags = GFP_KERNEL; | |
1525 | ],[ | |
1526 | AC_MSG_RESULT(yes) | |
1527 | AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1, | |
1528 | [struct kmem_cache has gfpflags]) | |
1529 | ],[ | |
1530 | AC_MSG_RESULT(no) | |
1531 | ]) | |
1532 | ]) | |
1533 | ]) | |
1534 | ||
1535 | dnl # | |
1536 | dnl # 3.17 API change, | |
1537 | dnl # wait_on_bit() no longer requires an action argument. The former | |
1538 | dnl # "wait_on_bit" interface required an 'action' function to be provided | |
1539 | dnl # which does the actual waiting. There were over 20 such functions in the | |
1540 | dnl # kernel, many of them identical, though most cases can be satisfied by one | |
1541 | dnl # of just two functions: one which uses io_schedule() and one which just | |
1542 | dnl # uses schedule(). This API change was made to consolidate all of those | |
1543 | dnl # redundant wait functions. | |
1544 | dnl # | |
1545 | AC_DEFUN([SPL_AC_WAIT_ON_BIT], [ | |
1546 | AC_MSG_CHECKING([whether wait_on_bit() takes an action]) | |
1547 | SPL_LINUX_TRY_COMPILE([ | |
1548 | #include <linux/wait.h> | |
1549 | ],[ | |
1550 | int (*action)(void *) = NULL; | |
1551 | wait_on_bit(NULL, 0, action, 0); | |
1552 | ],[ | |
1553 | AC_MSG_RESULT(yes) | |
1554 | AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes]) | |
1555 | ],[ | |
1556 | AC_MSG_RESULT(no) | |
1557 | ]) | |
1558 | ]) | |
1559 | ||
1560 | dnl # | |
1561 | dnl # 4.7 API change | |
1562 | dnl # i_mutex is changed to i_rwsem. Instead of directly using | |
1563 | dnl # i_mutex/i_rwsem, we should use inode_lock() and inode_lock_shared() | |
1564 | dnl # We test inode_lock_shared because inode_lock is introduced earlier. | |
1565 | dnl # | |
1566 | AC_DEFUN([SPL_AC_INODE_LOCK], [ | |
1567 | AC_MSG_CHECKING([whether inode_lock_shared() exists]) | |
1568 | tmp_flags="$EXTRA_KCFLAGS" | |
1569 | EXTRA_KCFLAGS="-Werror" | |
1570 | SPL_LINUX_TRY_COMPILE([ | |
1571 | #include <linux/fs.h> | |
1572 | ],[ | |
1573 | struct inode *inode = NULL; | |
1574 | inode_lock_shared(inode); | |
1575 | ],[ | |
1576 | AC_MSG_RESULT(yes) | |
1577 | AC_DEFINE(HAVE_INODE_LOCK_SHARED, 1, [yes]) | |
1578 | ],[ | |
1579 | AC_MSG_RESULT(no) | |
1580 | ]) | |
1581 | EXTRA_KCFLAGS="$tmp_flags" | |
1582 | ]) | |
1583 | ||
1584 | dnl # | |
1585 | dnl # Check whether mutex has owner with task_struct type. | |
1586 | dnl # | |
1587 | dnl # Note that before Linux 3.0, mutex owner is of type thread_info. | |
1588 | dnl # | |
1589 | dnl # Note that in Linux 3.18, the condition for owner is changed from | |
1590 | dnl # defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_SMP) to | |
1591 | dnl # defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_MUTEX_SPIN_ON_OWNER) | |
1592 | dnl # | |
1593 | AC_DEFUN([SPL_AC_MUTEX_OWNER], [ | |
1594 | AC_MSG_CHECKING([whether mutex has owner]) | |
1595 | tmp_flags="$EXTRA_KCFLAGS" | |
1596 | EXTRA_KCFLAGS="-Werror" | |
1597 | SPL_LINUX_TRY_COMPILE([ | |
1598 | #include <linux/mutex.h> | |
1599 | #include <linux/spinlock.h> | |
1600 | ],[ | |
1601 | DEFINE_MUTEX(m); | |
1602 | struct task_struct *t __attribute__ ((unused)); | |
1603 | t = m.owner; | |
1604 | ],[ | |
1605 | AC_MSG_RESULT(yes) | |
1606 | AC_DEFINE(HAVE_MUTEX_OWNER, 1, [yes]) | |
1607 | ],[ | |
1608 | AC_MSG_RESULT(no) | |
1609 | ]) | |
1610 | EXTRA_KCFLAGS="$tmp_flags" | |
1611 | ]) | |
1612 | ||
1613 | dnl # | |
1614 | dnl # 4.9 API change | |
1615 | dnl # group_info changed from 2d array via >blocks to 1d array via ->gid | |
1616 | dnl # | |
1617 | AC_DEFUN([SPL_AC_GROUP_INFO_GID], [ | |
1618 | AC_MSG_CHECKING([whether group_info->gid exists]) | |
1619 | tmp_flags="$EXTRA_KCFLAGS" | |
1620 | EXTRA_KCFLAGS="-Werror" | |
1621 | SPL_LINUX_TRY_COMPILE([ | |
1622 | #include <linux/cred.h> | |
1623 | ],[ | |
1624 | struct group_info *gi = groups_alloc(1); | |
1625 | gi->gid[0] = KGIDT_INIT(0); | |
1626 | ],[ | |
1627 | AC_MSG_RESULT(yes) | |
1628 | AC_DEFINE(HAVE_GROUP_INFO_GID, 1, [group_info->gid exists]) | |
1629 | ],[ | |
1630 | AC_MSG_RESULT(no) | |
1631 | ]) | |
1632 | EXTRA_KCFLAGS="$tmp_flags" | |
1633 | ]) |