]>
Commit | Line | Data |
---|---|---|
70e083d2 TG |
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_SHRINK], [ | |
8 | AC_MSG_CHECKING([whether super_block has s_shrink]) | |
9 | ZFS_LINUX_TRY_COMPILE([ | |
10 | #include <linux/fs.h> | |
11 | ||
12 | int shrink(struct shrinker *s, struct shrink_control *sc) | |
13 | { return 0; } | |
14 | ||
15 | static const struct super_block | |
16 | sb __attribute__ ((unused)) = { | |
17 | .s_shrink.shrink = shrink, | |
18 | .s_shrink.seeks = DEFAULT_SEEKS, | |
19 | .s_shrink.batch = 0, | |
20 | }; | |
21 | ],[ | |
22 | ],[ | |
23 | AC_MSG_RESULT(yes) | |
24 | AC_DEFINE(HAVE_SHRINK, 1, [struct super_block has s_shrink]) | |
25 | ||
26 | ],[ | |
27 | AC_MSG_RESULT(no) | |
28 | ]) | |
29 | ]) | |
30 | ||
31 | dnl # | |
32 | dnl # 3.3 API change | |
33 | dnl # The super_block structure was changed to use an hlist_node instead | |
34 | dnl # of a list_head for the .s_instance linkage. | |
35 | dnl # | |
36 | dnl # This was done in part to resolve a race in the iterate_supers_type() | |
37 | dnl # function which was introduced in Linux 3.0 kernel. The iterator | |
38 | dnl # was supposed to provide a safe way to call an arbitrary function on | |
39 | dnl # all super blocks of a specific type. Unfortunately, because a | |
40 | dnl # list_head was used it was possible for iterate_supers_type() to | |
41 | dnl # get stuck spinning a super block which was just deactivated. | |
42 | dnl # | |
43 | dnl # This can occur because when the list head is removed from the | |
44 | dnl # fs_supers list it is reinitialized to point to itself. If the | |
45 | dnl # iterate_supers_type() function happened to be processing the | |
46 | dnl # removed list_head it will get stuck spinning on that list_head. | |
47 | dnl # | |
48 | dnl # To resolve the issue for existing 3.0 - 3.2 kernels we detect when | |
49 | dnl # a list_head is used. Then to prevent the spinning from occurring | |
50 | dnl # the .next pointer is set to the fs_supers list_head which ensures | |
51 | dnl # the iterate_supers_type() function will always terminate. | |
52 | dnl # | |
53 | AC_DEFUN([ZFS_AC_KERNEL_S_INSTANCES_LIST_HEAD], [ | |
54 | AC_MSG_CHECKING([whether super_block has s_instances list_head]) | |
55 | ZFS_LINUX_TRY_COMPILE([ | |
56 | #include <linux/fs.h> | |
57 | ],[ | |
58 | struct super_block sb __attribute__ ((unused)); | |
59 | ||
60 | INIT_LIST_HEAD(&sb.s_instances); | |
61 | ],[ | |
62 | AC_MSG_RESULT(yes) | |
63 | AC_DEFINE(HAVE_S_INSTANCES_LIST_HEAD, 1, | |
64 | [struct super_block has s_instances list_head]) | |
65 | ],[ | |
66 | AC_MSG_RESULT(no) | |
67 | ]) | |
68 | ]) | |
69 | ||
70 | AC_DEFUN([ZFS_AC_KERNEL_NR_CACHED_OBJECTS], [ | |
71 | AC_MSG_CHECKING([whether sops->nr_cached_objects() exists]) | |
72 | ZFS_LINUX_TRY_COMPILE([ | |
73 | #include <linux/fs.h> | |
74 | ||
75 | int nr_cached_objects(struct super_block *sb) { return 0; } | |
76 | ||
77 | static const struct super_operations | |
78 | sops __attribute__ ((unused)) = { | |
79 | .nr_cached_objects = nr_cached_objects, | |
80 | }; | |
81 | ],[ | |
82 | ],[ | |
83 | AC_MSG_RESULT(yes) | |
84 | AC_DEFINE(HAVE_NR_CACHED_OBJECTS, 1, | |
85 | [sops->nr_cached_objects() exists]) | |
86 | ],[ | |
87 | AC_MSG_RESULT(no) | |
88 | ]) | |
89 | ]) | |
90 | ||
91 | AC_DEFUN([ZFS_AC_KERNEL_FREE_CACHED_OBJECTS], [ | |
92 | AC_MSG_CHECKING([whether sops->free_cached_objects() exists]) | |
93 | ZFS_LINUX_TRY_COMPILE([ | |
94 | #include <linux/fs.h> | |
95 | ||
96 | void free_cached_objects(struct super_block *sb, int x) | |
97 | { return; } | |
98 | ||
99 | static const struct super_operations | |
100 | sops __attribute__ ((unused)) = { | |
101 | .free_cached_objects = free_cached_objects, | |
102 | }; | |
103 | ],[ | |
104 | ],[ | |
105 | AC_MSG_RESULT(yes) | |
106 | AC_DEFINE(HAVE_FREE_CACHED_OBJECTS, 1, | |
107 | [sops->free_cached_objects() exists]) | |
108 | ],[ | |
109 | AC_MSG_RESULT(no) | |
110 | ]) | |
111 | ]) | |
112 | ||
113 | dnl # | |
114 | dnl # 3.12 API change | |
115 | dnl # The nid member was added to struct shrink_control to support | |
116 | dnl # NUMA-aware shrinkers. | |
117 | dnl # | |
118 | AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID], [ | |
119 | AC_MSG_CHECKING([whether shrink_control has nid]) | |
120 | ZFS_LINUX_TRY_COMPILE([ | |
121 | #include <linux/fs.h> | |
122 | ],[ | |
123 | struct shrink_control sc __attribute__ ((unused)); | |
124 | unsigned long scnidsize __attribute__ ((unused)) = | |
125 | sizeof(sc.nid); | |
126 | ],[ | |
127 | AC_MSG_RESULT(yes) | |
128 | AC_DEFINE(SHRINK_CONTROL_HAS_NID, 1, | |
129 | [struct shrink_control has nid]) | |
130 | ],[ | |
131 | AC_MSG_RESULT(no) | |
132 | ]) | |
133 | ]) |