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