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.
7 AC_DEFUN([ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK], [
8 ZFS_LINUX_TEST_SRC([super_block_s_shrink], [
11 static const struct super_block
12 sb __attribute__ ((unused)) = {
13 .s_shrink.seeks = DEFAULT_SEEKS,
21 dnl # s_shrink is now a pointer.
23 AC_DEFUN([ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK_PTR], [
24 ZFS_LINUX_TEST_SRC([super_block_s_shrink_ptr], [
26 static unsigned long shrinker_cb(struct shrinker *shrink,
27 struct shrink_control *sc) { return 0; }
28 static struct shrinker shrinker = {
29 .count_objects = shrinker_cb,
30 .scan_objects = shrinker_cb,
31 .seeks = DEFAULT_SEEKS,
33 static const struct super_block
34 sb __attribute__ ((unused)) = {
35 .s_shrink = &shrinker,
40 AC_DEFUN([ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK], [
41 AC_MSG_CHECKING([whether super_block has s_shrink])
42 ZFS_LINUX_TEST_RESULT([super_block_s_shrink], [
44 AC_DEFINE(HAVE_SUPER_BLOCK_S_SHRINK, 1,
45 [have super_block s_shrink])
48 AC_MSG_CHECKING([whether super_block has s_shrink pointer])
49 ZFS_LINUX_TEST_RESULT([super_block_s_shrink_ptr], [
51 AC_DEFINE(HAVE_SUPER_BLOCK_S_SHRINK_PTR, 1,
52 [have super_block s_shrink pointer])
55 ZFS_LINUX_TEST_ERROR([sb->s_shrink()])
62 dnl # The nid member was added to struct shrink_control to support
63 dnl # NUMA-aware shrinkers.
65 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID], [
66 ZFS_LINUX_TEST_SRC([shrink_control_nid], [
69 struct shrink_control sc __attribute__ ((unused));
70 unsigned long scnidsize __attribute__ ((unused)) =
75 AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID], [
76 AC_MSG_CHECKING([whether shrink_control has nid])
77 ZFS_LINUX_TEST_RESULT([shrink_control_nid], [
79 AC_DEFINE(SHRINK_CONTROL_HAS_NID, 1,
80 [struct shrink_control has nid])
86 AC_DEFUN([ZFS_AC_KERNEL_SRC_REGISTER_SHRINKER_VARARG], [
87 ZFS_LINUX_TEST_SRC([register_shrinker_vararg], [
89 static unsigned long shrinker_cb(struct shrinker *shrink,
90 struct shrink_control *sc) { return 0; }
92 struct shrinker cache_shrinker = {
93 .count_objects = shrinker_cb,
94 .scan_objects = shrinker_cb,
95 .seeks = DEFAULT_SEEKS,
97 register_shrinker(&cache_shrinker, "vararg-reg-shrink-test");
101 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK], [
102 ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control], [
103 #include <linux/mm.h>
104 static int shrinker_cb(struct shrinker *shrink,
105 struct shrink_control *sc) { return 0; }
107 struct shrinker cache_shrinker = {
108 .shrink = shrinker_cb,
109 .seeks = DEFAULT_SEEKS,
111 register_shrinker(&cache_shrinker);
114 ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control_split], [
115 #include <linux/mm.h>
116 static unsigned long shrinker_cb(struct shrinker *shrink,
117 struct shrink_control *sc) { return 0; }
119 struct shrinker cache_shrinker = {
120 .count_objects = shrinker_cb,
121 .scan_objects = shrinker_cb,
122 .seeks = DEFAULT_SEEKS,
124 register_shrinker(&cache_shrinker);
130 dnl # register_shrinker has been replaced by shrinker_register.
132 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER_REGISTER], [
133 ZFS_LINUX_TEST_SRC([shrinker_register], [
134 #include <linux/shrinker.h>
135 static unsigned long shrinker_cb(struct shrinker *shrink,
136 struct shrink_control *sc) { return 0; }
138 struct shrinker cache_shrinker = {
139 .count_objects = shrinker_cb,
140 .scan_objects = shrinker_cb,
141 .seeks = DEFAULT_SEEKS,
143 shrinker_register(&cache_shrinker);
147 AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_CALLBACK],[
150 dnl # register_shrinker() becomes a var-arg function that takes
151 dnl # a printf-style format string as args > 0
153 AC_MSG_CHECKING([whether new var-arg register_shrinker() exists])
154 ZFS_LINUX_TEST_RESULT([register_shrinker_vararg], [
156 AC_DEFINE(HAVE_REGISTER_SHRINKER_VARARG, 1,
157 [register_shrinker is vararg])
159 dnl # We assume that the split shrinker callback exists if the
160 dnl # vararg register_shrinker() exists, because the latter is
161 dnl # a much more recent addition, and the macro test for the
162 dnl # var-arg version only works if the callback is split
163 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, 1,
164 [cs->count_objects exists])
168 dnl # 3.0 - 3.11 API change
169 dnl # cs->shrink(struct shrinker *, struct shrink_control *sc)
171 AC_MSG_CHECKING([whether new 2-argument shrinker exists])
172 ZFS_LINUX_TEST_RESULT([shrinker_cb_shrink_control], [
174 AC_DEFINE(HAVE_SINGLE_SHRINKER_CALLBACK, 1,
175 [new shrinker callback wants 2 args])
180 dnl # 3.12 API change,
181 dnl # cs->shrink() is logically split in to
182 dnl # cs->count_objects() and cs->scan_objects()
185 [whether cs->count_objects callback exists])
186 ZFS_LINUX_TEST_RESULT(
187 [shrinker_cb_shrink_control_split],[
189 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, 1,
190 [cs->count_objects exists])
195 [whether shrinker_register exists])
196 ZFS_LINUX_TEST_RESULT([shrinker_register], [
198 AC_DEFINE(HAVE_SHRINKER_REGISTER, 1,
199 [shrinker_register exists])
201 dnl # We assume that the split shrinker
202 dnl # callback exists if
203 dnl # shrinker_register() exists,
204 dnl # because the latter is a much more
205 dnl # recent addition, and the macro
206 dnl # test for shrinker_register() only
207 dnl # works if the callback is split
208 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
209 1, [cs->count_objects exists])
212 ZFS_LINUX_TEST_ERROR([shrinker])
220 dnl # 2.6.39 API change,
221 dnl # Shrinker adjust to use common shrink_control structure.
223 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT], [
224 ZFS_LINUX_TEST_SRC([shrink_control_struct], [
225 #include <linux/mm.h>
227 struct shrink_control sc __attribute__ ((unused));
230 sc.gfp_mask = GFP_KERNEL;
234 AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT], [
235 AC_MSG_CHECKING([whether struct shrink_control exists])
236 ZFS_LINUX_TEST_RESULT([shrink_control_struct], [
238 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
239 [struct shrink_control exists])
241 ZFS_LINUX_TEST_ERROR([shrink_control])
245 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER], [
246 ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK
247 ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK_PTR
248 ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID
249 ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK
250 ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT
251 ZFS_AC_KERNEL_SRC_REGISTER_SHRINKER_VARARG
252 ZFS_AC_KERNEL_SRC_SHRINKER_REGISTER
255 AC_DEFUN([ZFS_AC_KERNEL_SHRINKER], [
256 ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK
257 ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID
258 ZFS_AC_KERNEL_SHRINKER_CALLBACK
259 ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT