]> git.proxmox.com Git - mirror_zfs.git/blame - config/kernel-shrink.m4
Linux 5.19 compat: bdev_max_secure_erase_sectors()
[mirror_zfs.git] / config / kernel-shrink.m4
CommitLineData
ab26409d
BB
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 #
608f8749
BB
7AC_DEFUN([ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK], [
8 ZFS_LINUX_TEST_SRC([super_block_s_shrink], [
ab26409d 9 #include <linux/fs.h>
c38367c7
RY
10
11 int shrink(struct shrinker *s, struct shrink_control *sc)
12 { return 0; }
13
14 static const struct super_block
15 sb __attribute__ ((unused)) = {
ab26409d
BB
16 .s_shrink.seeks = DEFAULT_SEEKS,
17 .s_shrink.batch = 0,
18 };
608f8749
BB
19 ],[])
20])
21
22AC_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], [
ab26409d 25 AC_MSG_RESULT(yes)
ab26409d 26 ],[
066e8252 27 ZFS_LINUX_TEST_ERROR([sb->s_shrink()])
ab26409d
BB
28 ])
29])
90947b23
TC
30
31dnl #
32dnl # 3.12 API change
33dnl # The nid member was added to struct shrink_control to support
34dnl # NUMA-aware shrinkers.
35dnl #
608f8749
BB
36AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID], [
37 ZFS_LINUX_TEST_SRC([shrink_control_nid], [
90947b23
TC
38 #include <linux/fs.h>
39 ],[
40 struct shrink_control sc __attribute__ ((unused));
41 unsigned long scnidsize __attribute__ ((unused)) =
42 sizeof(sc.nid);
608f8749
BB
43 ])
44])
45
46AC_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], [
90947b23
TC
49 AC_MSG_RESULT(yes)
50 AC_DEFINE(SHRINK_CONTROL_HAS_NID, 1,
51 [struct shrink_control has nid])
52 ],[
53 AC_MSG_RESULT(no)
54 ])
55])
93ce2b4c 56
608f8749 57AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK], [
608f8749
BB
58 ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control], [
59 #include <linux/mm.h>
60 int shrinker_cb(struct shrinker *shrink,
61 struct shrink_control *sc) { return 0; }
93ce2b4c
BB
62 ],[
63 struct shrinker cache_shrinker = {
64 .shrink = shrinker_cb,
65 .seeks = DEFAULT_SEEKS,
66 };
67 register_shrinker(&cache_shrinker);
608f8749
BB
68 ])
69
70 ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control_split], [
71 #include <linux/mm.h>
72 unsigned long shrinker_cb(struct shrinker *shrink,
73 struct shrink_control *sc) { return 0; }
93ce2b4c 74 ],[
608f8749
BB
75 struct shrinker cache_shrinker = {
76 .count_objects = shrinker_cb,
77 .scan_objects = shrinker_cb,
78 .seeks = DEFAULT_SEEKS,
79 };
80 register_shrinker(&cache_shrinker);
81 ])
82])
83
84AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_CALLBACK],[
85 dnl #
066e8252
BB
86 dnl # 3.0 - 3.11 API change
87 dnl # ->shrink(struct shrinker *, struct shrink_control *sc)
608f8749 88 dnl #
066e8252
BB
89 AC_MSG_CHECKING([whether new 2-argument shrinker exists])
90 ZFS_LINUX_TEST_RESULT([shrinker_cb_shrink_control], [
93ce2b4c 91 AC_MSG_RESULT(yes)
066e8252
BB
92 AC_DEFINE(HAVE_SINGLE_SHRINKER_CALLBACK, 1,
93 [new shrinker callback wants 2 args])
93ce2b4c
BB
94 ],[
95 AC_MSG_RESULT(no)
608f8749 96
93ce2b4c 97 dnl #
066e8252
BB
98 dnl # 3.12 API change,
99 dnl # ->shrink() is logically split in to
100 dnl # ->count_objects() and ->scan_objects()
93ce2b4c 101 dnl #
066e8252
BB
102 AC_MSG_CHECKING([whether ->count_objects callback exists])
103 ZFS_LINUX_TEST_RESULT([shrinker_cb_shrink_control_split], [
93ce2b4c 104 AC_MSG_RESULT(yes)
066e8252
BB
105 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, 1,
106 [->count_objects exists])
93ce2b4c 107 ],[
066e8252 108 ZFS_LINUX_TEST_ERROR([shrinker])
93ce2b4c
BB
109 ])
110 ])
93ce2b4c
BB
111])
112
113dnl #
114dnl # 2.6.39 API change,
115dnl # Shrinker adjust to use common shrink_control structure.
116dnl #
608f8749
BB
117AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT], [
118 ZFS_LINUX_TEST_SRC([shrink_control_struct], [
93ce2b4c
BB
119 #include <linux/mm.h>
120 ],[
121 struct shrink_control sc __attribute__ ((unused));
122
123 sc.nr_to_scan = 0;
124 sc.gfp_mask = GFP_KERNEL;
608f8749
BB
125 ])
126])
127
128AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT], [
129 AC_MSG_CHECKING([whether struct shrink_control exists])
130 ZFS_LINUX_TEST_RESULT([shrink_control_struct], [
93ce2b4c
BB
131 AC_MSG_RESULT(yes)
132 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
608f8749 133 [struct shrink_control exists])
93ce2b4c 134 ],[
066e8252 135 ZFS_LINUX_TEST_ERROR([shrink_control])
93ce2b4c
BB
136 ])
137])
608f8749
BB
138
139AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER], [
140 ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK
608f8749
BB
141 ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID
142 ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK
143 ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT
144])
145
146AC_DEFUN([ZFS_AC_KERNEL_SHRINKER], [
147 ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK
608f8749
BB
148 ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID
149 ZFS_AC_KERNEL_SHRINKER_CALLBACK
150 ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT
151])