2 dnl # 2.6.38 API change,
3 dnl # Added blkdev_get_by_path()
5 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH], [
6 ZFS_LINUX_TEST_SRC([blkdev_get_by_path], [
8 #include <linux/blkdev.h>
10 struct block_device *bdev __attribute__ ((unused)) = NULL;
11 const char *path = "path";
15 bdev = blkdev_get_by_path(path, mode, holder);
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], [
24 ZFS_LINUX_TEST_ERROR([blkdev_get_by_path()])
29 dnl # 2.6.38 API change,
30 dnl # Added blkdev_put()
32 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_PUT], [
33 ZFS_LINUX_TEST_SRC([blkdev_put], [
35 #include <linux/blkdev.h>
37 struct block_device *bdev = NULL;
40 blkdev_put(bdev, mode);
44 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_PUT], [
45 AC_MSG_CHECKING([whether blkdev_put() exists])
46 ZFS_LINUX_TEST_RESULT([blkdev_put], [
49 ZFS_LINUX_TEST_ERROR([blkdev_put()])
54 dnl # 4.1 API, exported blkdev_reread_part() symbol, back ported to the
55 dnl # 3.10.0 CentOS 7.x enterprise kernels.
57 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_REREAD_PART], [
58 ZFS_LINUX_TEST_SRC([blkdev_reread_part], [
60 #include <linux/blkdev.h>
62 struct block_device *bdev = NULL;
65 error = blkdev_reread_part(bdev);
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], [
73 AC_DEFINE(HAVE_BLKDEV_REREAD_PART, 1,
74 [blkdev_reread_part() exists])
81 dnl # check_disk_change() was removed in 5.10
83 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_CHECK_DISK_CHANGE], [
84 ZFS_LINUX_TEST_SRC([check_disk_change], [
86 #include <linux/blkdev.h>
88 struct block_device *bdev = NULL;
91 error = check_disk_change(bdev);
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], [
99 AC_DEFINE(HAVE_CHECK_DISK_CHANGE, 1,
100 [check_disk_change() exists])
107 dnl # 5.10 API, check_disk_change() is removed, in favor of
108 dnl # bdev_check_media_change(), which doesn't force revalidation
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>
115 struct block_device *bdev = NULL;
118 error = bdev_check_media_change(bdev);
122 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_CHECK_MEDIA_CHANGE], [
123 AC_MSG_CHECKING([whether bdev_check_media_change() exists])
124 ZFS_LINUX_TEST_RESULT([bdev_check_media_change], [
126 AC_DEFINE(HAVE_BDEV_CHECK_MEDIA_CHANGE, 1,
127 [bdev_check_media_change() exists])
134 dnl # 2.6.22 API change
135 dnl # Single argument invalidate_bdev()
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>
142 struct block_device *bdev = NULL;
143 invalidate_bdev(bdev);
147 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_INVALIDATE_BDEV], [
148 AC_MSG_CHECKING([whether invalidate_bdev() exists])
149 ZFS_LINUX_TEST_RESULT([invalidate_bdev], [
152 ZFS_LINUX_TEST_ERROR([invalidate_bdev()])
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.
161 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_LOOKUP_BDEV], [
162 ZFS_LINUX_TEST_SRC([lookup_bdev_devt], [
163 #include <linux/blkdev.h>
165 int error __attribute__ ((unused));
166 const char path[] = "/example/path";
169 error = lookup_bdev(path, &dev);
172 ZFS_LINUX_TEST_SRC([lookup_bdev_1arg], [
173 #include <linux/fs.h>
174 #include <linux/blkdev.h>
176 struct block_device *bdev __attribute__ ((unused));
177 const char path[] = "/example/path";
179 bdev = lookup_bdev(path);
182 ZFS_LINUX_TEST_SRC([lookup_bdev_mode], [
183 #include <linux/fs.h>
185 struct block_device *bdev __attribute__ ((unused));
186 const char path[] = "/example/path";
188 bdev = lookup_bdev(path, FMODE_READ);
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], [
197 AC_DEFINE(HAVE_DEVT_LOOKUP_BDEV, 1,
198 [lookup_bdev() wants dev_t arg])
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], [
206 AC_DEFINE(HAVE_1ARG_LOOKUP_BDEV, 1,
207 [lookup_bdev() wants 1 arg])
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], [
215 AC_DEFINE(HAVE_MODE_LOOKUP_BDEV, 1,
216 [lookup_bdev() wants mode arg])
218 ZFS_LINUX_TEST_ERROR([lookup_bdev()])
225 dnl # 2.6.30 API change
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.
231 dnl # Unfortunately, this interface isn't entirely reliable because
232 dnl # drives are sometimes known to misreport this value.
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>
238 struct block_device *bdev __attribute__ ((unused)) = NULL;
239 bdev_physical_block_size(bdev);
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], [
248 ZFS_LINUX_TEST_ERROR([bdev_physical_block_size()])
253 dnl # 2.6.30 API change
254 dnl # Added bdev_logical_block_size().
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>
260 struct block_device *bdev __attribute__ ((unused)) = NULL;
261 bdev_logical_block_size(bdev);
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], [
270 ZFS_LINUX_TEST_ERROR([bdev_logical_block_size()])
275 dnl # 5.11 API change
276 dnl # Added bdev_whole() helper.
278 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_WHOLE], [
279 ZFS_LINUX_TEST_SRC([bdev_whole], [
280 #include <linux/blkdev.h>
282 struct block_device *bdev = NULL;
283 bdev = bdev_whole(bdev);
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], [
291 AC_DEFINE(HAVE_BDEV_WHOLE, 1, [bdev_whole() is available])
298 dnl # 5.19 API: blkdev_issue_secure_erase()
299 dnl # 3.10 API: blkdev_issue_discard(..., BLKDEV_DISCARD_SECURE)
301 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_ISSUE_SECURE_ERASE], [
302 ZFS_LINUX_TEST_SRC([blkdev_issue_secure_erase], [
303 #include <linux/blkdev.h>
305 struct block_device *bdev = NULL;
307 sector_t nr_sects = 0;
308 int error __attribute__ ((unused));
310 error = blkdev_issue_secure_erase(bdev,
311 sector, nr_sects, GFP_KERNEL);
314 ZFS_LINUX_TEST_SRC([blkdev_issue_discard_flags], [
315 #include <linux/blkdev.h>
317 struct block_device *bdev = NULL;
319 sector_t nr_sects = 0;
320 unsigned long flags = 0;
321 int error __attribute__ ((unused));
323 error = blkdev_issue_discard(bdev,
324 sector, nr_sects, GFP_KERNEL, flags);
328 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_ISSUE_SECURE_ERASE], [
329 AC_MSG_CHECKING([whether blkdev_issue_secure_erase() is available])
330 ZFS_LINUX_TEST_RESULT([blkdev_issue_secure_erase], [
332 AC_DEFINE(HAVE_BLKDEV_ISSUE_SECURE_ERASE, 1,
333 [blkdev_issue_secure_erase() is available])
337 AC_MSG_CHECKING([whether blkdev_issue_discard() is available])
338 ZFS_LINUX_TEST_RESULT([blkdev_issue_discard_flags], [
340 AC_DEFINE(HAVE_BLKDEV_ISSUE_DISCARD, 1,
341 [blkdev_issue_discard() is available])
343 ZFS_LINUX_TEST_ERROR([blkdev_issue_discard()])
349 dnl # 5.13 API change
350 dnl # blkdev_get_by_path() no longer handles ERESTARTSYS
352 dnl # Unfortunately we're forced to rely solely on the kernel version
353 dnl # number in order to determine the expected behavior. This was an
354 dnl # internal change to blkdev_get_by_dev(), see commit a8ed1a0607.
356 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_ERESTARTSYS], [
357 AC_MSG_CHECKING([whether blkdev_get_by_path() handles ERESTARTSYS])
358 AS_VERSION_COMPARE([$LINUX_VERSION], [5.13.0], [
360 AC_DEFINE(HAVE_BLKDEV_GET_ERESTARTSYS, 1,
361 [blkdev_get_by_path() handles ERESTARTSYS])
369 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV], [
370 ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH
371 ZFS_AC_KERNEL_SRC_BLKDEV_PUT
372 ZFS_AC_KERNEL_SRC_BLKDEV_REREAD_PART
373 ZFS_AC_KERNEL_SRC_BLKDEV_INVALIDATE_BDEV
374 ZFS_AC_KERNEL_SRC_BLKDEV_LOOKUP_BDEV
375 ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE
376 ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE
377 ZFS_AC_KERNEL_SRC_BLKDEV_CHECK_DISK_CHANGE
378 ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_CHECK_MEDIA_CHANGE
379 ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_WHOLE
380 ZFS_AC_KERNEL_SRC_BLKDEV_ISSUE_SECURE_ERASE
383 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV], [
384 ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH
385 ZFS_AC_KERNEL_BLKDEV_PUT
386 ZFS_AC_KERNEL_BLKDEV_REREAD_PART
387 ZFS_AC_KERNEL_BLKDEV_INVALIDATE_BDEV
388 ZFS_AC_KERNEL_BLKDEV_LOOKUP_BDEV
389 ZFS_AC_KERNEL_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE
390 ZFS_AC_KERNEL_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE
391 ZFS_AC_KERNEL_BLKDEV_CHECK_DISK_CHANGE
392 ZFS_AC_KERNEL_BLKDEV_BDEV_CHECK_MEDIA_CHANGE
393 ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE
394 ZFS_AC_KERNEL_BLKDEV_GET_ERESTARTSYS
395 ZFS_AC_KERNEL_BLKDEV_ISSUE_SECURE_ERASE