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