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