xref: /freebsd/sys/contrib/openzfs/config/kernel-blkdev.m4 (revision 1e4896b176ff664dc9c2fce5426bf2fdf8017a7d)
1dnl #
2dnl # 2.6.38 API change,
3dnl # Added blkdev_get_by_path()
4dnl #
5AC_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;
14
15		bdev = blkdev_get_by_path(path, mode, holder);
16	])
17])
18
19AC_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	])
26])
27
28dnl #
29dnl # 2.6.38 API change,
30dnl # Added blkdev_put()
31dnl #
32AC_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;
39
40		blkdev_put(bdev, mode);
41	])
42])
43
44AC_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	])
51])
52
53dnl #
54dnl # 4.1 API, exported blkdev_reread_part() symbol, back ported to the
55dnl # 3.10.0 CentOS 7.x enterprise kernels.
56dnl #
57AC_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;
64
65		error = blkdev_reread_part(bdev);
66	])
67])
68
69AC_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	])
78])
79
80dnl #
81dnl # 2.6.22 API change
82dnl # Single argument invalidate_bdev()
83dnl #
84AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_INVALIDATE_BDEV], [
85	ZFS_LINUX_TEST_SRC([invalidate_bdev], [
86		#include <linux/buffer_head.h>
87		#include <linux/blkdev.h>
88	],[
89		struct block_device *bdev = NULL;
90		invalidate_bdev(bdev);
91	])
92])
93
94AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_INVALIDATE_BDEV], [
95	AC_MSG_CHECKING([whether invalidate_bdev() exists])
96	ZFS_LINUX_TEST_RESULT([invalidate_bdev], [
97		AC_MSG_RESULT(yes)
98	],[
99		ZFS_LINUX_TEST_ERROR([invalidate_bdev()])
100	])
101])
102
103dnl #
104dnl # 2.6.27, lookup_bdev() was exported.
105dnl # 4.4.0-6.21 - lookup_bdev() takes 2 arguments.
106dnl #
107AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_LOOKUP_BDEV], [
108	ZFS_LINUX_TEST_SRC([lookup_bdev_1arg], [
109		#include <linux/fs.h>
110		#include <linux/blkdev.h>
111	], [
112		lookup_bdev(NULL);
113	])
114
115	ZFS_LINUX_TEST_SRC([lookup_bdev_2args], [
116		#include <linux/fs.h>
117	], [
118		lookup_bdev(NULL, FMODE_READ);
119	])
120])
121
122AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_LOOKUP_BDEV], [
123	AC_MSG_CHECKING([whether lookup_bdev() wants 1 arg])
124	ZFS_LINUX_TEST_RESULT_SYMBOL([lookup_bdev_1arg],
125	    [lookup_bdev], [fs/block_dev.c], [
126		AC_MSG_RESULT(yes)
127		AC_DEFINE(HAVE_1ARG_LOOKUP_BDEV, 1,
128		    [lookup_bdev() wants 1 arg])
129	], [
130		AC_MSG_RESULT(no)
131
132		AC_MSG_CHECKING([whether lookup_bdev() wants 2 args])
133		ZFS_LINUX_TEST_RESULT_SYMBOL([lookup_bdev_2args],
134		    [lookup_bdev], [fs/block_dev.c], [
135			AC_MSG_RESULT(yes)
136			AC_DEFINE(HAVE_2ARGS_LOOKUP_BDEV, 1,
137			    [lookup_bdev() wants 2 args])
138		], [
139			ZFS_LINUX_TEST_ERROR([lookup_bdev()])
140		])
141	])
142])
143
144dnl #
145dnl # 2.6.30 API change
146dnl #
147dnl # The bdev_physical_block_size() interface was added to provide a way
148dnl # to determine the smallest write which can be performed without a
149dnl # read-modify-write operation.
150dnl #
151dnl # Unfortunately, this interface isn't entirely reliable because
152dnl # drives are sometimes known to misreport this value.
153dnl #
154AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE], [
155	ZFS_LINUX_TEST_SRC([bdev_physical_block_size], [
156		#include <linux/blkdev.h>
157	],[
158		struct block_device *bdev __attribute__ ((unused)) = NULL;
159		bdev_physical_block_size(bdev);
160	])
161])
162
163AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE], [
164	AC_MSG_CHECKING([whether bdev_physical_block_size() is available])
165	ZFS_LINUX_TEST_RESULT([bdev_physical_block_size], [
166		AC_MSG_RESULT(yes)
167	],[
168		ZFS_LINUX_TEST_ERROR([bdev_physical_block_size()])
169	])
170])
171
172dnl #
173dnl # 2.6.30 API change
174dnl # Added bdev_logical_block_size().
175dnl #
176AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE], [
177	ZFS_LINUX_TEST_SRC([bdev_logical_block_size], [
178		#include <linux/blkdev.h>
179	],[
180		struct block_device *bdev __attribute__ ((unused)) = NULL;
181		bdev_logical_block_size(bdev);
182	])
183])
184
185AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE], [
186	AC_MSG_CHECKING([whether bdev_logical_block_size() is available])
187	ZFS_LINUX_TEST_RESULT([bdev_logical_block_size], [
188		AC_MSG_RESULT(yes)
189	],[
190		ZFS_LINUX_TEST_ERROR([bdev_logical_block_size()])
191	])
192])
193
194AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV], [
195	ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH
196	ZFS_AC_KERNEL_SRC_BLKDEV_PUT
197	ZFS_AC_KERNEL_SRC_BLKDEV_REREAD_PART
198	ZFS_AC_KERNEL_SRC_BLKDEV_INVALIDATE_BDEV
199	ZFS_AC_KERNEL_SRC_BLKDEV_LOOKUP_BDEV
200	ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE
201	ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE
202])
203
204AC_DEFUN([ZFS_AC_KERNEL_BLKDEV], [
205	ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH
206	ZFS_AC_KERNEL_BLKDEV_PUT
207	ZFS_AC_KERNEL_BLKDEV_REREAD_PART
208	ZFS_AC_KERNEL_BLKDEV_INVALIDATE_BDEV
209	ZFS_AC_KERNEL_BLKDEV_LOOKUP_BDEV
210	ZFS_AC_KERNEL_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE
211	ZFS_AC_KERNEL_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE
212])
213