]>
Commit | Line | Data |
---|---|---|
ab26409d BB |
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 # | |
608f8749 BB |
7 | AC_DEFUN([ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK], [ |
8 | ZFS_LINUX_TEST_SRC([super_block_s_shrink], [ | |
ab26409d | 9 | #include <linux/fs.h> |
c38367c7 RY |
10 | |
11 | int shrink(struct shrinker *s, struct shrink_control *sc) | |
12 | { return 0; } | |
13 | ||
14 | static const struct super_block | |
15 | sb __attribute__ ((unused)) = { | |
ab26409d BB |
16 | .s_shrink.shrink = shrink, |
17 | .s_shrink.seeks = DEFAULT_SEEKS, | |
18 | .s_shrink.batch = 0, | |
19 | }; | |
608f8749 BB |
20 | ],[]) |
21 | ]) | |
22 | ||
23 | AC_DEFUN([ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK], [ | |
24 | AC_MSG_CHECKING([whether super_block has s_shrink]) | |
25 | ZFS_LINUX_TEST_RESULT([super_block_s_shrink], [ | |
ab26409d BB |
26 | AC_MSG_RESULT(yes) |
27 | AC_DEFINE(HAVE_SHRINK, 1, [struct super_block has s_shrink]) | |
28 | ||
29 | ],[ | |
30 | AC_MSG_RESULT(no) | |
dba1d705 BB |
31 | ]) |
32 | ]) | |
33 | ||
34 | dnl # | |
35 | dnl # 3.3 API change | |
36 | dnl # The super_block structure was changed to use an hlist_node instead | |
37 | dnl # of a list_head for the .s_instance linkage. | |
38 | dnl # | |
39 | dnl # This was done in part to resolve a race in the iterate_supers_type() | |
40 | dnl # function which was introduced in Linux 3.0 kernel. The iterator | |
41 | dnl # was supposed to provide a safe way to call an arbitrary function on | |
42 | dnl # all super blocks of a specific type. Unfortunately, because a | |
43 | dnl # list_head was used it was possible for iterate_supers_type() to | |
44 | dnl # get stuck spinning a super block which was just deactivated. | |
45 | dnl # | |
46 | dnl # This can occur because when the list head is removed from the | |
47 | dnl # fs_supers list it is reinitialized to point to itself. If the | |
48 | dnl # iterate_supers_type() function happened to be processing the | |
49 | dnl # removed list_head it will get stuck spinning on that list_head. | |
50 | dnl # | |
51 | dnl # To resolve the issue for existing 3.0 - 3.2 kernels we detect when | |
52 | dnl # a list_head is used. Then to prevent the spinning from occurring | |
53 | dnl # the .next pointer is set to the fs_supers list_head which ensures | |
54 | dnl # the iterate_supers_type() function will always terminate. | |
55 | dnl # | |
608f8749 BB |
56 | AC_DEFUN([ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_INSTANCES_LIST_HEAD], [ |
57 | ZFS_LINUX_TEST_SRC([super_block_s_instances_list_head], [ | |
dba1d705 BB |
58 | #include <linux/fs.h> |
59 | ],[ | |
60 | struct super_block sb __attribute__ ((unused)); | |
dba1d705 | 61 | INIT_LIST_HEAD(&sb.s_instances); |
608f8749 BB |
62 | ]) |
63 | ]) | |
64 | ||
65 | AC_DEFUN([ZFS_AC_KERNEL_SUPER_BLOCK_S_INSTANCES_LIST_HEAD], [ | |
66 | AC_MSG_CHECKING([whether super_block has s_instances list_head]) | |
67 | ZFS_LINUX_TEST_RESULT([super_block_s_instances_list_head], [ | |
dba1d705 BB |
68 | AC_MSG_RESULT(yes) |
69 | AC_DEFINE(HAVE_S_INSTANCES_LIST_HEAD, 1, | |
70 | [struct super_block has s_instances list_head]) | |
71 | ],[ | |
72 | AC_MSG_RESULT(no) | |
ab26409d BB |
73 | ]) |
74 | ]) | |
75 | ||
608f8749 BB |
76 | AC_DEFUN([ZFS_AC_KERNEL_SRC_NR_CACHED_OBJECTS], [ |
77 | ZFS_LINUX_TEST_SRC([nr_cached_objects], [ | |
ab26409d | 78 | #include <linux/fs.h> |
c38367c7 RY |
79 | |
80 | int nr_cached_objects(struct super_block *sb) { return 0; } | |
81 | ||
82 | static const struct super_operations | |
83 | sops __attribute__ ((unused)) = { | |
ab26409d BB |
84 | .nr_cached_objects = nr_cached_objects, |
85 | }; | |
608f8749 BB |
86 | ],[]) |
87 | ]) | |
88 | ||
89 | AC_DEFUN([ZFS_AC_KERNEL_NR_CACHED_OBJECTS], [ | |
90 | AC_MSG_CHECKING([whether sops->nr_cached_objects() exists]) | |
91 | ZFS_LINUX_TEST_RESULT([nr_cached_objects], [ | |
ab26409d BB |
92 | AC_MSG_RESULT(yes) |
93 | AC_DEFINE(HAVE_NR_CACHED_OBJECTS, 1, | |
608f8749 | 94 | [sops->nr_cached_objects() exists]) |
ab26409d BB |
95 | ],[ |
96 | AC_MSG_RESULT(no) | |
97 | ]) | |
98 | ]) | |
99 | ||
608f8749 BB |
100 | AC_DEFUN([ZFS_AC_KERNEL_SRC_FREE_CACHED_OBJECTS], [ |
101 | ZFS_LINUX_TEST_SRC([free_cached_objects], [ | |
ab26409d | 102 | #include <linux/fs.h> |
c38367c7 RY |
103 | |
104 | void free_cached_objects(struct super_block *sb, int x) | |
105 | { return; } | |
106 | ||
107 | static const struct super_operations | |
108 | sops __attribute__ ((unused)) = { | |
ab26409d BB |
109 | .free_cached_objects = free_cached_objects, |
110 | }; | |
608f8749 BB |
111 | ],[]) |
112 | ]) | |
113 | ||
114 | AC_DEFUN([ZFS_AC_KERNEL_FREE_CACHED_OBJECTS], [ | |
115 | AC_MSG_CHECKING([whether sops->free_cached_objects() exists]) | |
116 | ZFS_LINUX_TEST_RESULT([free_cached_objects], [ | |
ab26409d BB |
117 | AC_MSG_RESULT(yes) |
118 | AC_DEFINE(HAVE_FREE_CACHED_OBJECTS, 1, | |
608f8749 | 119 | [sops->free_cached_objects() exists]) |
ab26409d BB |
120 | ],[ |
121 | AC_MSG_RESULT(no) | |
122 | ]) | |
123 | ]) | |
90947b23 TC |
124 | |
125 | dnl # | |
126 | dnl # 3.12 API change | |
127 | dnl # The nid member was added to struct shrink_control to support | |
128 | dnl # NUMA-aware shrinkers. | |
129 | dnl # | |
608f8749 BB |
130 | AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID], [ |
131 | ZFS_LINUX_TEST_SRC([shrink_control_nid], [ | |
90947b23 TC |
132 | #include <linux/fs.h> |
133 | ],[ | |
134 | struct shrink_control sc __attribute__ ((unused)); | |
135 | unsigned long scnidsize __attribute__ ((unused)) = | |
136 | sizeof(sc.nid); | |
608f8749 BB |
137 | ]) |
138 | ]) | |
139 | ||
140 | AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID], [ | |
141 | AC_MSG_CHECKING([whether shrink_control has nid]) | |
142 | ZFS_LINUX_TEST_RESULT([shrink_control_nid], [ | |
90947b23 TC |
143 | AC_MSG_RESULT(yes) |
144 | AC_DEFINE(SHRINK_CONTROL_HAS_NID, 1, | |
145 | [struct shrink_control has nid]) | |
146 | ],[ | |
147 | AC_MSG_RESULT(no) | |
148 | ]) | |
149 | ]) | |
93ce2b4c | 150 | |
608f8749 BB |
151 | AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK], [ |
152 | ZFS_LINUX_TEST_SRC([shrinker_cb_2arg], [ | |
153 | #include <linux/mm.h> | |
154 | int shrinker_cb(int nr_to_scan, gfp_t gfp_mask) { return 0; } | |
155 | ],[ | |
156 | struct shrinker cache_shrinker = { | |
157 | .shrink = shrinker_cb, | |
158 | .seeks = DEFAULT_SEEKS, | |
159 | }; | |
160 | register_shrinker(&cache_shrinker); | |
161 | ]) | |
93ce2b4c | 162 | |
608f8749 | 163 | ZFS_LINUX_TEST_SRC([shrinker_cb_3arg], [ |
93ce2b4c | 164 | #include <linux/mm.h> |
608f8749 BB |
165 | int shrinker_cb(struct shrinker *shrink, int nr_to_scan, |
166 | gfp_t gfp_mask) { return 0; } | |
167 | ],[ | |
168 | struct shrinker cache_shrinker = { | |
169 | .shrink = shrinker_cb, | |
170 | .seeks = DEFAULT_SEEKS, | |
171 | }; | |
172 | register_shrinker(&cache_shrinker); | |
173 | ]) | |
93ce2b4c | 174 | |
608f8749 BB |
175 | ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control], [ |
176 | #include <linux/mm.h> | |
177 | int shrinker_cb(struct shrinker *shrink, | |
178 | struct shrink_control *sc) { return 0; } | |
93ce2b4c BB |
179 | ],[ |
180 | struct shrinker cache_shrinker = { | |
181 | .shrink = shrinker_cb, | |
182 | .seeks = DEFAULT_SEEKS, | |
183 | }; | |
184 | register_shrinker(&cache_shrinker); | |
608f8749 BB |
185 | ]) |
186 | ||
187 | ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control_split], [ | |
188 | #include <linux/mm.h> | |
189 | unsigned long shrinker_cb(struct shrinker *shrink, | |
190 | struct shrink_control *sc) { return 0; } | |
93ce2b4c | 191 | ],[ |
608f8749 BB |
192 | struct shrinker cache_shrinker = { |
193 | .count_objects = shrinker_cb, | |
194 | .scan_objects = shrinker_cb, | |
195 | .seeks = DEFAULT_SEEKS, | |
196 | }; | |
197 | register_shrinker(&cache_shrinker); | |
198 | ]) | |
199 | ]) | |
200 | ||
201 | AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_CALLBACK],[ | |
202 | dnl # | |
203 | dnl # 2.6.23 to 2.6.34 API change | |
204 | dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask) | |
205 | dnl # | |
206 | AC_MSG_CHECKING([whether old 2-argument shrinker exists]) | |
207 | ZFS_LINUX_TEST_RESULT([shrinker_cb_2arg], [ | |
93ce2b4c BB |
208 | AC_MSG_RESULT(yes) |
209 | AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1, | |
608f8749 | 210 | [old shrinker callback wants 2 args]) |
93ce2b4c BB |
211 | ],[ |
212 | AC_MSG_RESULT(no) | |
608f8749 | 213 | |
93ce2b4c BB |
214 | dnl # |
215 | dnl # 2.6.35 - 2.6.39 API change | |
216 | dnl # ->shrink(struct shrinker *, | |
217 | dnl # int nr_to_scan, gfp_t gfp_mask) | |
218 | dnl # | |
219 | AC_MSG_CHECKING([whether old 3-argument shrinker exists]) | |
608f8749 | 220 | ZFS_LINUX_TEST_RESULT([shrinker_cb_3arg], [ |
93ce2b4c BB |
221 | AC_MSG_RESULT(yes) |
222 | AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1, | |
223 | [old shrinker callback wants 3 args]) | |
224 | ],[ | |
225 | AC_MSG_RESULT(no) | |
608f8749 | 226 | |
93ce2b4c BB |
227 | dnl # |
228 | dnl # 3.0 - 3.11 API change | |
229 | dnl # ->shrink(struct shrinker *, | |
230 | dnl # struct shrink_control *sc) | |
231 | dnl # | |
232 | AC_MSG_CHECKING( | |
608f8749 BB |
233 | [whether new 2-argument shrinker exists]) |
234 | ZFS_LINUX_TEST_RESULT([shrinker_cb_shrink_control], [ | |
93ce2b4c BB |
235 | AC_MSG_RESULT(yes) |
236 | AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1, | |
237 | [new shrinker callback wants 2 args]) | |
238 | ],[ | |
239 | AC_MSG_RESULT(no) | |
608f8749 | 240 | |
93ce2b4c BB |
241 | dnl # |
242 | dnl # 3.12 API change, | |
243 | dnl # ->shrink() is logically split in to | |
244 | dnl # ->count_objects() and ->scan_objects() | |
245 | dnl # | |
246 | AC_MSG_CHECKING( | |
247 | [whether ->count_objects callback exists]) | |
608f8749 BB |
248 | ZFS_LINUX_TEST_RESULT( |
249 | [shrinker_cb_shrink_control_split], [ | |
93ce2b4c BB |
250 | AC_MSG_RESULT(yes) |
251 | AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, | |
252 | 1, [->count_objects exists]) | |
253 | ],[ | |
608f8749 | 254 | ZFS_LINUX_TEST_ERROR([shrinker]) |
93ce2b4c BB |
255 | ]) |
256 | ]) | |
257 | ]) | |
258 | ]) | |
93ce2b4c BB |
259 | ]) |
260 | ||
261 | dnl # | |
262 | dnl # 2.6.39 API change, | |
263 | dnl # Shrinker adjust to use common shrink_control structure. | |
264 | dnl # | |
608f8749 BB |
265 | AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT], [ |
266 | ZFS_LINUX_TEST_SRC([shrink_control_struct], [ | |
93ce2b4c BB |
267 | #include <linux/mm.h> |
268 | ],[ | |
269 | struct shrink_control sc __attribute__ ((unused)); | |
270 | ||
271 | sc.nr_to_scan = 0; | |
272 | sc.gfp_mask = GFP_KERNEL; | |
608f8749 BB |
273 | ]) |
274 | ]) | |
275 | ||
276 | AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT], [ | |
277 | AC_MSG_CHECKING([whether struct shrink_control exists]) | |
278 | ZFS_LINUX_TEST_RESULT([shrink_control_struct], [ | |
93ce2b4c BB |
279 | AC_MSG_RESULT(yes) |
280 | AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1, | |
608f8749 | 281 | [struct shrink_control exists]) |
93ce2b4c BB |
282 | ],[ |
283 | AC_MSG_RESULT(no) | |
284 | ]) | |
285 | ]) | |
608f8749 BB |
286 | |
287 | AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER], [ | |
288 | ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK | |
289 | ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_INSTANCES_LIST_HEAD | |
290 | ZFS_AC_KERNEL_SRC_NR_CACHED_OBJECTS | |
291 | ZFS_AC_KERNEL_SRC_FREE_CACHED_OBJECTS | |
292 | ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID | |
293 | ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK | |
294 | ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT | |
295 | ]) | |
296 | ||
297 | AC_DEFUN([ZFS_AC_KERNEL_SHRINKER], [ | |
298 | ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK | |
299 | ZFS_AC_KERNEL_SUPER_BLOCK_S_INSTANCES_LIST_HEAD | |
300 | ZFS_AC_KERNEL_NR_CACHED_OBJECTS | |
301 | ZFS_AC_KERNEL_FREE_CACHED_OBJECTS | |
302 | ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID | |
303 | ZFS_AC_KERNEL_SHRINKER_CALLBACK | |
304 | ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT | |
305 | ]) |