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);
20 dnl # 6.5.x API change,
21 dnl # blkdev_get_by_path() takes 4 args
23 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH_4ARG], [
24 ZFS_LINUX_TEST_SRC([blkdev_get_by_path_4arg], [
26 #include <linux/blkdev.h>
28 struct block_device *bdev __attribute__ ((unused)) = NULL;
29 const char *path = "path";
32 struct blk_holder_ops h;
34 bdev = blkdev_get_by_path(path, mode, holder, &h);
38 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH], [
39 AC_MSG_CHECKING([whether blkdev_get_by_path() exists and takes 3 args])
40 ZFS_LINUX_TEST_RESULT([blkdev_get_by_path], [
44 AC_MSG_CHECKING([whether blkdev_get_by_path() exists and takes 4 args])
45 ZFS_LINUX_TEST_RESULT([blkdev_get_by_path_4arg], [
46 AC_DEFINE(HAVE_BLKDEV_GET_BY_PATH_4ARG, 1,
47 [blkdev_get_by_path() exists and takes 4 args])
50 ZFS_LINUX_TEST_ERROR([blkdev_get_by_path()])
56 dnl # 6.5.x API change
57 dnl # blk_mode_t was added as a type to supercede some places where fmode_t
60 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BLK_MODE_T], [
61 ZFS_LINUX_TEST_SRC([blk_mode_t], [
63 #include <linux/blkdev.h>
65 blk_mode_t m __attribute((unused)) = (blk_mode_t)0;
69 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BLK_MODE_T], [
70 AC_MSG_CHECKING([whether blk_mode_t is defined])
71 ZFS_LINUX_TEST_RESULT([blk_mode_t], [
73 AC_DEFINE(HAVE_BLK_MODE_T, 1, [blk_mode_t is defined])
80 dnl # 2.6.38 API change,
81 dnl # Added blkdev_put()
83 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_PUT], [
84 ZFS_LINUX_TEST_SRC([blkdev_put], [
86 #include <linux/blkdev.h>
88 struct block_device *bdev = NULL;
91 blkdev_put(bdev, mode);
96 dnl # 6.5.x API change.
97 dnl # blkdev_put() takes (void* holder) as arg 2
99 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_PUT_HOLDER], [
100 ZFS_LINUX_TEST_SRC([blkdev_put_holder], [
101 #include <linux/fs.h>
102 #include <linux/blkdev.h>
104 struct block_device *bdev = NULL;
107 blkdev_put(bdev, holder);
111 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_PUT], [
112 AC_MSG_CHECKING([whether blkdev_put() exists])
113 ZFS_LINUX_TEST_RESULT([blkdev_put], [
116 AC_MSG_CHECKING([whether blkdev_put() accepts void* as arg 2])
117 ZFS_LINUX_TEST_RESULT([blkdev_put_holder], [
119 AC_DEFINE(HAVE_BLKDEV_PUT_HOLDER, 1,
120 [blkdev_put() accepts void* as arg 2])
122 ZFS_LINUX_TEST_ERROR([blkdev_put()])
128 dnl # 4.1 API, exported blkdev_reread_part() symbol, back ported to the
129 dnl # 3.10.0 CentOS 7.x enterprise kernels.
131 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_REREAD_PART], [
132 ZFS_LINUX_TEST_SRC([blkdev_reread_part], [
133 #include <linux/fs.h>
134 #include <linux/blkdev.h>
136 struct block_device *bdev = NULL;
139 error = blkdev_reread_part(bdev);
143 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_REREAD_PART], [
144 AC_MSG_CHECKING([whether blkdev_reread_part() exists])
145 ZFS_LINUX_TEST_RESULT([blkdev_reread_part], [
147 AC_DEFINE(HAVE_BLKDEV_REREAD_PART, 1,
148 [blkdev_reread_part() exists])
155 dnl # check_disk_change() was removed in 5.10
157 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_CHECK_DISK_CHANGE], [
158 ZFS_LINUX_TEST_SRC([check_disk_change], [
159 #include <linux/fs.h>
160 #include <linux/blkdev.h>
162 struct block_device *bdev = NULL;
165 error = check_disk_change(bdev);
169 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_CHECK_DISK_CHANGE], [
170 AC_MSG_CHECKING([whether check_disk_change() exists])
171 ZFS_LINUX_TEST_RESULT([check_disk_change], [
173 AC_DEFINE(HAVE_CHECK_DISK_CHANGE, 1,
174 [check_disk_change() exists])
181 dnl # 6.5.x API change
182 dnl # disk_check_media_change() was added
184 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_DISK_CHECK_MEDIA_CHANGE], [
185 ZFS_LINUX_TEST_SRC([disk_check_media_change], [
186 #include <linux/fs.h>
187 #include <linux/blkdev.h>
189 struct block_device *bdev = NULL;
192 error = disk_check_media_change(bdev->bd_disk);
196 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_DISK_CHECK_MEDIA_CHANGE], [
197 AC_MSG_CHECKING([whether disk_check_media_change() exists])
198 ZFS_LINUX_TEST_RESULT([disk_check_media_change], [
200 AC_DEFINE(HAVE_DISK_CHECK_MEDIA_CHANGE, 1,
201 [disk_check_media_change() exists])
208 dnl # bdev_kobj() is introduced from 5.12
210 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_KOBJ], [
211 ZFS_LINUX_TEST_SRC([bdev_kobj], [
212 #include <linux/fs.h>
213 #include <linux/blkdev.h>
214 #include <linux/kobject.h>
216 struct block_device *bdev = NULL;
217 struct kobject *disk_kobj;
218 disk_kobj = bdev_kobj(bdev);
222 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_KOBJ], [
223 AC_MSG_CHECKING([whether bdev_kobj() exists])
224 ZFS_LINUX_TEST_RESULT([bdev_kobj], [
226 AC_DEFINE(HAVE_BDEV_KOBJ, 1,
227 [bdev_kobj() exists])
234 dnl # part_to_dev() was removed in 5.12
236 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_PART_TO_DEV], [
237 ZFS_LINUX_TEST_SRC([part_to_dev], [
238 #include <linux/fs.h>
239 #include <linux/blkdev.h>
241 struct hd_struct *p = NULL;
243 pdev = part_to_dev(p);
247 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_PART_TO_DEV], [
248 AC_MSG_CHECKING([whether part_to_dev() exists])
249 ZFS_LINUX_TEST_RESULT([part_to_dev], [
251 AC_DEFINE(HAVE_PART_TO_DEV, 1,
252 [part_to_dev() exists])
259 dnl # 5.10 API, check_disk_change() is removed, in favor of
260 dnl # bdev_check_media_change(), which doesn't force revalidation
262 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_CHECK_MEDIA_CHANGE], [
263 ZFS_LINUX_TEST_SRC([bdev_check_media_change], [
264 #include <linux/fs.h>
265 #include <linux/blkdev.h>
267 struct block_device *bdev = NULL;
270 error = bdev_check_media_change(bdev);
274 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_CHECK_MEDIA_CHANGE], [
275 AC_MSG_CHECKING([whether bdev_check_media_change() exists])
276 ZFS_LINUX_TEST_RESULT([bdev_check_media_change], [
278 AC_DEFINE(HAVE_BDEV_CHECK_MEDIA_CHANGE, 1,
279 [bdev_check_media_change() exists])
286 dnl # 2.6.22 API change
287 dnl # Single argument invalidate_bdev()
289 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_INVALIDATE_BDEV], [
290 ZFS_LINUX_TEST_SRC([invalidate_bdev], [
291 #include <linux/buffer_head.h>
292 #include <linux/blkdev.h>
294 struct block_device *bdev = NULL;
295 invalidate_bdev(bdev);
299 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_INVALIDATE_BDEV], [
300 AC_MSG_CHECKING([whether invalidate_bdev() exists])
301 ZFS_LINUX_TEST_RESULT([invalidate_bdev], [
304 ZFS_LINUX_TEST_ERROR([invalidate_bdev()])
309 dnl # 5.11 API, lookup_bdev() takes dev_t argument.
310 dnl # 2.6.27 API, lookup_bdev() was first exported.
311 dnl # 4.4.0-6.21 API, lookup_bdev() on Ubuntu takes mode argument.
313 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_LOOKUP_BDEV], [
314 ZFS_LINUX_TEST_SRC([lookup_bdev_devt], [
315 #include <linux/blkdev.h>
317 int error __attribute__ ((unused));
318 const char path[] = "/example/path";
321 error = lookup_bdev(path, &dev);
324 ZFS_LINUX_TEST_SRC([lookup_bdev_1arg], [
325 #include <linux/fs.h>
326 #include <linux/blkdev.h>
328 struct block_device *bdev __attribute__ ((unused));
329 const char path[] = "/example/path";
331 bdev = lookup_bdev(path);
334 ZFS_LINUX_TEST_SRC([lookup_bdev_mode], [
335 #include <linux/fs.h>
337 struct block_device *bdev __attribute__ ((unused));
338 const char path[] = "/example/path";
340 bdev = lookup_bdev(path, FMODE_READ);
344 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_LOOKUP_BDEV], [
345 AC_MSG_CHECKING([whether lookup_bdev() wants dev_t arg])
346 ZFS_LINUX_TEST_RESULT_SYMBOL([lookup_bdev_devt],
347 [lookup_bdev], [fs/block_dev.c], [
349 AC_DEFINE(HAVE_DEVT_LOOKUP_BDEV, 1,
350 [lookup_bdev() wants dev_t arg])
354 AC_MSG_CHECKING([whether lookup_bdev() wants 1 arg])
355 ZFS_LINUX_TEST_RESULT_SYMBOL([lookup_bdev_1arg],
356 [lookup_bdev], [fs/block_dev.c], [
358 AC_DEFINE(HAVE_1ARG_LOOKUP_BDEV, 1,
359 [lookup_bdev() wants 1 arg])
363 AC_MSG_CHECKING([whether lookup_bdev() wants mode arg])
364 ZFS_LINUX_TEST_RESULT_SYMBOL([lookup_bdev_mode],
365 [lookup_bdev], [fs/block_dev.c], [
367 AC_DEFINE(HAVE_MODE_LOOKUP_BDEV, 1,
368 [lookup_bdev() wants mode arg])
370 ZFS_LINUX_TEST_ERROR([lookup_bdev()])
377 dnl # 2.6.30 API change
379 dnl # The bdev_physical_block_size() interface was added to provide a way
380 dnl # to determine the smallest write which can be performed without a
381 dnl # read-modify-write operation.
383 dnl # Unfortunately, this interface isn't entirely reliable because
384 dnl # drives are sometimes known to misreport this value.
386 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE], [
387 ZFS_LINUX_TEST_SRC([bdev_physical_block_size], [
388 #include <linux/blkdev.h>
390 struct block_device *bdev __attribute__ ((unused)) = NULL;
391 bdev_physical_block_size(bdev);
395 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE], [
396 AC_MSG_CHECKING([whether bdev_physical_block_size() is available])
397 ZFS_LINUX_TEST_RESULT([bdev_physical_block_size], [
400 ZFS_LINUX_TEST_ERROR([bdev_physical_block_size()])
405 dnl # 2.6.30 API change
406 dnl # Added bdev_logical_block_size().
408 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE], [
409 ZFS_LINUX_TEST_SRC([bdev_logical_block_size], [
410 #include <linux/blkdev.h>
412 struct block_device *bdev __attribute__ ((unused)) = NULL;
413 bdev_logical_block_size(bdev);
417 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE], [
418 AC_MSG_CHECKING([whether bdev_logical_block_size() is available])
419 ZFS_LINUX_TEST_RESULT([bdev_logical_block_size], [
422 ZFS_LINUX_TEST_ERROR([bdev_logical_block_size()])
427 dnl # 5.11 API change
428 dnl # Added bdev_whole() helper.
430 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_WHOLE], [
431 ZFS_LINUX_TEST_SRC([bdev_whole], [
432 #include <linux/blkdev.h>
434 struct block_device *bdev = NULL;
435 bdev = bdev_whole(bdev);
439 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE], [
440 AC_MSG_CHECKING([whether bdev_whole() is available])
441 ZFS_LINUX_TEST_RESULT([bdev_whole], [
443 AC_DEFINE(HAVE_BDEV_WHOLE, 1, [bdev_whole() is available])
450 dnl # 5.20 API change,
451 dnl # Removed bdevname(), snprintf(.., %pg) should be used.
453 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEVNAME], [
454 ZFS_LINUX_TEST_SRC([bdevname], [
455 #include <linux/fs.h>
456 #include <linux/blkdev.h>
458 struct block_device *bdev __attribute__ ((unused)) = NULL;
459 char path[BDEVNAME_SIZE];
461 (void) bdevname(bdev, path);
465 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEVNAME], [
466 AC_MSG_CHECKING([whether bdevname() exists])
467 ZFS_LINUX_TEST_RESULT([bdevname], [
468 AC_DEFINE(HAVE_BDEVNAME, 1, [bdevname() is available])
476 dnl # 5.19 API: blkdev_issue_secure_erase()
477 dnl # 3.10 API: blkdev_issue_discard(..., BLKDEV_DISCARD_SECURE)
479 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_ISSUE_SECURE_ERASE], [
480 ZFS_LINUX_TEST_SRC([blkdev_issue_secure_erase], [
481 #include <linux/blkdev.h>
483 struct block_device *bdev = NULL;
485 sector_t nr_sects = 0;
486 int error __attribute__ ((unused));
488 error = blkdev_issue_secure_erase(bdev,
489 sector, nr_sects, GFP_KERNEL);
492 ZFS_LINUX_TEST_SRC([blkdev_issue_discard_flags], [
493 #include <linux/blkdev.h>
495 struct block_device *bdev = NULL;
497 sector_t nr_sects = 0;
498 unsigned long flags = 0;
499 int error __attribute__ ((unused));
501 error = blkdev_issue_discard(bdev,
502 sector, nr_sects, GFP_KERNEL, flags);
506 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_ISSUE_SECURE_ERASE], [
507 AC_MSG_CHECKING([whether blkdev_issue_secure_erase() is available])
508 ZFS_LINUX_TEST_RESULT([blkdev_issue_secure_erase], [
510 AC_DEFINE(HAVE_BLKDEV_ISSUE_SECURE_ERASE, 1,
511 [blkdev_issue_secure_erase() is available])
515 AC_MSG_CHECKING([whether blkdev_issue_discard() is available])
516 ZFS_LINUX_TEST_RESULT([blkdev_issue_discard_flags], [
518 AC_DEFINE(HAVE_BLKDEV_ISSUE_DISCARD, 1,
519 [blkdev_issue_discard() is available])
521 ZFS_LINUX_TEST_ERROR([blkdev_issue_discard()])
527 dnl # 5.13 API change
528 dnl # blkdev_get_by_path() no longer handles ERESTARTSYS
530 dnl # Unfortunately we're forced to rely solely on the kernel version
531 dnl # number in order to determine the expected behavior. This was an
532 dnl # internal change to blkdev_get_by_dev(), see commit a8ed1a0607.
534 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_ERESTARTSYS], [
535 AC_MSG_CHECKING([whether blkdev_get_by_path() handles ERESTARTSYS])
536 AS_VERSION_COMPARE([$LINUX_VERSION], [5.13.0], [
538 AC_DEFINE(HAVE_BLKDEV_GET_ERESTARTSYS, 1,
539 [blkdev_get_by_path() handles ERESTARTSYS])
548 dnl # 6.5.x API change
549 dnl # BLK_STS_NEXUS replaced with BLK_STS_RESV_CONFLICT
551 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BLK_STS_RESV_CONFLICT], [
552 ZFS_LINUX_TEST_SRC([blk_sts_resv_conflict], [
553 #include <linux/blkdev.h>
555 blk_status_t s __attribute__ ((unused)) = BLK_STS_RESV_CONFLICT;
559 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BLK_STS_RESV_CONFLICT], [
560 AC_MSG_CHECKING([whether BLK_STS_RESV_CONFLICT is defined])
561 ZFS_LINUX_TEST_RESULT([blk_sts_resv_conflict], [
562 AC_DEFINE(HAVE_BLK_STS_RESV_CONFLICT, 1, [BLK_STS_RESV_CONFLICT is defined])
570 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV], [
571 ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH
572 ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH_4ARG
573 ZFS_AC_KERNEL_SRC_BLKDEV_PUT
574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EDIA_CHANGE
602 ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE
603 ZFS_AC_KERNEL_BLKDEV_BDEVNAME
604 ZFS_AC_KERNEL_BLKDEV_GET_ERESTARTSYS
605 ZFS_AC_KERNEL_BLKDEV_ISSUE_SECURE_ERASE
606 ZFS_AC_KERNEL_BLKDEV_BDEV_KOBJ
607 ZFS_AC_KERNEL_BLKDEV_PART_TO_DEV
608 ZFS_AC_KERNEL_BLKDEV_DISK_CHECK_MEDIA_CHANGE
609 ZFS_AC_KERNEL_BLKDEV_BLK_STS_RESV_CONFLICT
610 ZFS_AC_KERNEL_BLKDEV_BLK_MODE_T