zdb: remove strtok
[zfs.git] / config / kernel-shrink.m4
bloba40c86d5c57f56ddebeddad5fbff16f4eef2b1cd
1 dnl #
2 dnl # 3.1 API change
3 dnl # The super_block structure now stores a per-filesystem shrinker.
4 dnl # This interface is preferable because it can be used to specifically
5 dnl # target only the zfs filesystem for pruning.
6 dnl #
7 AC_DEFUN([ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK], [
8         ZFS_LINUX_TEST_SRC([super_block_s_shrink], [
9                 #include <linux/fs.h>
11                 int shrink(struct shrinker *s, struct shrink_control *sc)
12                     { return 0; }
14                 static const struct super_block
15                     sb __attribute__ ((unused)) = {
16                         .s_shrink.seeks = DEFAULT_SEEKS,
17                         .s_shrink.batch = 0,
18                 };
19         ],[])
22 AC_DEFUN([ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK], [
23         AC_MSG_CHECKING([whether super_block has s_shrink])
24         ZFS_LINUX_TEST_RESULT([super_block_s_shrink], [
25                 AC_MSG_RESULT(yes)
26         ],[
27                 ZFS_LINUX_TEST_ERROR([sb->s_shrink()])
28         ])
31 dnl #
32 dnl # 3.12 API change
33 dnl # The nid member was added to struct shrink_control to support
34 dnl # NUMA-aware shrinkers.
35 dnl #
36 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID], [
37         ZFS_LINUX_TEST_SRC([shrink_control_nid], [
38                 #include <linux/fs.h>
39         ],[
40                 struct shrink_control sc __attribute__ ((unused));
41                 unsigned long scnidsize __attribute__ ((unused)) =
42                     sizeof(sc.nid);
43         ])
46 AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID], [
47         AC_MSG_CHECKING([whether shrink_control has nid])
48         ZFS_LINUX_TEST_RESULT([shrink_control_nid], [
49                 AC_MSG_RESULT(yes)
50                 AC_DEFINE(SHRINK_CONTROL_HAS_NID, 1,
51                     [struct shrink_control has nid])
52         ],[
53                 AC_MSG_RESULT(no)
54         ])
57 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK], [
58         ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control], [
59                 #include <linux/mm.h>
60                 int shrinker_cb(struct shrinker *shrink,
61                     struct shrink_control *sc) { return 0; }
62         ],[
63                 struct shrinker cache_shrinker = {
64                         .shrink = shrinker_cb,
65                         .seeks = DEFAULT_SEEKS,
66                 };
67                 register_shrinker(&cache_shrinker);
68         ])
70         ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control_split], [
71                 #include <linux/mm.h>
72                 unsigned long shrinker_cb(struct shrinker *shrink,
73                     struct shrink_control *sc) { return 0; }
74         ],[
75                 struct shrinker cache_shrinker = {
76                         .count_objects = shrinker_cb,
77                         .scan_objects = shrinker_cb,
78                         .seeks = DEFAULT_SEEKS,
79                 };
80                 register_shrinker(&cache_shrinker);
81         ])
84 AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_CALLBACK],[
85         dnl #
86         dnl # 3.0 - 3.11 API change
87         dnl # ->shrink(struct shrinker *, struct shrink_control *sc)
88         dnl #
89         AC_MSG_CHECKING([whether new 2-argument shrinker exists])
90         ZFS_LINUX_TEST_RESULT([shrinker_cb_shrink_control], [
91                 AC_MSG_RESULT(yes)
92                 AC_DEFINE(HAVE_SINGLE_SHRINKER_CALLBACK, 1,
93                     [new shrinker callback wants 2 args])
94         ],[
95                 AC_MSG_RESULT(no)
97                 dnl #
98                 dnl # 3.12 API change,
99                 dnl # ->shrink() is logically split in to
100                 dnl # ->count_objects() and ->scan_objects()
101                 dnl #
102                 AC_MSG_CHECKING([whether ->count_objects callback exists])
103                 ZFS_LINUX_TEST_RESULT([shrinker_cb_shrink_control_split], [
104                         AC_MSG_RESULT(yes)
105                         AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, 1,
106                             [->count_objects exists])
107                 ],[
108                         ZFS_LINUX_TEST_ERROR([shrinker])
109                 ])
110         ])
113 dnl #
114 dnl # 2.6.39 API change,
115 dnl # Shrinker adjust to use common shrink_control structure.
116 dnl #
117 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT], [
118         ZFS_LINUX_TEST_SRC([shrink_control_struct], [
119                 #include <linux/mm.h>
120         ],[
121                 struct shrink_control sc __attribute__ ((unused));
123                 sc.nr_to_scan = 0;
124                 sc.gfp_mask = GFP_KERNEL;
125         ])
128 AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT], [
129         AC_MSG_CHECKING([whether struct shrink_control exists])
130         ZFS_LINUX_TEST_RESULT([shrink_control_struct], [
131                 AC_MSG_RESULT(yes)
132                 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
133                     [struct shrink_control exists])
134         ],[
135                 ZFS_LINUX_TEST_ERROR([shrink_control])
136         ])
139 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER], [
140         ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK
141         ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID
142         ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK
143         ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT
146 AC_DEFUN([ZFS_AC_KERNEL_SHRINKER], [
147         ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK
148         ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID
149         ZFS_AC_KERNEL_SHRINKER_CALLBACK
150         ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT