]> git.proxmox.com Git - zfsonlinux.git/blame - spl-patches/0007-Split-spl-build.m4.patch
bump ZFS version to 0.7.7-pve2~bpo9
[zfsonlinux.git] / spl-patches / 0007-Split-spl-build.m4.patch
CommitLineData
edf5051c
FG
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Brian Behlendorf <behlendorf1@llnl.gov>
3Date: Wed, 7 Feb 2018 11:50:24 -0800
4Subject: [PATCH] Split spl-build.m4
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Split the kernel interface configure checks in to seperate m4
10macro files. This is intended to facilitate moving the spl
11source code in to the zfs repository.
12
13Reviewed-by: Tony Hutter <hutter2@llnl.gov>
14Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
15Closes #682
16(cherry picked from commit 6902e2839f7efe32dab97980aa4b4c151bdb4f5e)
17Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
18---
19 config/kernel-ctl-table-name.m4 | 18 +
20 config/kernel-fallocate.m4 | 68 +++
21 config/kernel-group-info.m4 | 21 +
22 config/kernel-inode-lock.m4 | 23 +
23 config/kernel-kmem-cache.m4 | 72 +++
24 config/kernel-kuidgid.m4 | 28 +
25 config/kernel-pde-data.m4 | 17 +
26 config/kernel-rw.m4 | 57 +++
27 config/kernel-rwsem.m4 | 75 +++
28 config/kernel-sched.m4 | 56 ++
29 config/kernel-set-fs-pwd.m4 | 39 ++
30 config/kernel-shrinker.m4 | 125 +++++
31 config/kernel-spinlock.m4 | 24 +
32 config/kernel-timer.m4 | 32 ++
33 config/kernel-trim-unused-symbols.m4 | 19 +
34 config/kernel-truncate-range.m4 | 19 +
35 config/kernel-urange-sleep.m4 | 21 +
36 config/kernel-vfs-fsync.m4 | 17 +
37 config/kernel-vfs-getattr.m4 | 62 +++
38 config/kernel-wait.m4 | 76 +++
39 config/kernel-zlib.m4 | 63 +++
40 config/spl-build.m4 | 956 -----------------------------------
41 22 files changed, 932 insertions(+), 956 deletions(-)
42 create mode 100644 config/kernel-ctl-table-name.m4
43 create mode 100644 config/kernel-fallocate.m4
44 create mode 100644 config/kernel-group-info.m4
45 create mode 100644 config/kernel-inode-lock.m4
46 create mode 100644 config/kernel-kmem-cache.m4
47 create mode 100644 config/kernel-kuidgid.m4
48 create mode 100644 config/kernel-pde-data.m4
49 create mode 100644 config/kernel-rw.m4
50 create mode 100644 config/kernel-rwsem.m4
51 create mode 100644 config/kernel-sched.m4
52 create mode 100644 config/kernel-set-fs-pwd.m4
53 create mode 100644 config/kernel-shrinker.m4
54 create mode 100644 config/kernel-spinlock.m4
55 create mode 100644 config/kernel-timer.m4
56 create mode 100644 config/kernel-trim-unused-symbols.m4
57 create mode 100644 config/kernel-truncate-range.m4
58 create mode 100644 config/kernel-urange-sleep.m4
59 create mode 100644 config/kernel-vfs-fsync.m4
60 create mode 100644 config/kernel-vfs-getattr.m4
61 create mode 100644 config/kernel-wait.m4
62 create mode 100644 config/kernel-zlib.m4
63
64diff --git a/config/kernel-ctl-table-name.m4 b/config/kernel-ctl-table-name.m4
65new file mode 100644
66index 0000000..8dd2e77
67--- /dev/null
68+++ b/config/kernel-ctl-table-name.m4
69@@ -0,0 +1,18 @@
70+dnl #
71+dnl # 2.6.33 API change,
72+dnl # Removed .ctl_name from struct ctl_table.
73+dnl #
74+AC_DEFUN([SPL_AC_CTL_NAME], [
75+ AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
76+ SPL_LINUX_TRY_COMPILE([
77+ #include <linux/sysctl.h>
78+ ],[
79+ struct ctl_table ctl __attribute__ ((unused));
80+ ctl.ctl_name = 0;
81+ ],[
82+ AC_MSG_RESULT(yes)
83+ AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
84+ ],[
85+ AC_MSG_RESULT(no)
86+ ])
87+])
88diff --git a/config/kernel-fallocate.m4 b/config/kernel-fallocate.m4
89new file mode 100644
90index 0000000..b8c82f4
91--- /dev/null
92+++ b/config/kernel-fallocate.m4
93@@ -0,0 +1,68 @@
94+dnl #
95+dnl # Linux 2.6.38 - 3.x API
96+dnl #
97+AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
98+ AC_MSG_CHECKING([whether fops->fallocate() exists])
99+ SPL_LINUX_TRY_COMPILE([
100+ #include <linux/fs.h>
101+ ],[
102+ long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
103+ struct file_operations fops __attribute__ ((unused)) = {
104+ .fallocate = fallocate,
105+ };
106+ ],[
107+ AC_MSG_RESULT(yes)
108+ AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
109+ ],[
110+ AC_MSG_RESULT(no)
111+ ])
112+])
113+dnl #
114+dnl # Linux 2.6.x - 2.6.37 API
115+dnl #
116+AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
117+ AC_MSG_CHECKING([whether iops->fallocate() exists])
118+ SPL_LINUX_TRY_COMPILE([
119+ #include <linux/fs.h>
120+ ],[
121+ long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
122+ struct inode_operations fops __attribute__ ((unused)) = {
123+ .fallocate = fallocate,
124+ };
125+ ],[
126+ AC_MSG_RESULT(yes)
127+ AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
128+ ],[
129+ AC_MSG_RESULT(no)
130+ ])
131+])
132+
133+dnl #
134+dnl # PaX Linux 2.6.38 - 3.x API
135+dnl #
136+AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
137+ AC_MSG_CHECKING([whether fops->fallocate() exists])
138+ SPL_LINUX_TRY_COMPILE([
139+ #include <linux/fs.h>
140+ ],[
141+ long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
142+ struct file_operations_no_const fops __attribute__ ((unused)) = {
143+ .fallocate = fallocate,
144+ };
145+ ],[
146+ AC_MSG_RESULT(yes)
147+ AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
148+ ],[
149+ AC_MSG_RESULT(no)
150+ ])
151+])
152+
153+dnl #
154+dnl # The fallocate callback was moved from the inode_operations
155+dnl # structure to the file_operations structure.
156+dnl #
157+AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
158+ SPL_AC_KERNEL_FILE_FALLOCATE
159+ SPL_AC_KERNEL_INODE_FALLOCATE
160+ SPL_AC_PAX_KERNEL_FILE_FALLOCATE
161+])
162diff --git a/config/kernel-group-info.m4 b/config/kernel-group-info.m4
163new file mode 100644
164index 0000000..4db2bba
165--- /dev/null
166+++ b/config/kernel-group-info.m4
167@@ -0,0 +1,21 @@
168+dnl #
169+dnl # 4.9 API change
170+dnl # group_info changed from 2d array via >blocks to 1d array via ->gid
171+dnl #
172+AC_DEFUN([SPL_AC_GROUP_INFO_GID], [
173+ AC_MSG_CHECKING([whether group_info->gid exists])
174+ tmp_flags="$EXTRA_KCFLAGS"
175+ EXTRA_KCFLAGS="-Werror"
176+ SPL_LINUX_TRY_COMPILE([
177+ #include <linux/cred.h>
178+ ],[
179+ struct group_info *gi = groups_alloc(1);
180+ gi->gid[0] = KGIDT_INIT(0);
181+ ],[
182+ AC_MSG_RESULT(yes)
183+ AC_DEFINE(HAVE_GROUP_INFO_GID, 1, [group_info->gid exists])
184+ ],[
185+ AC_MSG_RESULT(no)
186+ ])
187+ EXTRA_KCFLAGS="$tmp_flags"
188+])
189diff --git a/config/kernel-inode-lock.m4 b/config/kernel-inode-lock.m4
190new file mode 100644
191index 0000000..2cc06a5
192--- /dev/null
193+++ b/config/kernel-inode-lock.m4
194@@ -0,0 +1,23 @@
195+dnl #
196+dnl # 4.7 API change
197+dnl # i_mutex is changed to i_rwsem. Instead of directly using
198+dnl # i_mutex/i_rwsem, we should use inode_lock() and inode_lock_shared()
199+dnl # We test inode_lock_shared because inode_lock is introduced earlier.
200+dnl #
201+AC_DEFUN([SPL_AC_INODE_LOCK], [
202+ AC_MSG_CHECKING([whether inode_lock_shared() exists])
203+ tmp_flags="$EXTRA_KCFLAGS"
204+ EXTRA_KCFLAGS="-Werror"
205+ SPL_LINUX_TRY_COMPILE([
206+ #include <linux/fs.h>
207+ ],[
208+ struct inode *inode = NULL;
209+ inode_lock_shared(inode);
210+ ],[
211+ AC_MSG_RESULT(yes)
212+ AC_DEFINE(HAVE_INODE_LOCK_SHARED, 1, [yes])
213+ ],[
214+ AC_MSG_RESULT(no)
215+ ])
216+ EXTRA_KCFLAGS="$tmp_flags"
217+])
218diff --git a/config/kernel-kmem-cache.m4 b/config/kernel-kmem-cache.m4
219new file mode 100644
220index 0000000..50a7fdb
221--- /dev/null
222+++ b/config/kernel-kmem-cache.m4
223@@ -0,0 +1,72 @@
224+dnl #
225+dnl # 2.6.35 API change,
226+dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
227+dnl # private allocation flags which are applied when allocating a new slab
228+dnl # in kmem_getpages(). Unfortunately there is no public API for setting
229+dnl # non-default flags.
230+dnl #
231+AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
232+ AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
233+ SPL_LINUX_TRY_COMPILE([
234+ #include <linux/slab.h>
235+ ],[
236+ struct kmem_cache cachep __attribute__ ((unused));
237+ cachep.allocflags = GFP_KERNEL;
238+ ],[
239+ AC_MSG_RESULT(yes)
240+ AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
241+ [struct kmem_cache has allocflags])
242+ ],[
243+ AC_MSG_RESULT(no)
244+
245+ AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
246+ SPL_LINUX_TRY_COMPILE([
247+ #include <linux/slab.h>
248+ ],[
249+ struct kmem_cache cachep __attribute__ ((unused));
250+ cachep.gfpflags = GFP_KERNEL;
251+ ],[
252+ AC_MSG_RESULT(yes)
253+ AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
254+ [struct kmem_cache has gfpflags])
255+ ],[
256+ AC_MSG_RESULT(no)
257+ ])
258+ ])
259+])
260+
261+dnl #
262+dnl # grsecurity API change,
263+dnl # kmem_cache_create() with SLAB_USERCOPY flag replaced by
264+dnl # kmem_cache_create_usercopy().
265+dnl #
266+AC_DEFUN([SPL_AC_KMEM_CACHE_CREATE_USERCOPY], [
267+ AC_MSG_CHECKING([whether kmem_cache_create_usercopy() exists])
268+ tmp_flags="$EXTRA_KCFLAGS"
269+ EXTRA_KCFLAGS="-Werror"
270+ SPL_LINUX_TRY_COMPILE([
271+ #include <linux/slab.h>
272+ static void ctor(void *foo)
273+ {
274+ // fake ctor
275+ }
276+ ],[
277+ struct kmem_cache *skc_linux_cache;
278+ const char *name = "test";
279+ size_t size = 4096;
280+ size_t align = 8;
281+ unsigned long flags = 0;
282+ size_t useroffset = 0;
283+ size_t usersize = size - useroffset;
284+
285+ skc_linux_cache = kmem_cache_create_usercopy(
286+ name, size, align, flags, useroffset, usersize, ctor);
287+ ],[
288+ AC_MSG_RESULT(yes)
289+ AC_DEFINE(HAVE_KMEM_CACHE_CREATE_USERCOPY, 1,
290+ [kmem_cache_create_usercopy() exists])
291+ ],[
292+ AC_MSG_RESULT(no)
293+ ])
294+ EXTRA_KCFLAGS="$tmp_flags"
295+])
296diff --git a/config/kernel-kuidgid.m4 b/config/kernel-kuidgid.m4
297new file mode 100644
298index 0000000..47d1937
299--- /dev/null
300+++ b/config/kernel-kuidgid.m4
301@@ -0,0 +1,28 @@
302+dnl #
303+dnl # User namespaces, use kuid_t in place of uid_t
304+dnl # where available. Not strictly a user namespaces thing
305+dnl # but it should prevent surprises
306+dnl #
307+AC_DEFUN([SPL_AC_KUIDGID_T], [
308+ AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
309+ SPL_LINUX_TRY_COMPILE([
310+ #include <linux/uidgid.h>
311+ ], [
312+ kuid_t userid = KUIDT_INIT(0);
313+ kgid_t groupid = KGIDT_INIT(0);
314+ ],[
315+ SPL_LINUX_TRY_COMPILE([
316+ #include <linux/uidgid.h>
317+ ], [
318+ kuid_t userid = 0;
319+ kgid_t groupid = 0;
320+ ],[
321+ AC_MSG_RESULT(yes; optional)
322+ ],[
323+ AC_MSG_RESULT(yes; mandatory)
324+ AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
325+ ])
326+ ],[
327+ AC_MSG_RESULT(no)
328+ ])
329+])
330diff --git a/config/kernel-pde-data.m4 b/config/kernel-pde-data.m4
331new file mode 100644
332index 0000000..6aa5765
333--- /dev/null
334+++ b/config/kernel-pde-data.m4
335@@ -0,0 +1,17 @@
336+dnl #
337+dnl # 3.10 API change,
338+dnl # PDE is replaced by PDE_DATA
339+dnl #
340+AC_DEFUN([SPL_AC_PDE_DATA], [
341+ AC_MSG_CHECKING([whether PDE_DATA() is available])
342+ SPL_LINUX_TRY_COMPILE_SYMBOL([
343+ #include <linux/proc_fs.h>
344+ ], [
345+ PDE_DATA(NULL);
346+ ], [PDE_DATA], [], [
347+ AC_MSG_RESULT(yes)
348+ AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
349+ ],[
350+ AC_MSG_RESULT(no)
351+ ])
352+])
353diff --git a/config/kernel-rw.m4 b/config/kernel-rw.m4
354new file mode 100644
355index 0000000..23c14b7
356--- /dev/null
357+++ b/config/kernel-rw.m4
358@@ -0,0 +1,57 @@
359+dnl #
360+dnl # 4.14 API change
361+dnl # kernel_write() which was introduced in 3.9 was updated to take
362+dnl # the offset as a pointer which is needed by vn_rdwr().
363+dnl #
364+AC_DEFUN([SPL_AC_KERNEL_WRITE], [
365+ AC_MSG_CHECKING([whether kernel_write() takes loff_t pointer])
366+ tmp_flags="$EXTRA_KCFLAGS"
367+ EXTRA_KCFLAGS="-Werror"
368+ SPL_LINUX_TRY_COMPILE([
369+ #include <linux/fs.h>
370+ ],[
371+ struct file *file = NULL;
372+ const void *buf = NULL;
373+ size_t count = 0;
374+ loff_t *pos = NULL;
375+ ssize_t ret;
376+
377+ ret = kernel_write(file, buf, count, pos);
378+ ],[
379+ AC_MSG_RESULT(yes)
380+ AC_DEFINE(HAVE_KERNEL_WRITE_PPOS, 1,
381+ [kernel_write() take loff_t pointer])
382+ ],[
383+ AC_MSG_RESULT(no)
384+ ])
385+ EXTRA_KCFLAGS="$tmp_flags"
386+])
387+
388+dnl #
389+dnl # 4.14 API change
390+dnl # kernel_read() which has existed for forever was updated to take
391+dnl # the offset as a pointer which is needed by vn_rdwr().
392+dnl #
393+AC_DEFUN([SPL_AC_KERNEL_READ], [
394+ AC_MSG_CHECKING([whether kernel_read() takes loff_t pointer])
395+ tmp_flags="$EXTRA_KCFLAGS"
396+ EXTRA_KCFLAGS="-Werror"
397+ SPL_LINUX_TRY_COMPILE([
398+ #include <linux/fs.h>
399+ ],[
400+ struct file *file = NULL;
401+ void *buf = NULL;
402+ size_t count = 0;
403+ loff_t *pos = NULL;
404+ ssize_t ret;
405+
406+ ret = kernel_read(file, buf, count, pos);
407+ ],[
408+ AC_MSG_RESULT(yes)
409+ AC_DEFINE(HAVE_KERNEL_READ_PPOS, 1,
410+ [kernel_read() take loff_t pointer])
411+ ],[
412+ AC_MSG_RESULT(no)
413+ ])
414+ EXTRA_KCFLAGS="$tmp_flags"
415+])
416diff --git a/config/kernel-rwsem.m4 b/config/kernel-rwsem.m4
417new file mode 100644
418index 0000000..aee20ae
419--- /dev/null
420+++ b/config/kernel-rwsem.m4
421@@ -0,0 +1,75 @@
422+dnl #
423+dnl # 3.1 API Change
424+dnl #
425+dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
426+dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
427+dnl #
428+AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
429+ AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
430+ tmp_flags="$EXTRA_KCFLAGS"
431+ EXTRA_KCFLAGS="-Werror"
432+ SPL_LINUX_TRY_COMPILE([
433+ #include <linux/rwsem.h>
434+ ],[
435+ struct rw_semaphore dummy_semaphore __attribute__ ((unused));
436+ raw_spinlock_t dummy_lock __attribute__ ((unused)) =
437+ __RAW_SPIN_LOCK_INITIALIZER(dummy_lock);
438+ dummy_semaphore.wait_lock = dummy_lock;
439+ ],[
440+ AC_MSG_RESULT(yes)
441+ AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
442+ [struct rw_semaphore member wait_lock is raw_spinlock_t])
443+ ],[
444+ AC_MSG_RESULT(no)
445+ ])
446+ EXTRA_KCFLAGS="$tmp_flags"
447+])
448+
449+dnl #
450+dnl # 3.16 API Change
451+dnl #
452+dnl # rwsem-spinlock "->activity" changed to "->count"
453+dnl #
454+AC_DEFUN([SPL_AC_RWSEM_ACTIVITY], [
455+ AC_MSG_CHECKING([whether struct rw_semaphore has member activity])
456+ tmp_flags="$EXTRA_KCFLAGS"
457+ EXTRA_KCFLAGS="-Werror"
458+ SPL_LINUX_TRY_COMPILE([
459+ #include <linux/rwsem.h>
460+ ],[
461+ struct rw_semaphore dummy_semaphore __attribute__ ((unused));
462+ dummy_semaphore.activity = 0;
463+ ],[
464+ AC_MSG_RESULT(yes)
465+ AC_DEFINE(HAVE_RWSEM_ACTIVITY, 1,
466+ [struct rw_semaphore has member activity])
467+ ],[
468+ AC_MSG_RESULT(no)
469+ ])
470+ EXTRA_KCFLAGS="$tmp_flags"
471+])
472+
473+dnl #
474+dnl # 4.8 API Change
475+dnl #
476+dnl # rwsem "->count" changed to atomic_long_t type
477+dnl #
478+AC_DEFUN([SPL_AC_RWSEM_ATOMIC_LONG_COUNT], [
479+ AC_MSG_CHECKING(
480+ [whether struct rw_semaphore has atomic_long_t member count])
481+ tmp_flags="$EXTRA_KCFLAGS"
482+ EXTRA_KCFLAGS="-Werror"
483+ SPL_LINUX_TRY_COMPILE([
484+ #include <linux/rwsem.h>
485+ ],[
486+ DECLARE_RWSEM(dummy_semaphore);
487+ (void) atomic_long_read(&dummy_semaphore.count);
488+ ],[
489+ AC_MSG_RESULT(yes)
490+ AC_DEFINE(HAVE_RWSEM_ATOMIC_LONG_COUNT, 1,
491+ [struct rw_semaphore has atomic_long_t member count])
492+ ],[
493+ AC_MSG_RESULT(no)
494+ ])
495+ EXTRA_KCFLAGS="$tmp_flags"
496+])
497diff --git a/config/kernel-sched.m4 b/config/kernel-sched.m4
498new file mode 100644
499index 0000000..5ae2167
500--- /dev/null
501+++ b/config/kernel-sched.m4
502@@ -0,0 +1,56 @@
503+dnl #
504+dnl # 3.9 API change,
505+dnl # Moved things from linux/sched.h to linux/sched/rt.h
506+dnl #
507+AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
508+ [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
509+ SPL_LINUX_TRY_COMPILE([
510+ #include <linux/sched.h>
511+ #include <linux/sched/rt.h>
512+ ],[
513+ return 0;
514+ ],[
515+ AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
516+ AC_MSG_RESULT(yes)
517+ ],[
518+ AC_MSG_RESULT(no)
519+ ])
520+])
521+
522+dnl #
523+dnl # 4.11 API change,
524+dnl # Moved things from linux/sched.h to linux/sched/signal.h
525+dnl #
526+AC_DEFUN([SPL_AC_SCHED_SIGNAL_HEADER],
527+ [AC_MSG_CHECKING([whether header linux/sched/signal.h exists])
528+ SPL_LINUX_TRY_COMPILE([
529+ #include <linux/sched.h>
530+ #include <linux/sched/signal.h>
531+ ],[
532+ return 0;
533+ ],[
534+ AC_DEFINE(HAVE_SCHED_SIGNAL_HEADER, 1, [linux/sched/signal.h exists])
535+ AC_MSG_RESULT(yes)
536+ ],[
537+ AC_MSG_RESULT(no)
538+ ])
539+])
540+dnl #
541+dnl # 3.19 API change
542+dnl # The io_schedule_timeout() function is present in all 2.6.32 kernels
543+dnl # but it was not exported until Linux 3.19. The RHEL 7.x kernels which
544+dnl # are based on a 3.10 kernel do export this symbol.
545+dnl #
546+AC_DEFUN([SPL_AC_IO_SCHEDULE_TIMEOUT], [
547+ AC_MSG_CHECKING([whether io_schedule_timeout() is available])
548+ SPL_LINUX_TRY_COMPILE_SYMBOL([
549+ #include <linux/sched.h>
550+ ], [
551+ (void) io_schedule_timeout(1);
552+ ], [io_schedule_timeout], [], [
553+ AC_MSG_RESULT(yes)
554+ AC_DEFINE(HAVE_IO_SCHEDULE_TIMEOUT, 1, [yes])
555+ ],[
556+ AC_MSG_RESULT(no)
557+ ])
558+])
559diff --git a/config/kernel-set-fs-pwd.m4 b/config/kernel-set-fs-pwd.m4
560new file mode 100644
561index 0000000..849e7e6
562--- /dev/null
563+++ b/config/kernel-set-fs-pwd.m4
564@@ -0,0 +1,39 @@
565+dnl #
566+dnl # 3.9 API change
567+dnl # set_fs_pwd takes const struct path *
568+dnl #
569+AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
570+ tmp_flags="$EXTRA_KCFLAGS"
571+ EXTRA_KCFLAGS="-Werror"
572+ [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
573+ SPL_LINUX_TRY_COMPILE([
574+ #include <linux/spinlock.h>
575+ #include <linux/fs_struct.h>
576+ #include <linux/path.h>
577+ void (*const set_fs_pwd_func)
578+ (struct fs_struct *, const struct path *)
579+ = set_fs_pwd;
580+ ],[
581+ return 0;
582+ ],[
583+ AC_MSG_RESULT(yes)
584+ AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
585+ [set_fs_pwd() needs const path *])
586+ ],[
587+ SPL_LINUX_TRY_COMPILE([
588+ #include <linux/spinlock.h>
589+ #include <linux/fs_struct.h>
590+ #include <linux/path.h>
591+ void (*const set_fs_pwd_func)
592+ (struct fs_struct *, struct path *)
593+ = set_fs_pwd;
594+ ],[
595+ return 0;
596+ ],[
597+ AC_MSG_RESULT(no)
598+ ],[
599+ AC_MSG_ERROR(unknown)
600+ ])
601+ ])
602+ EXTRA_KCFLAGS="$tmp_flags"
603+])
604diff --git a/config/kernel-shrinker.m4 b/config/kernel-shrinker.m4
605new file mode 100644
606index 0000000..6fc9b54
607--- /dev/null
608+++ b/config/kernel-shrinker.m4
609@@ -0,0 +1,125 @@
610+AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
611+ tmp_flags="$EXTRA_KCFLAGS"
612+ EXTRA_KCFLAGS="-Werror"
613+ dnl #
614+ dnl # 2.6.23 to 2.6.34 API change
615+ dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
616+ dnl #
617+ AC_MSG_CHECKING([whether old 2-argument shrinker exists])
618+ SPL_LINUX_TRY_COMPILE([
619+ #include <linux/mm.h>
620+
621+ int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
622+ ],[
623+ struct shrinker cache_shrinker = {
624+ .shrink = shrinker_cb,
625+ .seeks = DEFAULT_SEEKS,
626+ };
627+ register_shrinker(&cache_shrinker);
628+ ],[
629+ AC_MSG_RESULT(yes)
630+ AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
631+ [old shrinker callback wants 2 args])
632+ ],[
633+ AC_MSG_RESULT(no)
634+ dnl #
635+ dnl # 2.6.35 - 2.6.39 API change
636+ dnl # ->shrink(struct shrinker *,
637+ dnl # int nr_to_scan, gfp_t gfp_mask)
638+ dnl #
639+ AC_MSG_CHECKING([whether old 3-argument shrinker exists])
640+ SPL_LINUX_TRY_COMPILE([
641+ #include <linux/mm.h>
642+
643+ int shrinker_cb(struct shrinker *, int nr_to_scan,
644+ gfp_t gfp_mask);
645+ ],[
646+ struct shrinker cache_shrinker = {
647+ .shrink = shrinker_cb,
648+ .seeks = DEFAULT_SEEKS,
649+ };
650+ register_shrinker(&cache_shrinker);
651+ ],[
652+ AC_MSG_RESULT(yes)
653+ AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
654+ [old shrinker callback wants 3 args])
655+ ],[
656+ AC_MSG_RESULT(no)
657+ dnl #
658+ dnl # 3.0 - 3.11 API change
659+ dnl # ->shrink(struct shrinker *,
660+ dnl # struct shrink_control *sc)
661+ dnl #
662+ AC_MSG_CHECKING(
663+ [whether new 2-argument shrinker exists])
664+ SPL_LINUX_TRY_COMPILE([
665+ #include <linux/mm.h>
666+
667+ int shrinker_cb(struct shrinker *,
668+ struct shrink_control *sc);
669+ ],[
670+ struct shrinker cache_shrinker = {
671+ .shrink = shrinker_cb,
672+ .seeks = DEFAULT_SEEKS,
673+ };
674+ register_shrinker(&cache_shrinker);
675+ ],[
676+ AC_MSG_RESULT(yes)
677+ AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
678+ [new shrinker callback wants 2 args])
679+ ],[
680+ AC_MSG_RESULT(no)
681+ dnl #
682+ dnl # 3.12 API change,
683+ dnl # ->shrink() is logically split in to
684+ dnl # ->count_objects() and ->scan_objects()
685+ dnl #
686+ AC_MSG_CHECKING(
687+ [whether ->count_objects callback exists])
688+ SPL_LINUX_TRY_COMPILE([
689+ #include <linux/mm.h>
690+
691+ unsigned long shrinker_cb(
692+ struct shrinker *,
693+ struct shrink_control *sc);
694+ ],[
695+ struct shrinker cache_shrinker = {
696+ .count_objects = shrinker_cb,
697+ .scan_objects = shrinker_cb,
698+ .seeks = DEFAULT_SEEKS,
699+ };
700+ register_shrinker(&cache_shrinker);
701+ ],[
702+ AC_MSG_RESULT(yes)
703+ AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
704+ 1, [->count_objects exists])
705+ ],[
706+ AC_MSG_ERROR(error)
707+ ])
708+ ])
709+ ])
710+ ])
711+ EXTRA_KCFLAGS="$tmp_flags"
712+])
713+
714+dnl #
715+dnl # 2.6.39 API change,
716+dnl # Shrinker adjust to use common shrink_control structure.
717+dnl #
718+AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
719+ AC_MSG_CHECKING([whether struct shrink_control exists])
720+ SPL_LINUX_TRY_COMPILE([
721+ #include <linux/mm.h>
722+ ],[
723+ struct shrink_control sc __attribute__ ((unused));
724+
725+ sc.nr_to_scan = 0;
726+ sc.gfp_mask = GFP_KERNEL;
727+ ],[
728+ AC_MSG_RESULT(yes)
729+ AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
730+ [struct shrink_control exists])
731+ ],[
732+ AC_MSG_RESULT(no)
733+ ])
734+])
735diff --git a/config/kernel-spinlock.m4 b/config/kernel-spinlock.m4
736new file mode 100644
737index 0000000..136262d
738--- /dev/null
739+++ b/config/kernel-spinlock.m4
740@@ -0,0 +1,24 @@
741+dnl #
742+dnl # 2.6.36 API change,
743+dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
744+dnl # a spinlock_t to improve the fastpath performance.
745+dnl #
746+AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
747+ AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
748+ tmp_flags="$EXTRA_KCFLAGS"
749+ EXTRA_KCFLAGS="-Werror"
750+ SPL_LINUX_TRY_COMPILE([
751+ #include <linux/sched.h>
752+ #include <linux/fs_struct.h>
753+ ],[
754+ static struct fs_struct fs;
755+ spin_lock_init(&fs.lock);
756+ ],[
757+ AC_MSG_RESULT(yes)
758+ AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
759+ [struct fs_struct uses spinlock_t])
760+ ],[
761+ AC_MSG_RESULT(no)
762+ ])
763+ EXTRA_KCFLAGS="$tmp_flags"
764+])
765diff --git a/config/kernel-timer.m4 b/config/kernel-timer.m4
766new file mode 100644
767index 0000000..93b5158
768--- /dev/null
769+++ b/config/kernel-timer.m4
770@@ -0,0 +1,32 @@
771+dnl #
772+dnl # 4.15 API change
773+dnl # https://lkml.org/lkml/2017/11/25/90
774+dnl # Check if timer_list.func get passed a timer_list or an unsigned long
775+dnl # (older kernels). Also sanity check the from_timer() and timer_setup()
776+dnl # macros are available as well, since they will be used in the same newer
777+dnl # kernels that support the new timer_list.func signature.
778+dnl #
779+AC_DEFUN([SPL_AC_KERNEL_TIMER_FUNCTION_TIMER_LIST], [
780+ AC_MSG_CHECKING([whether timer_list.function gets a timer_list])
781+ tmp_flags="$EXTRA_KCFLAGS"
782+ EXTRA_KCFLAGS="-Werror"
783+ SPL_LINUX_TRY_COMPILE([
784+ #include <linux/timer.h>
785+ void task_expire(struct timer_list *tl) {}
786+ ],[
787+ #ifndef from_timer
788+ #error "No from_timer() macro"
789+ #endif
790+
791+ struct timer_list timer;
792+ timer.function = task_expire;
793+ timer_setup(&timer, NULL, 0);
794+ ],[
795+ AC_MSG_RESULT(yes)
796+ AC_DEFINE(HAVE_KERNEL_TIMER_FUNCTION_TIMER_LIST, 1,
797+ [timer_list.function gets a timer_list])
798+ ],[
799+ AC_MSG_RESULT(no)
800+ ])
801+ EXTRA_KCFLAGS="$tmp_flags"
802+])
803diff --git a/config/kernel-trim-unused-symbols.m4 b/config/kernel-trim-unused-symbols.m4
804new file mode 100644
805index 0000000..d1ac2f3
806--- /dev/null
807+++ b/config/kernel-trim-unused-symbols.m4
808@@ -0,0 +1,19 @@
809+dnl #
810+dnl # config trim unused symbols,
811+dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS DISABLED.
812+dnl #
813+AC_DEFUN([SPL_AC_CONFIG_TRIM_UNUSED_KSYMS], [
814+ AC_MSG_CHECKING([whether CONFIG_TRIM_UNUSED_KSYM is disabled])
815+ SPL_LINUX_TRY_COMPILE([
816+ #if defined(CONFIG_TRIM_UNUSED_KSYMS)
817+ #error CONFIG_TRIM_UNUSED_KSYMS not defined
818+ #endif
819+ ],[ ],[
820+ AC_MSG_RESULT([yes])
821+ ],[
822+ AC_MSG_RESULT([no])
823+ AC_MSG_ERROR([
824+ *** This kernel has unused symbols trimming enabled, please disable.
825+ *** Rebuild the kernel with CONFIG_TRIM_UNUSED_KSYMS=n set.])
826+ ])
827+])
828diff --git a/config/kernel-truncate-range.m4 b/config/kernel-truncate-range.m4
829new file mode 100644
830index 0000000..4b1600b
831--- /dev/null
832+++ b/config/kernel-truncate-range.m4
833@@ -0,0 +1,19 @@
834+dnl #
835+dnl # 3.5 API change,
836+dnl # inode_operations.truncate_range removed
837+dnl #
838+AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
839+ AC_MSG_CHECKING([whether truncate_range() inode operation is available])
840+ SPL_LINUX_TRY_COMPILE([
841+ #include <linux/fs.h>
842+ ],[
843+ struct inode_operations ops;
844+ ops.truncate_range = NULL;
845+ ],[
846+ AC_MSG_RESULT(yes)
847+ AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
848+ [truncate_range() inode operation is available])
849+ ],[
850+ AC_MSG_RESULT(no)
851+ ])
852+])
853diff --git a/config/kernel-urange-sleep.m4 b/config/kernel-urange-sleep.m4
854new file mode 100644
855index 0000000..85beca6
856--- /dev/null
857+++ b/config/kernel-urange-sleep.m4
858@@ -0,0 +1,21 @@
859+dnl #
860+dnl # 2.6.36 API compatibility.
861+dnl # Added usleep_range timer.
862+dnl # usleep_range is a finer precision implementation of msleep
863+dnl # designed to be a drop-in replacement for udelay where a precise
864+dnl # sleep / busy-wait is unnecessary.
865+dnl #
866+AC_DEFUN([SPL_AC_USLEEP_RANGE], [
867+ AC_MSG_CHECKING([whether usleep_range() is available])
868+ SPL_LINUX_TRY_COMPILE([
869+ #include <linux/delay.h>
870+ ],[
871+ usleep_range(0, 0);
872+ ],[
873+ AC_MSG_RESULT(yes)
874+ AC_DEFINE(HAVE_USLEEP_RANGE, 1,
875+ [usleep_range is available])
876+ ],[
877+ AC_MSG_RESULT(no)
878+ ])
879+])
880diff --git a/config/kernel-vfs-fsync.m4 b/config/kernel-vfs-fsync.m4
881new file mode 100644
882index 0000000..3c42bf1
883--- /dev/null
884+++ b/config/kernel-vfs-fsync.m4
885@@ -0,0 +1,17 @@
886+dnl #
887+dnl # 2.6.35 API change,
888+dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
889+dnl #
890+AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
891+ AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
892+ SPL_LINUX_TRY_COMPILE([
893+ #include <linux/fs.h>
894+ ],[
895+ vfs_fsync(NULL, 0);
896+ ],[
897+ AC_MSG_RESULT(yes)
898+ AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
899+ ],[
900+ AC_MSG_RESULT(no)
901+ ])
902+])
903diff --git a/config/kernel-vfs-getattr.m4 b/config/kernel-vfs-getattr.m4
904new file mode 100644
905index 0000000..7772cb5
906--- /dev/null
907+++ b/config/kernel-vfs-getattr.m4
908@@ -0,0 +1,62 @@
909+dnl #
910+dnl # 4.11 API, a528d35e@torvalds/linux
911+dnl # vfs_getattr(const struct path *p, struct kstat *s, u32 m, unsigned int f)
912+dnl #
913+AC_DEFUN([SPL_AC_4ARGS_VFS_GETATTR], [
914+ AC_MSG_CHECKING([whether vfs_getattr() wants 4 args])
915+ SPL_LINUX_TRY_COMPILE([
916+ #include <linux/fs.h>
917+ ],[
918+ vfs_getattr((const struct path *)NULL,
919+ (struct kstat *)NULL,
920+ (u32)0,
921+ (unsigned int)0);
922+ ],[
923+ AC_MSG_RESULT(yes)
924+ AC_DEFINE(HAVE_4ARGS_VFS_GETATTR, 1,
925+ [vfs_getattr wants 4 args])
926+ ],[
927+ AC_MSG_RESULT(no)
928+ ])
929+])
930+
931+dnl #
932+dnl # 3.9 API
933+dnl # vfs_getattr(struct path *p, struct kstat *s)
934+dnl #
935+AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
936+ AC_MSG_CHECKING([whether vfs_getattr() wants 2 args])
937+ SPL_LINUX_TRY_COMPILE([
938+ #include <linux/fs.h>
939+ ],[
940+ vfs_getattr((struct path *) NULL,
941+ (struct kstat *)NULL);
942+ ],[
943+ AC_MSG_RESULT(yes)
944+ AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
945+ [vfs_getattr wants 2 args])
946+ ],[
947+ AC_MSG_RESULT(no)
948+ ])
949+])
950+
951+dnl #
952+dnl # <3.9 API
953+dnl # vfs_getattr(struct vfsmount *v, struct dentry *d, struct kstat *k)
954+dnl #
955+AC_DEFUN([SPL_AC_3ARGS_VFS_GETATTR], [
956+ AC_MSG_CHECKING([whether vfs_getattr() wants 3 args])
957+ SPL_LINUX_TRY_COMPILE([
958+ #include <linux/fs.h>
959+ ],[
960+ vfs_getattr((struct vfsmount *)NULL,
961+ (struct dentry *)NULL,
962+ (struct kstat *)NULL);
963+ ],[
964+ AC_MSG_RESULT(yes)
965+ AC_DEFINE(HAVE_3ARGS_VFS_GETATTR, 1,
966+ [vfs_getattr wants 3 args])
967+ ],[
968+ AC_MSG_RESULT(no)
969+ ])
970+])
971diff --git a/config/kernel-wait.m4 b/config/kernel-wait.m4
972new file mode 100644
973index 0000000..5f718a1
974--- /dev/null
975+++ b/config/kernel-wait.m4
976@@ -0,0 +1,76 @@
977+dnl #
978+dnl # 3.17 API change,
979+dnl # wait_on_bit() no longer requires an action argument. The former
980+dnl # "wait_on_bit" interface required an 'action' function to be provided
981+dnl # which does the actual waiting. There were over 20 such functions in the
982+dnl # kernel, many of them identical, though most cases can be satisfied by one
983+dnl # of just two functions: one which uses io_schedule() and one which just
984+dnl # uses schedule(). This API change was made to consolidate all of those
985+dnl # redundant wait functions.
986+dnl #
987+AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
988+ AC_MSG_CHECKING([whether wait_on_bit() takes an action])
989+ SPL_LINUX_TRY_COMPILE([
990+ #include <linux/wait.h>
991+ ],[
992+ int (*action)(void *) = NULL;
993+ wait_on_bit(NULL, 0, action, 0);
994+ ],[
995+ AC_MSG_RESULT(yes)
996+ AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])
997+ ],[
998+ AC_MSG_RESULT(no)
999+ ])
1000+])
1001+dnl #
1002+dnl # 4.13 API change
1003+dnl # Renamed struct wait_queue -> struct wait_queue_entry.
1004+dnl #
1005+AC_DEFUN([SPL_AC_WAIT_QUEUE_ENTRY_T], [
1006+ AC_MSG_CHECKING([whether wait_queue_entry_t exists])
1007+ SPL_LINUX_TRY_COMPILE([
1008+ #include <linux/wait.h>
1009+ ],[
1010+ wait_queue_entry_t *entry __attribute__ ((unused));
1011+ ],[
1012+ AC_MSG_RESULT(yes)
1013+ AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY_T, 1,
1014+ [wait_queue_entry_t exists])
1015+ ],[
1016+ AC_MSG_RESULT(no)
1017+ ])
1018+])
1019+
1020+dnl #
1021+dnl # 4.13 API change
1022+dnl # Renamed wait_queue_head::task_list -> wait_queue_head::head
1023+dnl # Renamed wait_queue_entry::task_list -> wait_queue_entry::entry
1024+dnl #
1025+AC_DEFUN([SPL_AC_WAIT_QUEUE_HEAD_ENTRY], [
1026+ AC_MSG_CHECKING([whether wq_head->head and wq_entry->entry exist])
1027+ SPL_LINUX_TRY_COMPILE([
1028+ #include <linux/wait.h>
1029+
1030+ #ifdef HAVE_WAIT_QUEUE_ENTRY_T
1031+ typedef wait_queue_head_t spl_wait_queue_head_t;
1032+ typedef wait_queue_entry_t spl_wait_queue_entry_t;
1033+ #else
1034+ typedef wait_queue_head_t spl_wait_queue_head_t;
1035+ typedef wait_queue_t spl_wait_queue_entry_t;
1036+ #endif
1037+ ],[
1038+ spl_wait_queue_head_t wq_head;
1039+ spl_wait_queue_entry_t wq_entry;
1040+ struct list_head *head __attribute__ ((unused));
1041+ struct list_head *entry __attribute__ ((unused));
1042+
1043+ head = &wq_head.head;
1044+ entry = &wq_entry.entry;
1045+ ],[
1046+ AC_MSG_RESULT(yes)
1047+ AC_DEFINE(HAVE_WAIT_QUEUE_HEAD_ENTRY, 1,
1048+ [wq_head->head and wq_entry->entry exist])
1049+ ],[
1050+ AC_MSG_RESULT(no)
1051+ ])
1052+])
1053diff --git a/config/kernel-zlib.m4 b/config/kernel-zlib.m4
1054new file mode 100644
1055index 0000000..bb23646
1056--- /dev/null
1057+++ b/config/kernel-zlib.m4
1058@@ -0,0 +1,63 @@
1059+dnl #
1060+dnl # zlib inflate compat,
1061+dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1062+dnl #
1063+AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1064+ AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1065+ SPL_LINUX_TRY_COMPILE([
1066+ #if !defined(CONFIG_ZLIB_INFLATE) && \
1067+ !defined(CONFIG_ZLIB_INFLATE_MODULE)
1068+ #error CONFIG_ZLIB_INFLATE not defined
1069+ #endif
1070+ ],[ ],[
1071+ AC_MSG_RESULT([yes])
1072+ ],[
1073+ AC_MSG_RESULT([no])
1074+ AC_MSG_ERROR([
1075+ *** This kernel does not include the required zlib inflate support.
1076+ *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1077+ ])
1078+])
1079+
1080+dnl #
1081+dnl # zlib deflate compat,
1082+dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1083+dnl #
1084+AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1085+ AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1086+ SPL_LINUX_TRY_COMPILE([
1087+ #if !defined(CONFIG_ZLIB_DEFLATE) && \
1088+ !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1089+ #error CONFIG_ZLIB_DEFLATE not defined
1090+ #endif
1091+ ],[ ],[
1092+ AC_MSG_RESULT([yes])
1093+ ],[
1094+ AC_MSG_RESULT([no])
1095+ AC_MSG_ERROR([
1096+ *** This kernel does not include the required zlib deflate support.
1097+ *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1098+ ])
1099+])
1100+
1101+dnl #
1102+dnl # 2.6.39 API compat,
1103+dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1104+dnl # This was done to avoid always having to allocate the maximum size
1105+dnl # workspace (268K). The caller can now specific the windowBits and
1106+dnl # memLevel compression parameters to get a smaller workspace.
1107+dnl #
1108+AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1109+ [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1110+ SPL_LINUX_TRY_COMPILE([
1111+ #include <linux/zlib.h>
1112+ ],[
1113+ return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1114+ ],[
1115+ AC_MSG_RESULT(yes)
1116+ AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1117+ [zlib_deflate_workspacesize() wants 2 args])
1118+ ],[
1119+ AC_MSG_RESULT(no)
1120+ ])
1121+])
1122diff --git a/config/spl-build.m4 b/config/spl-build.m4
1123index afc8de6..553b5d5 100644
1124--- a/config/spl-build.m4
1125+++ b/config/spl-build.m4
1126@@ -753,959 +753,3 @@ AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
1127 AC_MSG_CHECKING([whether kernel defines atomic64_t])
1128 AC_MSG_RESULT([$have_atomic64_t])
1129 ])
1130-
1131-AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
1132- tmp_flags="$EXTRA_KCFLAGS"
1133- EXTRA_KCFLAGS="-Werror"
1134- dnl #
1135- dnl # 2.6.23 to 2.6.34 API change
1136- dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
1137- dnl #
1138- AC_MSG_CHECKING([whether old 2-argument shrinker exists])
1139- SPL_LINUX_TRY_COMPILE([
1140- #include <linux/mm.h>
1141-
1142- int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
1143- ],[
1144- struct shrinker cache_shrinker = {
1145- .shrink = shrinker_cb,
1146- .seeks = DEFAULT_SEEKS,
1147- };
1148- register_shrinker(&cache_shrinker);
1149- ],[
1150- AC_MSG_RESULT(yes)
1151- AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
1152- [old shrinker callback wants 2 args])
1153- ],[
1154- AC_MSG_RESULT(no)
1155- dnl #
1156- dnl # 2.6.35 - 2.6.39 API change
1157- dnl # ->shrink(struct shrinker *,
1158- dnl # int nr_to_scan, gfp_t gfp_mask)
1159- dnl #
1160- AC_MSG_CHECKING([whether old 3-argument shrinker exists])
1161- SPL_LINUX_TRY_COMPILE([
1162- #include <linux/mm.h>
1163-
1164- int shrinker_cb(struct shrinker *, int nr_to_scan,
1165- gfp_t gfp_mask);
1166- ],[
1167- struct shrinker cache_shrinker = {
1168- .shrink = shrinker_cb,
1169- .seeks = DEFAULT_SEEKS,
1170- };
1171- register_shrinker(&cache_shrinker);
1172- ],[
1173- AC_MSG_RESULT(yes)
1174- AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
1175- [old shrinker callback wants 3 args])
1176- ],[
1177- AC_MSG_RESULT(no)
1178- dnl #
1179- dnl # 3.0 - 3.11 API change
1180- dnl # ->shrink(struct shrinker *,
1181- dnl # struct shrink_control *sc)
1182- dnl #
1183- AC_MSG_CHECKING(
1184- [whether new 2-argument shrinker exists])
1185- SPL_LINUX_TRY_COMPILE([
1186- #include <linux/mm.h>
1187-
1188- int shrinker_cb(struct shrinker *,
1189- struct shrink_control *sc);
1190- ],[
1191- struct shrinker cache_shrinker = {
1192- .shrink = shrinker_cb,
1193- .seeks = DEFAULT_SEEKS,
1194- };
1195- register_shrinker(&cache_shrinker);
1196- ],[
1197- AC_MSG_RESULT(yes)
1198- AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
1199- [new shrinker callback wants 2 args])
1200- ],[
1201- AC_MSG_RESULT(no)
1202- dnl #
1203- dnl # 3.12 API change,
1204- dnl # ->shrink() is logically split in to
1205- dnl # ->count_objects() and ->scan_objects()
1206- dnl #
1207- AC_MSG_CHECKING(
1208- [whether ->count_objects callback exists])
1209- SPL_LINUX_TRY_COMPILE([
1210- #include <linux/mm.h>
1211-
1212- unsigned long shrinker_cb(
1213- struct shrinker *,
1214- struct shrink_control *sc);
1215- ],[
1216- struct shrinker cache_shrinker = {
1217- .count_objects = shrinker_cb,
1218- .scan_objects = shrinker_cb,
1219- .seeks = DEFAULT_SEEKS,
1220- };
1221- register_shrinker(&cache_shrinker);
1222- ],[
1223- AC_MSG_RESULT(yes)
1224- AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
1225- 1, [->count_objects exists])
1226- ],[
1227- AC_MSG_ERROR(error)
1228- ])
1229- ])
1230- ])
1231- ])
1232- EXTRA_KCFLAGS="$tmp_flags"
1233-])
1234-
1235-dnl #
1236-dnl # 2.6.33 API change,
1237-dnl # Removed .ctl_name from struct ctl_table.
1238-dnl #
1239-AC_DEFUN([SPL_AC_CTL_NAME], [
1240- AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
1241- SPL_LINUX_TRY_COMPILE([
1242- #include <linux/sysctl.h>
1243- ],[
1244- struct ctl_table ctl __attribute__ ((unused));
1245- ctl.ctl_name = 0;
1246- ],[
1247- AC_MSG_RESULT(yes)
1248- AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1249- ],[
1250- AC_MSG_RESULT(no)
1251- ])
1252-])
1253-
1254-dnl #
1255-dnl # 3.10 API change,
1256-dnl # PDE is replaced by PDE_DATA
1257-dnl #
1258-AC_DEFUN([SPL_AC_PDE_DATA], [
1259- AC_MSG_CHECKING([whether PDE_DATA() is available])
1260- SPL_LINUX_TRY_COMPILE_SYMBOL([
1261- #include <linux/proc_fs.h>
1262- ], [
1263- PDE_DATA(NULL);
1264- ], [PDE_DATA], [], [
1265- AC_MSG_RESULT(yes)
1266- AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
1267- ],[
1268- AC_MSG_RESULT(no)
1269- ])
1270-])
1271-
1272-dnl #
1273-dnl # 3.9 API change
1274-dnl # set_fs_pwd takes const struct path *
1275-dnl #
1276-AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
1277- tmp_flags="$EXTRA_KCFLAGS"
1278- EXTRA_KCFLAGS="-Werror"
1279- [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
1280- SPL_LINUX_TRY_COMPILE([
1281- #include <linux/spinlock.h>
1282- #include <linux/fs_struct.h>
1283- #include <linux/path.h>
1284- void (*const set_fs_pwd_func)
1285- (struct fs_struct *, const struct path *)
1286- = set_fs_pwd;
1287- ],[
1288- return 0;
1289- ],[
1290- AC_MSG_RESULT(yes)
1291- AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
1292- [set_fs_pwd() needs const path *])
1293- ],[
1294- SPL_LINUX_TRY_COMPILE([
1295- #include <linux/spinlock.h>
1296- #include <linux/fs_struct.h>
1297- #include <linux/path.h>
1298- void (*const set_fs_pwd_func)
1299- (struct fs_struct *, struct path *)
1300- = set_fs_pwd;
1301- ],[
1302- return 0;
1303- ],[
1304- AC_MSG_RESULT(no)
1305- ],[
1306- AC_MSG_ERROR(unknown)
1307- ])
1308- ])
1309- EXTRA_KCFLAGS="$tmp_flags"
1310-])
1311-
1312-dnl #
1313-dnl # 2.6.36 API change,
1314-dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1315-dnl # a spinlock_t to improve the fastpath performance.
1316-dnl #
1317-AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1318- AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1319- tmp_flags="$EXTRA_KCFLAGS"
1320- EXTRA_KCFLAGS="-Werror"
1321- SPL_LINUX_TRY_COMPILE([
1322- #include <linux/sched.h>
1323- #include <linux/fs_struct.h>
1324- ],[
1325- static struct fs_struct fs;
1326- spin_lock_init(&fs.lock);
1327- ],[
1328- AC_MSG_RESULT(yes)
1329- AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1330- [struct fs_struct uses spinlock_t])
1331- ],[
1332- AC_MSG_RESULT(no)
1333- ])
1334- EXTRA_KCFLAGS="$tmp_flags"
1335-])
1336-
1337-dnl #
1338-dnl # User namespaces, use kuid_t in place of uid_t
1339-dnl # where available. Not strictly a user namespaces thing
1340-dnl # but it should prevent surprises
1341-dnl #
1342-AC_DEFUN([SPL_AC_KUIDGID_T], [
1343- AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1344- SPL_LINUX_TRY_COMPILE([
1345- #include <linux/uidgid.h>
1346- ], [
1347- kuid_t userid = KUIDT_INIT(0);
1348- kgid_t groupid = KGIDT_INIT(0);
1349- ],[
1350- SPL_LINUX_TRY_COMPILE([
1351- #include <linux/uidgid.h>
1352- ], [
1353- kuid_t userid = 0;
1354- kgid_t groupid = 0;
1355- ],[
1356- AC_MSG_RESULT(yes; optional)
1357- ],[
1358- AC_MSG_RESULT(yes; mandatory)
1359- AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1360- ])
1361- ],[
1362- AC_MSG_RESULT(no)
1363- ])
1364-])
1365-
1366-dnl #
1367-dnl # 2.6.35 API change,
1368-dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1369-dnl #
1370-AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1371- AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1372- SPL_LINUX_TRY_COMPILE([
1373- #include <linux/fs.h>
1374- ],[
1375- vfs_fsync(NULL, 0);
1376- ],[
1377- AC_MSG_RESULT(yes)
1378- AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1379- ],[
1380- AC_MSG_RESULT(no)
1381- ])
1382-])
1383-
1384-dnl #
1385-dnl # 3.5 API change,
1386-dnl # inode_operations.truncate_range removed
1387-dnl #
1388-AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1389- AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1390- SPL_LINUX_TRY_COMPILE([
1391- #include <linux/fs.h>
1392- ],[
1393- struct inode_operations ops;
1394- ops.truncate_range = NULL;
1395- ],[
1396- AC_MSG_RESULT(yes)
1397- AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1398- [truncate_range() inode operation is available])
1399- ],[
1400- AC_MSG_RESULT(no)
1401- ])
1402-])
1403-
1404-dnl #
1405-dnl # Linux 2.6.38 - 3.x API
1406-dnl #
1407-AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1408- AC_MSG_CHECKING([whether fops->fallocate() exists])
1409- SPL_LINUX_TRY_COMPILE([
1410- #include <linux/fs.h>
1411- ],[
1412- long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1413- struct file_operations fops __attribute__ ((unused)) = {
1414- .fallocate = fallocate,
1415- };
1416- ],[
1417- AC_MSG_RESULT(yes)
1418- AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1419- ],[
1420- AC_MSG_RESULT(no)
1421- ])
1422-])
1423-
1424-dnl #
1425-dnl # Linux 2.6.x - 2.6.37 API
1426-dnl #
1427-AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1428- AC_MSG_CHECKING([whether iops->fallocate() exists])
1429- SPL_LINUX_TRY_COMPILE([
1430- #include <linux/fs.h>
1431- ],[
1432- long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1433- struct inode_operations fops __attribute__ ((unused)) = {
1434- .fallocate = fallocate,
1435- };
1436- ],[
1437- AC_MSG_RESULT(yes)
1438- AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1439- ],[
1440- AC_MSG_RESULT(no)
1441- ])
1442-])
1443-
1444-dnl #
1445-dnl # PaX Linux 2.6.38 - 3.x API
1446-dnl #
1447-AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1448- AC_MSG_CHECKING([whether fops->fallocate() exists])
1449- SPL_LINUX_TRY_COMPILE([
1450- #include <linux/fs.h>
1451- ],[
1452- long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1453- struct file_operations_no_const fops __attribute__ ((unused)) = {
1454- .fallocate = fallocate,
1455- };
1456- ],[
1457- AC_MSG_RESULT(yes)
1458- AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1459- ],[
1460- AC_MSG_RESULT(no)
1461- ])
1462-])
1463-
1464-dnl #
1465-dnl # The fallocate callback was moved from the inode_operations
1466-dnl # structure to the file_operations structure.
1467-dnl #
1468-AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1469- SPL_AC_KERNEL_FILE_FALLOCATE
1470- SPL_AC_KERNEL_INODE_FALLOCATE
1471- SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1472-])
1473-
1474-dnl #
1475-dnl # zlib inflate compat,
1476-dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1477-dnl #
1478-AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1479- AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1480- SPL_LINUX_TRY_COMPILE([
1481- #if !defined(CONFIG_ZLIB_INFLATE) && \
1482- !defined(CONFIG_ZLIB_INFLATE_MODULE)
1483- #error CONFIG_ZLIB_INFLATE not defined
1484- #endif
1485- ],[ ],[
1486- AC_MSG_RESULT([yes])
1487- ],[
1488- AC_MSG_RESULT([no])
1489- AC_MSG_ERROR([
1490- *** This kernel does not include the required zlib inflate support.
1491- *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1492- ])
1493-])
1494-
1495-dnl #
1496-dnl # zlib deflate compat,
1497-dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1498-dnl #
1499-AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1500- AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1501- SPL_LINUX_TRY_COMPILE([
1502- #if !defined(CONFIG_ZLIB_DEFLATE) && \
1503- !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1504- #error CONFIG_ZLIB_DEFLATE not defined
1505- #endif
1506- ],[ ],[
1507- AC_MSG_RESULT([yes])
1508- ],[
1509- AC_MSG_RESULT([no])
1510- AC_MSG_ERROR([
1511- *** This kernel does not include the required zlib deflate support.
1512- *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1513- ])
1514-])
1515-
1516-dnl #
1517-dnl # config trim unused symbols,
1518-dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS DISABLED.
1519-dnl #
1520-AC_DEFUN([SPL_AC_CONFIG_TRIM_UNUSED_KSYMS], [
1521- AC_MSG_CHECKING([whether CONFIG_TRIM_UNUSED_KSYM is disabled])
1522- SPL_LINUX_TRY_COMPILE([
1523- #if defined(CONFIG_TRIM_UNUSED_KSYMS)
1524- #error CONFIG_TRIM_UNUSED_KSYMS not defined
1525- #endif
1526- ],[ ],[
1527- AC_MSG_RESULT([yes])
1528- ],[
1529- AC_MSG_RESULT([no])
1530- AC_MSG_ERROR([
1531- *** This kernel has unused symbols trimming enabled, please disable.
1532- *** Rebuild the kernel with CONFIG_TRIM_UNUSED_KSYMS=n set.])
1533- ])
1534-])
1535-
1536-dnl #
1537-dnl # 2.6.39 API compat,
1538-dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1539-dnl # This was done to avoid always having to allocate the maximum size
1540-dnl # workspace (268K). The caller can now specific the windowBits and
1541-dnl # memLevel compression parameters to get a smaller workspace.
1542-dnl #
1543-AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1544- [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1545- SPL_LINUX_TRY_COMPILE([
1546- #include <linux/zlib.h>
1547- ],[
1548- return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1549- ],[
1550- AC_MSG_RESULT(yes)
1551- AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1552- [zlib_deflate_workspacesize() wants 2 args])
1553- ],[
1554- AC_MSG_RESULT(no)
1555- ])
1556-])
1557-
1558-dnl #
1559-dnl # 2.6.39 API change,
1560-dnl # Shrinker adjust to use common shrink_control structure.
1561-dnl #
1562-AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1563- AC_MSG_CHECKING([whether struct shrink_control exists])
1564- SPL_LINUX_TRY_COMPILE([
1565- #include <linux/mm.h>
1566- ],[
1567- struct shrink_control sc __attribute__ ((unused));
1568-
1569- sc.nr_to_scan = 0;
1570- sc.gfp_mask = GFP_KERNEL;
1571- ],[
1572- AC_MSG_RESULT(yes)
1573- AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1574- [struct shrink_control exists])
1575- ],[
1576- AC_MSG_RESULT(no)
1577- ])
1578-])
1579-
1580-dnl #
1581-dnl # 3.1 API Change
1582-dnl #
1583-dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1584-dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1585-dnl #
1586-AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1587- AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1588- tmp_flags="$EXTRA_KCFLAGS"
1589- EXTRA_KCFLAGS="-Werror"
1590- SPL_LINUX_TRY_COMPILE([
1591- #include <linux/rwsem.h>
1592- ],[
1593- struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1594- raw_spinlock_t dummy_lock __attribute__ ((unused)) =
1595- __RAW_SPIN_LOCK_INITIALIZER(dummy_lock);
1596- dummy_semaphore.wait_lock = dummy_lock;
1597- ],[
1598- AC_MSG_RESULT(yes)
1599- AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1600- [struct rw_semaphore member wait_lock is raw_spinlock_t])
1601- ],[
1602- AC_MSG_RESULT(no)
1603- ])
1604- EXTRA_KCFLAGS="$tmp_flags"
1605-])
1606-
1607-dnl #
1608-dnl # 3.16 API Change
1609-dnl #
1610-dnl # rwsem-spinlock "->activity" changed to "->count"
1611-dnl #
1612-AC_DEFUN([SPL_AC_RWSEM_ACTIVITY], [
1613- AC_MSG_CHECKING([whether struct rw_semaphore has member activity])
1614- tmp_flags="$EXTRA_KCFLAGS"
1615- EXTRA_KCFLAGS="-Werror"
1616- SPL_LINUX_TRY_COMPILE([
1617- #include <linux/rwsem.h>
1618- ],[
1619- struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1620- dummy_semaphore.activity = 0;
1621- ],[
1622- AC_MSG_RESULT(yes)
1623- AC_DEFINE(HAVE_RWSEM_ACTIVITY, 1,
1624- [struct rw_semaphore has member activity])
1625- ],[
1626- AC_MSG_RESULT(no)
1627- ])
1628- EXTRA_KCFLAGS="$tmp_flags"
1629-])
1630-
1631-dnl #
1632-dnl # 4.8 API Change
1633-dnl #
1634-dnl # rwsem "->count" changed to atomic_long_t type
1635-dnl #
1636-AC_DEFUN([SPL_AC_RWSEM_ATOMIC_LONG_COUNT], [
1637- AC_MSG_CHECKING(
1638- [whether struct rw_semaphore has atomic_long_t member count])
1639- tmp_flags="$EXTRA_KCFLAGS"
1640- EXTRA_KCFLAGS="-Werror"
1641- SPL_LINUX_TRY_COMPILE([
1642- #include <linux/rwsem.h>
1643- ],[
1644- DECLARE_RWSEM(dummy_semaphore);
1645- (void) atomic_long_read(&dummy_semaphore.count);
1646- ],[
1647- AC_MSG_RESULT(yes)
1648- AC_DEFINE(HAVE_RWSEM_ATOMIC_LONG_COUNT, 1,
1649- [struct rw_semaphore has atomic_long_t member count])
1650- ],[
1651- AC_MSG_RESULT(no)
1652- ])
1653- EXTRA_KCFLAGS="$tmp_flags"
1654-])
1655-
1656-dnl #
1657-dnl # 3.9 API change,
1658-dnl # Moved things from linux/sched.h to linux/sched/rt.h
1659-dnl #
1660-AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
1661- [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
1662- SPL_LINUX_TRY_COMPILE([
1663- #include <linux/sched.h>
1664- #include <linux/sched/rt.h>
1665- ],[
1666- return 0;
1667- ],[
1668- AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
1669- AC_MSG_RESULT(yes)
1670- ],[
1671- AC_MSG_RESULT(no)
1672- ])
1673-])
1674-
1675-dnl #
1676-dnl # 4.11 API change,
1677-dnl # Moved things from linux/sched.h to linux/sched/signal.h
1678-dnl #
1679-AC_DEFUN([SPL_AC_SCHED_SIGNAL_HEADER],
1680- [AC_MSG_CHECKING([whether header linux/sched/signal.h exists])
1681- SPL_LINUX_TRY_COMPILE([
1682- #include <linux/sched.h>
1683- #include <linux/sched/signal.h>
1684- ],[
1685- return 0;
1686- ],[
1687- AC_DEFINE(HAVE_SCHED_SIGNAL_HEADER, 1, [linux/sched/signal.h exists])
1688- AC_MSG_RESULT(yes)
1689- ],[
1690- AC_MSG_RESULT(no)
1691- ])
1692-])
1693-
1694-dnl #
1695-dnl # 4.11 API, a528d35e@torvalds/linux
1696-dnl # vfs_getattr(const struct path *p, struct kstat *s, u32 m, unsigned int f)
1697-dnl #
1698-AC_DEFUN([SPL_AC_4ARGS_VFS_GETATTR], [
1699- AC_MSG_CHECKING([whether vfs_getattr() wants 4 args])
1700- SPL_LINUX_TRY_COMPILE([
1701- #include <linux/fs.h>
1702- ],[
1703- vfs_getattr((const struct path *)NULL,
1704- (struct kstat *)NULL,
1705- (u32)0,
1706- (unsigned int)0);
1707- ],[
1708- AC_MSG_RESULT(yes)
1709- AC_DEFINE(HAVE_4ARGS_VFS_GETATTR, 1,
1710- [vfs_getattr wants 4 args])
1711- ],[
1712- AC_MSG_RESULT(no)
1713- ])
1714-])
1715-
1716-dnl #
1717-dnl # 3.9 API
1718-dnl # vfs_getattr(struct path *p, struct kstat *s)
1719-dnl #
1720-AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
1721- AC_MSG_CHECKING([whether vfs_getattr() wants 2 args])
1722- SPL_LINUX_TRY_COMPILE([
1723- #include <linux/fs.h>
1724- ],[
1725- vfs_getattr((struct path *) NULL,
1726- (struct kstat *)NULL);
1727- ],[
1728- AC_MSG_RESULT(yes)
1729- AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
1730- [vfs_getattr wants 2 args])
1731- ],[
1732- AC_MSG_RESULT(no)
1733- ])
1734-])
1735-
1736-dnl #
1737-dnl # <3.9 API
1738-dnl # vfs_getattr(struct vfsmount *v, struct dentry *d, struct kstat *k)
1739-dnl #
1740-AC_DEFUN([SPL_AC_3ARGS_VFS_GETATTR], [
1741- AC_MSG_CHECKING([whether vfs_getattr() wants 3 args])
1742- SPL_LINUX_TRY_COMPILE([
1743- #include <linux/fs.h>
1744- ],[
1745- vfs_getattr((struct vfsmount *)NULL,
1746- (struct dentry *)NULL,
1747- (struct kstat *)NULL);
1748- ],[
1749- AC_MSG_RESULT(yes)
1750- AC_DEFINE(HAVE_3ARGS_VFS_GETATTR, 1,
1751- [vfs_getattr wants 3 args])
1752- ],[
1753- AC_MSG_RESULT(no)
1754- ])
1755-])
1756-
1757-dnl #
1758-dnl # 2.6.36 API compatibility.
1759-dnl # Added usleep_range timer.
1760-dnl # usleep_range is a finer precision implementation of msleep
1761-dnl # designed to be a drop-in replacement for udelay where a precise
1762-dnl # sleep / busy-wait is unnecessary.
1763-dnl #
1764-AC_DEFUN([SPL_AC_USLEEP_RANGE], [
1765- AC_MSG_CHECKING([whether usleep_range() is available])
1766- SPL_LINUX_TRY_COMPILE([
1767- #include <linux/delay.h>
1768- ],[
1769- usleep_range(0, 0);
1770- ],[
1771- AC_MSG_RESULT(yes)
1772- AC_DEFINE(HAVE_USLEEP_RANGE, 1,
1773- [usleep_range is available])
1774- ],[
1775- AC_MSG_RESULT(no)
1776- ])
1777-])
1778-
1779-dnl #
1780-dnl # 2.6.35 API change,
1781-dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
1782-dnl # private allocation flags which are applied when allocating a new slab
1783-dnl # in kmem_getpages(). Unfortunately there is no public API for setting
1784-dnl # non-default flags.
1785-dnl #
1786-AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
1787- AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
1788- SPL_LINUX_TRY_COMPILE([
1789- #include <linux/slab.h>
1790- ],[
1791- struct kmem_cache cachep __attribute__ ((unused));
1792- cachep.allocflags = GFP_KERNEL;
1793- ],[
1794- AC_MSG_RESULT(yes)
1795- AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
1796- [struct kmem_cache has allocflags])
1797- ],[
1798- AC_MSG_RESULT(no)
1799-
1800- AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
1801- SPL_LINUX_TRY_COMPILE([
1802- #include <linux/slab.h>
1803- ],[
1804- struct kmem_cache cachep __attribute__ ((unused));
1805- cachep.gfpflags = GFP_KERNEL;
1806- ],[
1807- AC_MSG_RESULT(yes)
1808- AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
1809- [struct kmem_cache has gfpflags])
1810- ],[
1811- AC_MSG_RESULT(no)
1812- ])
1813- ])
1814-])
1815-
1816-dnl #
1817-dnl # 3.17 API change,
1818-dnl # wait_on_bit() no longer requires an action argument. The former
1819-dnl # "wait_on_bit" interface required an 'action' function to be provided
1820-dnl # which does the actual waiting. There were over 20 such functions in the
1821-dnl # kernel, many of them identical, though most cases can be satisfied by one
1822-dnl # of just two functions: one which uses io_schedule() and one which just
1823-dnl # uses schedule(). This API change was made to consolidate all of those
1824-dnl # redundant wait functions.
1825-dnl #
1826-AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
1827- AC_MSG_CHECKING([whether wait_on_bit() takes an action])
1828- SPL_LINUX_TRY_COMPILE([
1829- #include <linux/wait.h>
1830- ],[
1831- int (*action)(void *) = NULL;
1832- wait_on_bit(NULL, 0, action, 0);
1833- ],[
1834- AC_MSG_RESULT(yes)
1835- AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])
1836- ],[
1837- AC_MSG_RESULT(no)
1838- ])
1839-])
1840-
1841-dnl #
1842-dnl # 4.7 API change
1843-dnl # i_mutex is changed to i_rwsem. Instead of directly using
1844-dnl # i_mutex/i_rwsem, we should use inode_lock() and inode_lock_shared()
1845-dnl # We test inode_lock_shared because inode_lock is introduced earlier.
1846-dnl #
1847-AC_DEFUN([SPL_AC_INODE_LOCK], [
1848- AC_MSG_CHECKING([whether inode_lock_shared() exists])
1849- tmp_flags="$EXTRA_KCFLAGS"
1850- EXTRA_KCFLAGS="-Werror"
1851- SPL_LINUX_TRY_COMPILE([
1852- #include <linux/fs.h>
1853- ],[
1854- struct inode *inode = NULL;
1855- inode_lock_shared(inode);
1856- ],[
1857- AC_MSG_RESULT(yes)
1858- AC_DEFINE(HAVE_INODE_LOCK_SHARED, 1, [yes])
1859- ],[
1860- AC_MSG_RESULT(no)
1861- ])
1862- EXTRA_KCFLAGS="$tmp_flags"
1863-])
1864-
1865-dnl #
1866-dnl # 4.9 API change
1867-dnl # group_info changed from 2d array via >blocks to 1d array via ->gid
1868-dnl #
1869-AC_DEFUN([SPL_AC_GROUP_INFO_GID], [
1870- AC_MSG_CHECKING([whether group_info->gid exists])
1871- tmp_flags="$EXTRA_KCFLAGS"
1872- EXTRA_KCFLAGS="-Werror"
1873- SPL_LINUX_TRY_COMPILE([
1874- #include <linux/cred.h>
1875- ],[
1876- struct group_info *gi = groups_alloc(1);
1877- gi->gid[0] = KGIDT_INIT(0);
1878- ],[
1879- AC_MSG_RESULT(yes)
1880- AC_DEFINE(HAVE_GROUP_INFO_GID, 1, [group_info->gid exists])
1881- ],[
1882- AC_MSG_RESULT(no)
1883- ])
1884- EXTRA_KCFLAGS="$tmp_flags"
1885-])
1886-
1887-dnl #
1888-dnl # grsecurity API change,
1889-dnl # kmem_cache_create() with SLAB_USERCOPY flag replaced by
1890-dnl # kmem_cache_create_usercopy().
1891-dnl #
1892-AC_DEFUN([SPL_AC_KMEM_CACHE_CREATE_USERCOPY], [
1893- AC_MSG_CHECKING([whether kmem_cache_create_usercopy() exists])
1894- tmp_flags="$EXTRA_KCFLAGS"
1895- EXTRA_KCFLAGS="-Werror"
1896- SPL_LINUX_TRY_COMPILE([
1897- #include <linux/slab.h>
1898- static void ctor(void *foo)
1899- {
1900- // fake ctor
1901- }
1902- ],[
1903- struct kmem_cache *skc_linux_cache;
1904- const char *name = "test";
1905- size_t size = 4096;
1906- size_t align = 8;
1907- unsigned long flags = 0;
1908- size_t useroffset = 0;
1909- size_t usersize = size - useroffset;
1910-
1911- skc_linux_cache = kmem_cache_create_usercopy(
1912- name, size, align, flags, useroffset, usersize, ctor);
1913- ],[
1914- AC_MSG_RESULT(yes)
1915- AC_DEFINE(HAVE_KMEM_CACHE_CREATE_USERCOPY, 1,
1916- [kmem_cache_create_usercopy() exists])
1917- ],[
1918- AC_MSG_RESULT(no)
1919- ])
1920- EXTRA_KCFLAGS="$tmp_flags"
1921-])
1922-
1923-dnl #
1924-dnl # 4.13 API change
1925-dnl # Renamed struct wait_queue -> struct wait_queue_entry.
1926-dnl #
1927-AC_DEFUN([SPL_AC_WAIT_QUEUE_ENTRY_T], [
1928- AC_MSG_CHECKING([whether wait_queue_entry_t exists])
1929- SPL_LINUX_TRY_COMPILE([
1930- #include <linux/wait.h>
1931- ],[
1932- wait_queue_entry_t *entry __attribute__ ((unused));
1933- ],[
1934- AC_MSG_RESULT(yes)
1935- AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY_T, 1,
1936- [wait_queue_entry_t exists])
1937- ],[
1938- AC_MSG_RESULT(no)
1939- ])
1940-])
1941-
1942-dnl #
1943-dnl # 4.13 API change
1944-dnl # Renamed wait_queue_head::task_list -> wait_queue_head::head
1945-dnl # Renamed wait_queue_entry::task_list -> wait_queue_entry::entry
1946-dnl #
1947-AC_DEFUN([SPL_AC_WAIT_QUEUE_HEAD_ENTRY], [
1948- AC_MSG_CHECKING([whether wq_head->head and wq_entry->entry exist])
1949- SPL_LINUX_TRY_COMPILE([
1950- #include <linux/wait.h>
1951-
1952- #ifdef HAVE_WAIT_QUEUE_ENTRY_T
1953- typedef wait_queue_head_t spl_wait_queue_head_t;
1954- typedef wait_queue_entry_t spl_wait_queue_entry_t;
1955- #else
1956- typedef wait_queue_head_t spl_wait_queue_head_t;
1957- typedef wait_queue_t spl_wait_queue_entry_t;
1958- #endif
1959- ],[
1960- spl_wait_queue_head_t wq_head;
1961- spl_wait_queue_entry_t wq_entry;
1962- struct list_head *head __attribute__ ((unused));
1963- struct list_head *entry __attribute__ ((unused));
1964-
1965- head = &wq_head.head;
1966- entry = &wq_entry.entry;
1967- ],[
1968- AC_MSG_RESULT(yes)
1969- AC_DEFINE(HAVE_WAIT_QUEUE_HEAD_ENTRY, 1,
1970- [wq_head->head and wq_entry->entry exist])
1971- ],[
1972- AC_MSG_RESULT(no)
1973- ])
1974-])
1975-
1976-dnl #
1977-dnl # 3.19 API change
1978-dnl # The io_schedule_timeout() function is present in all 2.6.32 kernels
1979-dnl # but it was not exported until Linux 3.19. The RHEL 7.x kernels which
1980-dnl # are based on a 3.10 kernel do export this symbol.
1981-dnl #
1982-AC_DEFUN([SPL_AC_IO_SCHEDULE_TIMEOUT], [
1983- AC_MSG_CHECKING([whether io_schedule_timeout() is available])
1984- SPL_LINUX_TRY_COMPILE_SYMBOL([
1985- #include <linux/sched.h>
1986- ], [
1987- (void) io_schedule_timeout(1);
1988- ], [io_schedule_timeout], [], [
1989- AC_MSG_RESULT(yes)
1990- AC_DEFINE(HAVE_IO_SCHEDULE_TIMEOUT, 1, [yes])
1991- ],[
1992- AC_MSG_RESULT(no)
1993- ])
1994-])
1995-
1996-dnl #
1997-dnl # 4.14 API change
1998-dnl # kernel_write() which was introduced in 3.9 was updated to take
1999-dnl # the offset as a pointer which is needed by vn_rdwr().
2000-dnl #
2001-AC_DEFUN([SPL_AC_KERNEL_WRITE], [
2002- AC_MSG_CHECKING([whether kernel_write() takes loff_t pointer])
2003- tmp_flags="$EXTRA_KCFLAGS"
2004- EXTRA_KCFLAGS="-Werror"
2005- SPL_LINUX_TRY_COMPILE([
2006- #include <linux/fs.h>
2007- ],[
2008- struct file *file = NULL;
2009- const void *buf = NULL;
2010- size_t count = 0;
2011- loff_t *pos = NULL;
2012- ssize_t ret;
2013-
2014- ret = kernel_write(file, buf, count, pos);
2015- ],[
2016- AC_MSG_RESULT(yes)
2017- AC_DEFINE(HAVE_KERNEL_WRITE_PPOS, 1,
2018- [kernel_write() take loff_t pointer])
2019- ],[
2020- AC_MSG_RESULT(no)
2021- ])
2022- EXTRA_KCFLAGS="$tmp_flags"
2023-])
2024-
2025-dnl #
2026-dnl # 4.14 API change
2027-dnl # kernel_read() which has existed for forever was updated to take
2028-dnl # the offset as a pointer which is needed by vn_rdwr().
2029-dnl #
2030-AC_DEFUN([SPL_AC_KERNEL_READ], [
2031- AC_MSG_CHECKING([whether kernel_read() takes loff_t pointer])
2032- tmp_flags="$EXTRA_KCFLAGS"
2033- EXTRA_KCFLAGS="-Werror"
2034- SPL_LINUX_TRY_COMPILE([
2035- #include <linux/fs.h>
2036- ],[
2037- struct file *file = NULL;
2038- void *buf = NULL;
2039- size_t count = 0;
2040- loff_t *pos = NULL;
2041- ssize_t ret;
2042-
2043- ret = kernel_read(file, buf, count, pos);
2044- ],[
2045- AC_MSG_RESULT(yes)
2046- AC_DEFINE(HAVE_KERNEL_READ_PPOS, 1,
2047- [kernel_read() take loff_t pointer])
2048- ],[
2049- AC_MSG_RESULT(no)
2050- ])
2051- EXTRA_KCFLAGS="$tmp_flags"
2052-])
2053-
2054-dnl #
2055-dnl # 4.15 API change
2056-dnl # https://lkml.org/lkml/2017/11/25/90
2057-dnl # Check if timer_list.func get passed a timer_list or an unsigned long
2058-dnl # (older kernels). Also sanity check the from_timer() and timer_setup()
2059-dnl # macros are available as well, since they will be used in the same newer
2060-dnl # kernels that support the new timer_list.func signature.
2061-dnl #
2062-AC_DEFUN([SPL_AC_KERNEL_TIMER_FUNCTION_TIMER_LIST], [
2063- AC_MSG_CHECKING([whether timer_list.function gets a timer_list])
2064- tmp_flags="$EXTRA_KCFLAGS"
2065- EXTRA_KCFLAGS="-Werror"
2066- SPL_LINUX_TRY_COMPILE([
2067- #include <linux/timer.h>
2068- void task_expire(struct timer_list *tl) {}
2069- ],[
2070- #ifndef from_timer
2071- #error "No from_timer() macro"
2072- #endif
2073-
2074- struct timer_list timer;
2075- timer.function = task_expire;
2076- timer_setup(&timer, NULL, 0);
2077- ],[
2078- AC_MSG_RESULT(yes)
2079- AC_DEFINE(HAVE_KERNEL_TIMER_FUNCTION_TIMER_LIST, 1,
2080- [timer_list.function gets a timer_list])
2081- ],[
2082- AC_MSG_RESULT(no)
2083- ])
2084- EXTRA_KCFLAGS="$tmp_flags"
2085-])
2086--
20872.14.2
2088