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