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 int shrink(struct shrinker *s, struct shrink_control *sc)
14 static const struct super_block
15 sb __attribute__ ((unused)) = {
16 .s_shrink.seeks = DEFAULT_SEEKS,
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], [
27 ZFS_LINUX_TEST_ERROR([sb->s_shrink()])
33 dnl # The nid member was added to struct shrink_control to support
34 dnl # NUMA-aware shrinkers.
36 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID], [
37 ZFS_LINUX_TEST_SRC([shrink_control_nid], [
40 struct shrink_control sc __attribute__ ((unused));
41 unsigned long scnidsize __attribute__ ((unused)) =
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], [
50 AC_DEFINE(SHRINK_CONTROL_HAS_NID, 1,
51 [struct shrink_control has nid])
57 AC_DEFUN([ZFS_AC_KERNEL_SRC_REGISTER_SHRINKER_VARARG], [
58 ZFS_LINUX_TEST_SRC([register_shrinker_vararg], [
60 unsigned long shrinker_cb(struct shrinker *shrink,
61 struct shrink_control *sc) { return 0; }
63 struct shrinker cache_shrinker = {
64 .count_objects = shrinker_cb,
65 .scan_objects = shrinker_cb,
66 .seeks = DEFAULT_SEEKS,
68 register_shrinker(&cache_shrinker, "vararg-reg-shrink-test");
72 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK], [
73 ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control], [
75 int shrinker_cb(struct shrinker *shrink,
76 struct shrink_control *sc) { return 0; }
78 struct shrinker cache_shrinker = {
79 .shrink = shrinker_cb,
80 .seeks = DEFAULT_SEEKS,
82 register_shrinker(&cache_shrinker);
85 ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control_split], [
87 unsigned long shrinker_cb(struct shrinker *shrink,
88 struct shrink_control *sc) { return 0; }
90 struct shrinker cache_shrinker = {
91 .count_objects = shrinker_cb,
92 .scan_objects = shrinker_cb,
93 .seeks = DEFAULT_SEEKS,
95 register_shrinker(&cache_shrinker);
99 AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_CALLBACK],[
102 dnl # register_shrinker() becomes a var-arg function that takes
103 dnl # a printf-style format string as args > 0
105 AC_MSG_CHECKING([whether new var-arg register_shrinker() exists])
106 ZFS_LINUX_TEST_RESULT([register_shrinker_vararg], [
108 AC_DEFINE(HAVE_REGISTER_SHRINKER_VARARG, 1,
109 [register_shrinker is vararg])
111 dnl # We assume that the split shrinker callback exists if the
112 dnl # vararg register_shrinker() exists, because the latter is
113 dnl # a much more recent addition, and the macro test for the
114 dnl # var-arg version only works if the callback is split
115 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, 1,
116 [cs->count_objects exists])
120 dnl # 3.0 - 3.11 API change
121 dnl # cs->shrink(struct shrinker *, struct shrink_control *sc)
123 AC_MSG_CHECKING([whether new 2-argument shrinker exists])
124 ZFS_LINUX_TEST_RESULT([shrinker_cb_shrink_control], [
126 AC_DEFINE(HAVE_SINGLE_SHRINKER_CALLBACK, 1,
127 [new shrinker callback wants 2 args])
132 dnl # 3.12 API change,
133 dnl # cs->shrink() is logically split in to
134 dnl # cs->count_objects() and cs->scan_objects()
136 AC_MSG_CHECKING([if cs->count_objects callback exists])
137 ZFS_LINUX_TEST_RESULT(
138 [shrinker_cb_shrink_control_split],[
140 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, 1,
141 [cs->count_objects exists])
143 ZFS_LINUX_TEST_ERROR([shrinker])
150 dnl # 2.6.39 API change,
151 dnl # Shrinker adjust to use common shrink_control structure.
153 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT], [
154 ZFS_LINUX_TEST_SRC([shrink_control_struct], [
155 #include <linux/mm.h>
157 struct shrink_control sc __attribute__ ((unused));
160 sc.gfp_mask = GFP_KERNEL;
164 AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT], [
165 AC_MSG_CHECKING([whether struct shrink_control exists])
166 ZFS_LINUX_TEST_RESULT([shrink_control_struct], [
168 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
169 [struct shrink_control exists])
171 ZFS_LINUX_TEST_ERROR([shrink_control])
175 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER], [
176 ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK
177 ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID
178 ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK
179 ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT
180 ZFS_AC_KERNEL_SRC_REGISTER_SHRINKER_VARARG
183 AC_DEFUN([ZFS_AC_KERNEL_SHRINKER], [
184 ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK
185 ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID
186 ZFS_AC_KERNEL_SHRINKER_CALLBACK
187 ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT