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_SHRINKER_CALLBACK], [
58 ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control], [
60 int shrinker_cb(struct shrinker *shrink,
61 struct shrink_control *sc) { return 0; }
63 struct shrinker cache_shrinker = {
64 .shrink = shrinker_cb,
65 .seeks = DEFAULT_SEEKS,
67 register_shrinker(&cache_shrinker);
70 ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control_split], [
72 unsigned long shrinker_cb(struct shrinker *shrink,
73 struct shrink_control *sc) { return 0; }
75 struct shrinker cache_shrinker = {
76 .count_objects = shrinker_cb,
77 .scan_objects = shrinker_cb,
78 .seeks = DEFAULT_SEEKS,
80 register_shrinker(&cache_shrinker);
84 AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_CALLBACK],[
86 dnl # 3.0 - 3.11 API change
87 dnl # ->shrink(struct shrinker *, struct shrink_control *sc)
89 AC_MSG_CHECKING([whether new 2-argument shrinker exists])
90 ZFS_LINUX_TEST_RESULT([shrinker_cb_shrink_control], [
92 AC_DEFINE(HAVE_SINGLE_SHRINKER_CALLBACK, 1,
93 [new shrinker callback wants 2 args])
98 dnl # 3.12 API change,
99 dnl # ->shrink() is logically split in to
100 dnl # ->count_objects() and ->scan_objects()
102 AC_MSG_CHECKING([whether ->count_objects callback exists])
103 ZFS_LINUX_TEST_RESULT([shrinker_cb_shrink_control_split], [
105 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, 1,
106 [->count_objects exists])
108 ZFS_LINUX_TEST_ERROR([shrinker])
114 dnl # 2.6.39 API change,
115 dnl # Shrinker adjust to use common shrink_control structure.
117 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT], [
118 ZFS_LINUX_TEST_SRC([shrink_control_struct], [
119 #include <linux/mm.h>
121 struct shrink_control sc __attribute__ ((unused));
124 sc.gfp_mask = GFP_KERNEL;
128 AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT], [
129 AC_MSG_CHECKING([whether struct shrink_control exists])
130 ZFS_LINUX_TEST_RESULT([shrink_control_struct], [
132 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
133 [struct shrink_control exists])
135 ZFS_LINUX_TEST_ERROR([shrink_control])
139 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER], [
140 ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK
141 ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID
142 ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK
143 ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT
146 AC_DEFUN([ZFS_AC_KERNEL_SHRINKER], [
147 ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK
148 ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID
149 ZFS_AC_KERNEL_SHRINKER_CALLBACK
150 ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT