Fix some nits in zfs_getpages()
[zfs.git] / config / kernel-shrink.m4
blobc4258f4e40d6e96a3fffe030d8c25ccfb74b266d
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_SRC_SUPER_BLOCK_S_SHRINK], [
8         ZFS_LINUX_TEST_SRC([super_block_s_shrink], [
9                 #include <linux/fs.h>
11                 static const struct super_block
12                     sb __attribute__ ((unused)) = {
13                         .s_shrink.seeks = DEFAULT_SEEKS,
14                         .s_shrink.batch = 0,
15                 };
16         ],[])
19 dnl #
20 dnl # 6.7 API change
21 dnl # s_shrink is now a pointer.
22 dnl #
23 AC_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         ],[])
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], [
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         ])
60 dnl #
61 dnl # 6.0 API change
62 dnl # register_shrinker() becomes a var-arg function that takes
63 dnl # a printf-style format string as args > 0
64 dnl #
65 AC_DEFUN([ZFS_AC_KERNEL_SRC_REGISTER_SHRINKER_VARARG], [
66         ZFS_LINUX_TEST_SRC([register_shrinker_vararg], [
67                 #include <linux/mm.h>
68                 static unsigned long shrinker_cb(struct shrinker *shrink,
69                     struct shrink_control *sc) { return 0; }
70         ],[
71                 struct shrinker cache_shrinker = {
72                         .count_objects = shrinker_cb,
73                         .scan_objects = shrinker_cb,
74                         .seeks = DEFAULT_SEEKS,
75                 };
76                 register_shrinker(&cache_shrinker, "vararg-reg-shrink-test");
77         ])
80 AC_DEFUN([ZFS_AC_KERNEL_REGISTER_SHRINKER_VARARG],[
81         AC_MSG_CHECKING([whether new var-arg register_shrinker() exists])
82         ZFS_LINUX_TEST_RESULT([register_shrinker_vararg], [
83                 AC_MSG_RESULT(yes)
84                 AC_DEFINE(HAVE_REGISTER_SHRINKER_VARARG, 1,
85                     [register_shrinker is vararg])
86         ],[
87                 AC_MSG_RESULT(no)
88         ])
91 dnl #
92 dnl # 6.7 API change
93 dnl # register_shrinker has been replaced by shrinker_register.
94 dnl #
95 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER_REGISTER], [
96         ZFS_LINUX_TEST_SRC([shrinker_register], [
97                 #include <linux/shrinker.h>
98                 static unsigned long shrinker_cb(struct shrinker *shrink,
99                     struct shrink_control *sc) { return 0; }
100         ],[
101                 struct shrinker cache_shrinker = {
102                         .count_objects = shrinker_cb,
103                         .scan_objects = shrinker_cb,
104                         .seeks = DEFAULT_SEEKS,
105                 };
106                 shrinker_register(&cache_shrinker);
107         ])
110 AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_REGISTER], [
111         AC_MSG_CHECKING([whether shrinker_register() exists])
112         ZFS_LINUX_TEST_RESULT([shrinker_register], [
113                 AC_MSG_RESULT(yes)
114                 AC_DEFINE(HAVE_SHRINKER_REGISTER, 1, [shrinker_register exists])
115         ], [
116                 AC_MSG_RESULT(no)
117         ])
120 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER], [
121         ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK
122         ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK_PTR
123         ZFS_AC_KERNEL_SRC_REGISTER_SHRINKER_VARARG
124         ZFS_AC_KERNEL_SRC_SHRINKER_REGISTER
127 AC_DEFUN([ZFS_AC_KERNEL_SHRINKER], [
128         ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK
129         ZFS_AC_KERNEL_REGISTER_SHRINKER_VARARG
130         ZFS_AC_KERNEL_SHRINKER_REGISTER