1dnl # 2dnl # 3.1 API change 3dnl # The super_block structure now stores a per-filesystem shrinker. 4dnl # This interface is preferable because it can be used to specifically 5dnl # target only the zfs filesystem for pruning. 6dnl # 7AC_DEFUN([ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK], [ 8 ZFS_LINUX_TEST_SRC([super_block_s_shrink], [ 9 #include <linux/fs.h> 10 11 static const struct super_block 12 sb __attribute__ ((unused)) = { 13 .s_shrink.seeks = DEFAULT_SEEKS, 14 .s_shrink.batch = 0, 15 }; 16 ],[]) 17]) 18 19dnl # 20dnl # 6.7 API change 21dnl # s_shrink is now a pointer. 22dnl # 23AC_DEFUN([ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK_PTR], [ 24 ZFS_LINUX_TEST_SRC([super_block_s_shrink_ptr], [ 25 #include <linux/fs.h> 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, 32 }; 33 static const struct super_block 34 sb __attribute__ ((unused)) = { 35 .s_shrink = &shrinker, 36 }; 37 ],[]) 38]) 39 40AC_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], [ 43 AC_MSG_RESULT(yes) 44 AC_DEFINE(HAVE_SUPER_BLOCK_S_SHRINK, 1, 45 [have super_block s_shrink]) 46 ],[ 47 AC_MSG_RESULT(no) 48 AC_MSG_CHECKING([whether super_block has s_shrink pointer]) 49 ZFS_LINUX_TEST_RESULT([super_block_s_shrink_ptr], [ 50 AC_MSG_RESULT(yes) 51 AC_DEFINE(HAVE_SUPER_BLOCK_S_SHRINK_PTR, 1, 52 [have super_block s_shrink pointer]) 53 ],[ 54 AC_MSG_RESULT(no) 55 ZFS_LINUX_TEST_ERROR([sb->s_shrink()]) 56 ]) 57 ]) 58]) 59 60dnl # 61dnl # 3.12 API change 62dnl # The nid member was added to struct shrink_control to support 63dnl # NUMA-aware shrinkers. 64dnl # 65AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID], [ 66 ZFS_LINUX_TEST_SRC([shrink_control_nid], [ 67 #include <linux/fs.h> 68 ],[ 69 struct shrink_control sc __attribute__ ((unused)); 70 unsigned long scnidsize __attribute__ ((unused)) = 71 sizeof(sc.nid); 72 ]) 73]) 74 75AC_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], [ 78 AC_MSG_RESULT(yes) 79 AC_DEFINE(SHRINK_CONTROL_HAS_NID, 1, 80 [struct shrink_control has nid]) 81 ],[ 82 AC_MSG_RESULT(no) 83 ]) 84]) 85 86AC_DEFUN([ZFS_AC_KERNEL_SRC_REGISTER_SHRINKER_VARARG], [ 87 ZFS_LINUX_TEST_SRC([register_shrinker_vararg], [ 88 #include <linux/mm.h> 89 static unsigned long shrinker_cb(struct shrinker *shrink, 90 struct shrink_control *sc) { return 0; } 91 ],[ 92 struct shrinker cache_shrinker = { 93 .count_objects = shrinker_cb, 94 .scan_objects = shrinker_cb, 95 .seeks = DEFAULT_SEEKS, 96 }; 97 register_shrinker(&cache_shrinker, "vararg-reg-shrink-test"); 98 ]) 99]) 100 101AC_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; } 106 ],[ 107 struct shrinker cache_shrinker = { 108 .shrink = shrinker_cb, 109 .seeks = DEFAULT_SEEKS, 110 }; 111 register_shrinker(&cache_shrinker); 112 ]) 113 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; } 118 ],[ 119 struct shrinker cache_shrinker = { 120 .count_objects = shrinker_cb, 121 .scan_objects = shrinker_cb, 122 .seeks = DEFAULT_SEEKS, 123 }; 124 register_shrinker(&cache_shrinker); 125 ]) 126]) 127 128dnl # 129dnl # 6.7 API change 130dnl # register_shrinker has been replaced by shrinker_register. 131dnl # 132AC_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; } 137 ],[ 138 struct shrinker cache_shrinker = { 139 .count_objects = shrinker_cb, 140 .scan_objects = shrinker_cb, 141 .seeks = DEFAULT_SEEKS, 142 }; 143 shrinker_register(&cache_shrinker); 144 ]) 145]) 146 147AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_CALLBACK],[ 148 dnl # 149 dnl # 6.0 API change 150 dnl # register_shrinker() becomes a var-arg function that takes 151 dnl # a printf-style format string as args > 0 152 dnl # 153 AC_MSG_CHECKING([whether new var-arg register_shrinker() exists]) 154 ZFS_LINUX_TEST_RESULT([register_shrinker_vararg], [ 155 AC_MSG_RESULT(yes) 156 AC_DEFINE(HAVE_REGISTER_SHRINKER_VARARG, 1, 157 [register_shrinker is vararg]) 158 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]) 165 ],[ 166 AC_MSG_RESULT(no) 167 dnl # 168 dnl # 3.0 - 3.11 API change 169 dnl # cs->shrink(struct shrinker *, struct shrink_control *sc) 170 dnl # 171 AC_MSG_CHECKING([whether new 2-argument shrinker exists]) 172 ZFS_LINUX_TEST_RESULT([shrinker_cb_shrink_control], [ 173 AC_MSG_RESULT(yes) 174 AC_DEFINE(HAVE_SINGLE_SHRINKER_CALLBACK, 1, 175 [new shrinker callback wants 2 args]) 176 ],[ 177 AC_MSG_RESULT(no) 178 179 dnl # 180 dnl # 3.12 API change, 181 dnl # cs->shrink() is logically split in to 182 dnl # cs->count_objects() and cs->scan_objects() 183 dnl # 184 AC_MSG_CHECKING( 185 [whether cs->count_objects callback exists]) 186 ZFS_LINUX_TEST_RESULT( 187 [shrinker_cb_shrink_control_split],[ 188 AC_MSG_RESULT(yes) 189 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, 1, 190 [cs->count_objects exists]) 191 ],[ 192 AC_MSG_RESULT(no) 193 194 AC_MSG_CHECKING( 195 [whether shrinker_register exists]) 196 ZFS_LINUX_TEST_RESULT([shrinker_register], [ 197 AC_MSG_RESULT(yes) 198 AC_DEFINE(HAVE_SHRINKER_REGISTER, 1, 199 [shrinker_register exists]) 200 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]) 210 ],[ 211 AC_MSG_RESULT(no) 212 ZFS_LINUX_TEST_ERROR([shrinker]) 213 ]) 214 ]) 215 ]) 216 ]) 217]) 218 219dnl # 220dnl # 2.6.39 API change, 221dnl # Shrinker adjust to use common shrink_control structure. 222dnl # 223AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT], [ 224 ZFS_LINUX_TEST_SRC([shrink_control_struct], [ 225 #include <linux/mm.h> 226 ],[ 227 struct shrink_control sc __attribute__ ((unused)); 228 229 sc.nr_to_scan = 0; 230 sc.gfp_mask = GFP_KERNEL; 231 ]) 232]) 233 234AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT], [ 235 AC_MSG_CHECKING([whether struct shrink_control exists]) 236 ZFS_LINUX_TEST_RESULT([shrink_control_struct], [ 237 AC_MSG_RESULT(yes) 238 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1, 239 [struct shrink_control exists]) 240 ],[ 241 ZFS_LINUX_TEST_ERROR([shrink_control]) 242 ]) 243]) 244 245AC_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 253]) 254 255AC_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 260]) 261