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