xref: /freebsd/sys/contrib/openzfs/config/kernel-block-device-operations.m4 (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
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		static 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		static 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
52dnl #
53dnl # 5.9.x API change
54dnl #
55AC_DEFUN([ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_RELEASE_1ARG], [
56	ZFS_LINUX_TEST_SRC([block_device_operations_release_void_1arg], [
57		#include <linux/blkdev.h>
58
59		static void blk_release(struct gendisk *g) {
60			(void) g;
61			return;
62		}
63
64		static const struct block_device_operations
65		    bops __attribute__ ((unused)) = {
66			.open		= NULL,
67			.release	= blk_release,
68			.ioctl		= NULL,
69			.compat_ioctl	= NULL,
70		};
71	], [], [])
72])
73
74AC_DEFUN([ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID], [
75	AC_MSG_CHECKING([whether bops->release() is void and takes 2 args])
76	ZFS_LINUX_TEST_RESULT([block_device_operations_release_void], [
77		AC_MSG_RESULT(yes)
78	],[
79		AC_MSG_RESULT(no)
80		AC_MSG_CHECKING([whether bops->release() is void and takes 1 arg])
81		ZFS_LINUX_TEST_RESULT([block_device_operations_release_void_1arg], [
82			AC_MSG_RESULT(yes)
83			AC_DEFINE([HAVE_BLOCK_DEVICE_OPERATIONS_RELEASE_1ARG], [1],
84				[Define if release() in block_device_operations takes 1 arg])
85		],[
86			ZFS_LINUX_TEST_ERROR([bops->release()])
87		])
88	])
89])
90
91dnl #
92dnl # 5.13 API change
93dnl # block_device_operations->revalidate_disk() was removed
94dnl #
95AC_DEFUN([ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK], [
96	ZFS_LINUX_TEST_SRC([block_device_operations_revalidate_disk], [
97		#include <linux/blkdev.h>
98
99		static int blk_revalidate_disk(struct gendisk *disk) {
100			(void) disk;
101			return(0);
102		}
103
104		static const struct block_device_operations
105		    bops __attribute__ ((unused)) = {
106			.revalidate_disk	= blk_revalidate_disk,
107		};
108	], [], [])
109])
110
111AC_DEFUN([ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK], [
112	AC_MSG_CHECKING([whether bops->revalidate_disk() exists])
113	ZFS_LINUX_TEST_RESULT([block_device_operations_revalidate_disk], [
114		AC_DEFINE([HAVE_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK], [1],
115			[Define if revalidate_disk() in block_device_operations])
116		AC_MSG_RESULT(yes)
117	],[
118		AC_MSG_RESULT(no)
119	])
120])
121
122AC_DEFUN([ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS], [
123	ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_CHECK_EVENTS
124	ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID
125	ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_RELEASE_1ARG
126	ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK
127])
128
129AC_DEFUN([ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS], [
130	ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_CHECK_EVENTS
131	ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID
132	ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK
133])
134