zdb: remove strtok
[zfs.git] / config / kernel-blkdev.m4
blob4b80d4dd29a58defbc0f43be384223e0439d02e0
1 dnl #
2 dnl # 2.6.38 API change,
3 dnl # Added blkdev_get_by_path()
4 dnl #
5 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH], [
6         ZFS_LINUX_TEST_SRC([blkdev_get_by_path], [
7                 #include <linux/fs.h>
8                 #include <linux/blkdev.h>
9         ], [
10                 struct block_device *bdev __attribute__ ((unused)) = NULL;
11                 const char *path = "path";
12                 fmode_t mode = 0;
13                 void *holder = NULL;
15                 bdev = blkdev_get_by_path(path, mode, holder);
16         ])
19 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH], [
20         AC_MSG_CHECKING([whether blkdev_get_by_path() exists])
21         ZFS_LINUX_TEST_RESULT([blkdev_get_by_path], [
22                 AC_MSG_RESULT(yes)
23         ], [
24                 ZFS_LINUX_TEST_ERROR([blkdev_get_by_path()])
25         ])
28 dnl #
29 dnl # 2.6.38 API change,
30 dnl # Added blkdev_put()
31 dnl #
32 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_PUT], [
33         ZFS_LINUX_TEST_SRC([blkdev_put], [
34                 #include <linux/fs.h>
35                 #include <linux/blkdev.h>
36         ], [
37                 struct block_device *bdev = NULL;
38                 fmode_t mode = 0;
40                 blkdev_put(bdev, mode);
41         ])
44 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_PUT], [
45         AC_MSG_CHECKING([whether blkdev_put() exists])
46         ZFS_LINUX_TEST_RESULT([blkdev_put], [
47                 AC_MSG_RESULT(yes)
48         ], [
49                 ZFS_LINUX_TEST_ERROR([blkdev_put()])
50         ])
53 dnl #
54 dnl # 4.1 API, exported blkdev_reread_part() symbol, back ported to the
55 dnl # 3.10.0 CentOS 7.x enterprise kernels.
56 dnl #
57 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_REREAD_PART], [
58         ZFS_LINUX_TEST_SRC([blkdev_reread_part], [
59                 #include <linux/fs.h>
60                 #include <linux/blkdev.h>
61         ], [
62                 struct block_device *bdev = NULL;
63                 int error;
65                 error = blkdev_reread_part(bdev);
66         ])
69 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_REREAD_PART], [
70         AC_MSG_CHECKING([whether blkdev_reread_part() exists])
71         ZFS_LINUX_TEST_RESULT([blkdev_reread_part], [
72                 AC_MSG_RESULT(yes)
73                 AC_DEFINE(HAVE_BLKDEV_REREAD_PART, 1,
74                     [blkdev_reread_part() exists])
75         ], [
76                 AC_MSG_RESULT(no)
77         ])
80 dnl #
81 dnl # check_disk_change() was removed in 5.10
82 dnl #
83 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_CHECK_DISK_CHANGE], [
84         ZFS_LINUX_TEST_SRC([check_disk_change], [
85                 #include <linux/fs.h>
86                 #include <linux/blkdev.h>
87         ], [
88                 struct block_device *bdev = NULL;
89                 bool error;
91                 error = check_disk_change(bdev);
92         ])
95 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_CHECK_DISK_CHANGE], [
96         AC_MSG_CHECKING([whether check_disk_change() exists])
97         ZFS_LINUX_TEST_RESULT([check_disk_change], [
98                 AC_MSG_RESULT(yes)
99                 AC_DEFINE(HAVE_CHECK_DISK_CHANGE, 1,
100                     [check_disk_change() exists])
101         ], [
102                 AC_MSG_RESULT(no)
103         ])
106 dnl #
107 dnl # 5.10 API, check_disk_change() is removed, in favor of
108 dnl # bdev_check_media_change(), which doesn't force revalidation
109 dnl #
110 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_CHECK_MEDIA_CHANGE], [
111         ZFS_LINUX_TEST_SRC([bdev_check_media_change], [
112                 #include <linux/fs.h>
113                 #include <linux/blkdev.h>
114         ], [
115                 struct block_device *bdev = NULL;
116                 int error;
118                 error = bdev_check_media_change(bdev);
119         ])
122 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_CHECK_MEDIA_CHANGE], [
123         AC_MSG_CHECKING([whether bdev_disk_changed() exists])
124         ZFS_LINUX_TEST_RESULT([bdev_check_media_change], [
125                 AC_MSG_RESULT(yes)
126                 AC_DEFINE(HAVE_BDEV_CHECK_MEDIA_CHANGE, 1,
127                     [bdev_check_media_change() exists])
128         ], [
129                 AC_MSG_RESULT(no)
130         ])
133 dnl #
134 dnl # 2.6.22 API change
135 dnl # Single argument invalidate_bdev()
136 dnl #
137 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_INVALIDATE_BDEV], [
138         ZFS_LINUX_TEST_SRC([invalidate_bdev], [
139                 #include <linux/buffer_head.h>
140                 #include <linux/blkdev.h>
141         ],[
142                 struct block_device *bdev = NULL;
143                 invalidate_bdev(bdev);
144         ])
147 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_INVALIDATE_BDEV], [
148         AC_MSG_CHECKING([whether invalidate_bdev() exists])
149         ZFS_LINUX_TEST_RESULT([invalidate_bdev], [
150                 AC_MSG_RESULT(yes)
151         ],[
152                 ZFS_LINUX_TEST_ERROR([invalidate_bdev()])
153         ])
156 dnl #
157 dnl # 5.11 API, lookup_bdev() takes dev_t argument.
158 dnl # 2.6.27 API, lookup_bdev() was first exported.
159 dnl # 4.4.0-6.21 API, lookup_bdev() on Ubuntu takes mode argument.
160 dnl #
161 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_LOOKUP_BDEV], [
162         ZFS_LINUX_TEST_SRC([lookup_bdev_devt], [
163                 #include <linux/blkdev.h>
164         ], [
165                 int error __attribute__ ((unused));
166                 const char path[] = "/example/path";
167                 dev_t dev;
169                 error = lookup_bdev(path, &dev);
170         ])
172         ZFS_LINUX_TEST_SRC([lookup_bdev_1arg], [
173                 #include <linux/fs.h>
174                 #include <linux/blkdev.h>
175         ], [
176                 struct block_device *bdev __attribute__ ((unused));
177                 const char path[] = "/example/path";
179                 bdev = lookup_bdev(path);
180         ])
182         ZFS_LINUX_TEST_SRC([lookup_bdev_mode], [
183                 #include <linux/fs.h>
184         ], [
185                 struct block_device *bdev __attribute__ ((unused));
186                 const char path[] = "/example/path";
188                 bdev = lookup_bdev(path, FMODE_READ);
189         ])
192 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_LOOKUP_BDEV], [
193         AC_MSG_CHECKING([whether lookup_bdev() wants dev_t arg])
194         ZFS_LINUX_TEST_RESULT_SYMBOL([lookup_bdev_devt],
195             [lookup_bdev], [fs/block_dev.c], [
196                 AC_MSG_RESULT(yes)
197                 AC_DEFINE(HAVE_DEVT_LOOKUP_BDEV, 1,
198                     [lookup_bdev() wants dev_t arg])
199         ], [
200                 AC_MSG_RESULT(no)
202                 AC_MSG_CHECKING([whether lookup_bdev() wants 1 arg])
203                 ZFS_LINUX_TEST_RESULT_SYMBOL([lookup_bdev_1arg],
204                     [lookup_bdev], [fs/block_dev.c], [
205                         AC_MSG_RESULT(yes)
206                         AC_DEFINE(HAVE_1ARG_LOOKUP_BDEV, 1,
207                             [lookup_bdev() wants 1 arg])
208                 ], [
209                         AC_MSG_RESULT(no)
211                         AC_MSG_CHECKING([whether lookup_bdev() wants mode arg])
212                         ZFS_LINUX_TEST_RESULT_SYMBOL([lookup_bdev_mode],
213                             [lookup_bdev], [fs/block_dev.c], [
214                                 AC_MSG_RESULT(yes)
215                                 AC_DEFINE(HAVE_MODE_LOOKUP_BDEV, 1,
216                                     [lookup_bdev() wants mode arg])
217                         ], [
218                                 ZFS_LINUX_TEST_ERROR([lookup_bdev()])
219                         ])
220                 ])
221         ])
224 dnl #
225 dnl # 2.6.30 API change
226 dnl #
227 dnl # The bdev_physical_block_size() interface was added to provide a way
228 dnl # to determine the smallest write which can be performed without a
229 dnl # read-modify-write operation.
230 dnl #
231 dnl # Unfortunately, this interface isn't entirely reliable because
232 dnl # drives are sometimes known to misreport this value.
233 dnl #
234 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE], [
235         ZFS_LINUX_TEST_SRC([bdev_physical_block_size], [
236                 #include <linux/blkdev.h>
237         ],[
238                 struct block_device *bdev __attribute__ ((unused)) = NULL;
239                 bdev_physical_block_size(bdev);
240         ])
243 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE], [
244         AC_MSG_CHECKING([whether bdev_physical_block_size() is available])
245         ZFS_LINUX_TEST_RESULT([bdev_physical_block_size], [
246                 AC_MSG_RESULT(yes)
247         ],[
248                 ZFS_LINUX_TEST_ERROR([bdev_physical_block_size()])
249         ])
252 dnl #
253 dnl # 2.6.30 API change
254 dnl # Added bdev_logical_block_size().
255 dnl #
256 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE], [
257         ZFS_LINUX_TEST_SRC([bdev_logical_block_size], [
258                 #include <linux/blkdev.h>
259         ],[
260                 struct block_device *bdev __attribute__ ((unused)) = NULL;
261                 bdev_logical_block_size(bdev);
262         ])
265 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE], [
266         AC_MSG_CHECKING([whether bdev_logical_block_size() is available])
267         ZFS_LINUX_TEST_RESULT([bdev_logical_block_size], [
268                 AC_MSG_RESULT(yes)
269         ],[
270                 ZFS_LINUX_TEST_ERROR([bdev_logical_block_size()])
271         ])
274 dnl #
275 dnl # 5.11 API change
276 dnl # Added bdev_whole() helper.
277 dnl #
278 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_WHOLE], [
279         ZFS_LINUX_TEST_SRC([bdev_whole], [
280                 #include <linux/blkdev.h>
281         ],[
282                 struct block_device *bdev = NULL;
283                 bdev = bdev_whole(bdev);
284         ])
287 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE], [
288         AC_MSG_CHECKING([whether bdev_whole() is available])
289         ZFS_LINUX_TEST_RESULT([bdev_whole], [
290                 AC_MSG_RESULT(yes)
291                 AC_DEFINE(HAVE_BDEV_WHOLE, 1, [bdev_whole() is available])
292         ],[
293                 AC_MSG_RESULT(no)
294         ])
297 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV], [
298         ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH
299         ZFS_AC_KERNEL_SRC_BLKDEV_PUT
300         ZFS_AC_KERNEL_SRC_BLKDEV_REREAD_PART
301         ZFS_AC_KERNEL_SRC_BLKDEV_INVALIDATE_BDEV
302         ZFS_AC_KERNEL_SRC_BLKDEV_LOOKUP_BDEV
303         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE
304         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE
305         ZFS_AC_KERNEL_SRC_BLKDEV_CHECK_DISK_CHANGE
306         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_CHECK_MEDIA_CHANGE
307         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_WHOLE
310 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV], [
311         ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH
312         ZFS_AC_KERNEL_BLKDEV_PUT
313         ZFS_AC_KERNEL_BLKDEV_REREAD_PART
314         ZFS_AC_KERNEL_BLKDEV_INVALIDATE_BDEV
315         ZFS_AC_KERNEL_BLKDEV_LOOKUP_BDEV
316         ZFS_AC_KERNEL_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE
317         ZFS_AC_KERNEL_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE
318         ZFS_AC_KERNEL_BLKDEV_CHECK_DISK_CHANGE
319         ZFS_AC_KERNEL_BLKDEV_BDEV_CHECK_MEDIA_CHANGE
320         ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE