xref: /freebsd/sys/contrib/openzfs/config/kernel-block-device-operations.m4 (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1dnl #
2dnl # 2.6.38 API change
3dnl #
4AC_DEFUN([ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_CHECK_EVENTS], [
5	ZFS_LINUX_TEST_SRC([block_device_operations_check_events], [
6		#include <linux/blkdev.h>
7
8		unsigned int blk_check_events(struct gendisk *disk,
9		    unsigned int clearing) {
10			(void) disk, (void) clearing;
11			return (0);
12		}
13
14		static const struct block_device_operations
15		    bops __attribute__ ((unused)) = {
16			.check_events	= blk_check_events,
17		};
18	], [], [])
19])
20
21AC_DEFUN([ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_CHECK_EVENTS], [
22	AC_MSG_CHECKING([whether bops->check_events() exists])
23	ZFS_LINUX_TEST_RESULT([block_device_operations_check_events], [
24		AC_MSG_RESULT(yes)
25	],[
26		ZFS_LINUX_TEST_ERROR([bops->check_events()])
27	])
28])
29
30dnl #
31dnl # 3.10.x API change
32dnl #
33AC_DEFUN([ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID], [
34	ZFS_LINUX_TEST_SRC([block_device_operations_release_void], [
35		#include <linux/blkdev.h>
36
37		void blk_release(struct gendisk *g, fmode_t mode) {
38			(void) g, (void) mode;
39			return;
40		}
41
42		static const struct block_device_operations
43		    bops __attribute__ ((unused)) = {
44			.open		= NULL,
45			.release	= blk_release,
46			.ioctl		= NULL,
47			.compat_ioctl	= NULL,
48		};
49	], [], [])
50])
51
52AC_DEFUN([ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID], [
53	AC_MSG_CHECKING([whether bops->release() is void])
54	ZFS_LINUX_TEST_RESULT([block_device_operations_release_void], [
55		AC_MSG_RESULT(yes)
56	],[
57		ZFS_LINUX_TEST_ERROR([bops->release()])
58	])
59])
60
61dnl #
62dnl # 5.13 API change
63dnl # block_device_operations->revalidate_disk() was removed
64dnl #
65AC_DEFUN([ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK], [
66	ZFS_LINUX_TEST_SRC([block_device_operations_revalidate_disk], [
67		#include <linux/blkdev.h>
68
69		int blk_revalidate_disk(struct gendisk *disk) {
70			(void) disk;
71			return(0);
72		}
73
74		static const struct block_device_operations
75		    bops __attribute__ ((unused)) = {
76			.revalidate_disk	= blk_revalidate_disk,
77		};
78	], [], [])
79])
80
81AC_DEFUN([ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK], [
82	AC_MSG_CHECKING([whether bops->revalidate_disk() exists])
83	ZFS_LINUX_TEST_RESULT([block_device_operations_revalidate_disk], [
84		AC_DEFINE([HAVE_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK], [1],
85			[Define if revalidate_disk() in block_device_operations])
86		AC_MSG_RESULT(yes)
87	],[
88		AC_MSG_RESULT(no)
89	])
90])
91
92AC_DEFUN([ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS], [
93	ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_CHECK_EVENTS
94	ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID
95	ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK
96])
97
98AC_DEFUN([ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS], [
99	ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_CHECK_EVENTS
100	ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID
101	ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK
102])
103