xref: /freebsd/sys/contrib/openzfs/config/kernel-blk-queue.m4 (revision 18054d0220cfc8df9c9568c437bd6fbb59d53c3c)
1dnl #
2dnl # 2.6.39 API change,
3dnl # blk_start_plug() and blk_finish_plug()
4dnl #
5AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_PLUG], [
6	ZFS_LINUX_TEST_SRC([blk_plug], [
7		#include <linux/blkdev.h>
8	],[
9		struct blk_plug plug __attribute__ ((unused));
10
11		blk_start_plug(&plug);
12		blk_finish_plug(&plug);
13	])
14])
15
16AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_PLUG], [
17	AC_MSG_CHECKING([whether struct blk_plug is available])
18	ZFS_LINUX_TEST_RESULT([blk_plug], [
19		AC_MSG_RESULT(yes)
20	],[
21		ZFS_LINUX_TEST_ERROR([blk_plug])
22	])
23])
24
25dnl #
26dnl # 2.6.32 - 4.11: statically allocated bdi in request_queue
27dnl # 4.12: dynamically allocated bdi in request_queue
28dnl #
29AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_BDI], [
30	ZFS_LINUX_TEST_SRC([blk_queue_bdi], [
31		#include <linux/blkdev.h>
32	],[
33		struct request_queue q;
34		struct backing_dev_info bdi;
35		q.backing_dev_info = &bdi;
36	])
37])
38
39AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_BDI], [
40	AC_MSG_CHECKING([whether blk_queue bdi is dynamic])
41	ZFS_LINUX_TEST_RESULT([blk_queue_bdi], [
42		AC_MSG_RESULT(yes)
43		AC_DEFINE(HAVE_BLK_QUEUE_BDI_DYNAMIC, 1,
44		    [blk queue backing_dev_info is dynamic])
45	],[
46		AC_MSG_RESULT(no)
47	])
48])
49
50dnl #
51dnl # 5.9: added blk_queue_update_readahead(),
52dnl # 5.15: renamed to disk_update_readahead()
53dnl #
54AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_UPDATE_READAHEAD], [
55	ZFS_LINUX_TEST_SRC([blk_queue_update_readahead], [
56		#include <linux/blkdev.h>
57	],[
58		struct request_queue q;
59		blk_queue_update_readahead(&q);
60	])
61
62	ZFS_LINUX_TEST_SRC([disk_update_readahead], [
63		#include <linux/blkdev.h>
64	],[
65		struct gendisk disk;
66		disk_update_readahead(&disk);
67	])
68])
69
70AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_UPDATE_READAHEAD], [
71	AC_MSG_CHECKING([whether blk_queue_update_readahead() exists])
72	ZFS_LINUX_TEST_RESULT([blk_queue_update_readahead], [
73		AC_MSG_RESULT(yes)
74		AC_DEFINE(HAVE_BLK_QUEUE_UPDATE_READAHEAD, 1,
75		    [blk_queue_update_readahead() exists])
76	],[
77		AC_MSG_CHECKING([whether disk_update_readahead() exists])
78		ZFS_LINUX_TEST_RESULT([disk_update_readahead], [
79			AC_MSG_RESULT(yes)
80			AC_DEFINE(HAVE_DISK_UPDATE_READAHEAD, 1,
81			    [disk_update_readahead() exists])
82		],[
83			AC_MSG_RESULT(no)
84		])
85	])
86])
87
88dnl #
89dnl # 2.6.32 API,
90dnl #   blk_queue_discard()
91dnl #
92AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD], [
93	ZFS_LINUX_TEST_SRC([blk_queue_discard], [
94		#include <linux/blkdev.h>
95	],[
96		struct request_queue r;
97		struct request_queue *q = &r;
98		int value __attribute__ ((unused));
99		memset(q, 0, sizeof(r));
100		value = blk_queue_discard(q);
101	])
102])
103
104AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_DISCARD], [
105	AC_MSG_CHECKING([whether blk_queue_discard() is available])
106	ZFS_LINUX_TEST_RESULT([blk_queue_discard], [
107		AC_MSG_RESULT(yes)
108	],[
109		ZFS_LINUX_TEST_ERROR([blk_queue_discard])
110	])
111])
112
113dnl #
114dnl # 4.8 API,
115dnl #   blk_queue_secure_erase()
116dnl #
117dnl # 2.6.36 - 4.7 API,
118dnl #   blk_queue_secdiscard()
119dnl #
120AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE], [
121	ZFS_LINUX_TEST_SRC([blk_queue_secure_erase], [
122		#include <linux/blkdev.h>
123	],[
124		struct request_queue r;
125		struct request_queue *q = &r;
126		int value __attribute__ ((unused));
127		memset(q, 0, sizeof(r));
128		value = blk_queue_secure_erase(q);
129	])
130
131	ZFS_LINUX_TEST_SRC([blk_queue_secdiscard], [
132		#include <linux/blkdev.h>
133	],[
134		struct request_queue r;
135		struct request_queue *q = &r;
136		int value __attribute__ ((unused));
137		memset(q, 0, sizeof(r));
138		value = blk_queue_secdiscard(q);
139	])
140])
141
142AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE], [
143	AC_MSG_CHECKING([whether blk_queue_secure_erase() is available])
144	ZFS_LINUX_TEST_RESULT([blk_queue_secure_erase], [
145		AC_MSG_RESULT(yes)
146		AC_DEFINE(HAVE_BLK_QUEUE_SECURE_ERASE, 1,
147		    [blk_queue_secure_erase() is available])
148	],[
149		AC_MSG_RESULT(no)
150
151		AC_MSG_CHECKING([whether blk_queue_secdiscard() is available])
152		ZFS_LINUX_TEST_RESULT([blk_queue_secdiscard], [
153			AC_MSG_RESULT(yes)
154			AC_DEFINE(HAVE_BLK_QUEUE_SECDISCARD, 1,
155			    [blk_queue_secdiscard() is available])
156		],[
157			ZFS_LINUX_TEST_ERROR([blk_queue_secure_erase])
158		])
159	])
160])
161
162dnl #
163dnl # 4.16 API change,
164dnl # Introduction of blk_queue_flag_set and blk_queue_flag_clear
165dnl #
166AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_SET], [
167	ZFS_LINUX_TEST_SRC([blk_queue_flag_set], [
168		#include <linux/kernel.h>
169		#include <linux/blkdev.h>
170	],[
171		struct request_queue *q = NULL;
172		blk_queue_flag_set(0, q);
173	])
174])
175
176AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_FLAG_SET], [
177	AC_MSG_CHECKING([whether blk_queue_flag_set() exists])
178	ZFS_LINUX_TEST_RESULT([blk_queue_flag_set], [
179		AC_MSG_RESULT(yes)
180		AC_DEFINE(HAVE_BLK_QUEUE_FLAG_SET, 1,
181		    [blk_queue_flag_set() exists])
182	],[
183		AC_MSG_RESULT(no)
184	])
185])
186
187AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_CLEAR], [
188	ZFS_LINUX_TEST_SRC([blk_queue_flag_clear], [
189		#include <linux/kernel.h>
190		#include <linux/blkdev.h>
191	],[
192		struct request_queue *q = NULL;
193		blk_queue_flag_clear(0, q);
194	])
195])
196
197AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_FLAG_CLEAR], [
198	AC_MSG_CHECKING([whether blk_queue_flag_clear() exists])
199	ZFS_LINUX_TEST_RESULT([blk_queue_flag_clear], [
200		AC_MSG_RESULT(yes)
201		AC_DEFINE(HAVE_BLK_QUEUE_FLAG_CLEAR, 1,
202		    [blk_queue_flag_clear() exists])
203	],[
204		AC_MSG_RESULT(no)
205	])
206])
207
208dnl #
209dnl # 2.6.36 API change,
210dnl # Added blk_queue_flush() interface, while the previous interface
211dnl # was available to all the new one is GPL-only.  Thus in addition to
212dnl # detecting if this function is available we determine if it is
213dnl # GPL-only.  If the GPL-only interface is there we implement our own
214dnl # compatibility function, otherwise we use the function.  The hope
215dnl # is that long term this function will be opened up.
216dnl #
217dnl # 4.7 API change,
218dnl # Replace blk_queue_flush with blk_queue_write_cache
219dnl #
220AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLUSH], [
221	ZFS_LINUX_TEST_SRC([blk_queue_flush], [
222		#include <linux/blkdev.h>
223	], [
224		struct request_queue *q __attribute__ ((unused)) = NULL;
225		(void) blk_queue_flush(q, REQ_FLUSH);
226	], [], [ZFS_META_LICENSE])
227
228	ZFS_LINUX_TEST_SRC([blk_queue_write_cache], [
229		#include <linux/kernel.h>
230		#include <linux/blkdev.h>
231	], [
232		struct request_queue *q __attribute__ ((unused)) = NULL;
233		blk_queue_write_cache(q, true, true);
234	], [], [ZFS_META_LICENSE])
235])
236
237AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_FLUSH], [
238	AC_MSG_CHECKING([whether blk_queue_flush() is available])
239	ZFS_LINUX_TEST_RESULT([blk_queue_flush], [
240		AC_MSG_RESULT(yes)
241		AC_DEFINE(HAVE_BLK_QUEUE_FLUSH, 1,
242		    [blk_queue_flush() is available])
243
244		AC_MSG_CHECKING([whether blk_queue_flush() is GPL-only])
245		ZFS_LINUX_TEST_RESULT([blk_queue_flush_license], [
246			AC_MSG_RESULT(no)
247		],[
248			AC_MSG_RESULT(yes)
249			AC_DEFINE(HAVE_BLK_QUEUE_FLUSH_GPL_ONLY, 1,
250			    [blk_queue_flush() is GPL-only])
251		])
252	],[
253		AC_MSG_RESULT(no)
254	])
255
256	dnl #
257	dnl # 4.7 API change
258	dnl # Replace blk_queue_flush with blk_queue_write_cache
259	dnl #
260	AC_MSG_CHECKING([whether blk_queue_write_cache() exists])
261	ZFS_LINUX_TEST_RESULT([blk_queue_write_cache], [
262		AC_MSG_RESULT(yes)
263		AC_DEFINE(HAVE_BLK_QUEUE_WRITE_CACHE, 1,
264		    [blk_queue_write_cache() exists])
265
266		AC_MSG_CHECKING([whether blk_queue_write_cache() is GPL-only])
267		ZFS_LINUX_TEST_RESULT([blk_queue_write_cache_license], [
268			AC_MSG_RESULT(no)
269		],[
270			AC_MSG_RESULT(yes)
271			AC_DEFINE(HAVE_BLK_QUEUE_WRITE_CACHE_GPL_ONLY, 1,
272			    [blk_queue_write_cache() is GPL-only])
273		])
274	],[
275		AC_MSG_RESULT(no)
276	])
277])
278
279dnl #
280dnl # 2.6.34 API change
281dnl # blk_queue_max_hw_sectors() replaces blk_queue_max_sectors().
282dnl #
283AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_HW_SECTORS], [
284	ZFS_LINUX_TEST_SRC([blk_queue_max_hw_sectors], [
285		#include <linux/blkdev.h>
286	], [
287		struct request_queue *q __attribute__ ((unused)) = NULL;
288		(void) blk_queue_max_hw_sectors(q, BLK_SAFE_MAX_SECTORS);
289	], [])
290])
291
292AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS], [
293	AC_MSG_CHECKING([whether blk_queue_max_hw_sectors() is available])
294	ZFS_LINUX_TEST_RESULT([blk_queue_max_hw_sectors], [
295		AC_MSG_RESULT(yes)
296	],[
297		ZFS_LINUX_TEST_ERROR([blk_queue_max_hw_sectors])
298	])
299])
300
301dnl #
302dnl # 2.6.34 API change
303dnl # blk_queue_max_segments() consolidates blk_queue_max_hw_segments()
304dnl # and blk_queue_max_phys_segments().
305dnl #
306AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_SEGMENTS], [
307	ZFS_LINUX_TEST_SRC([blk_queue_max_segments], [
308		#include <linux/blkdev.h>
309	], [
310		struct request_queue *q __attribute__ ((unused)) = NULL;
311		(void) blk_queue_max_segments(q, BLK_MAX_SEGMENTS);
312	], [])
313])
314
315AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS], [
316	AC_MSG_CHECKING([whether blk_queue_max_segments() is available])
317	ZFS_LINUX_TEST_RESULT([blk_queue_max_segments], [
318		AC_MSG_RESULT(yes)
319	], [
320		ZFS_LINUX_TEST_ERROR([blk_queue_max_segments])
321	])
322])
323
324AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE], [
325	ZFS_AC_KERNEL_SRC_BLK_QUEUE_PLUG
326	ZFS_AC_KERNEL_SRC_BLK_QUEUE_BDI
327	ZFS_AC_KERNEL_SRC_BLK_QUEUE_UPDATE_READAHEAD
328	ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD
329	ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE
330	ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_SET
331	ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_CLEAR
332	ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLUSH
333	ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_HW_SECTORS
334	ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_SEGMENTS
335])
336
337AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE], [
338	ZFS_AC_KERNEL_BLK_QUEUE_PLUG
339	ZFS_AC_KERNEL_BLK_QUEUE_BDI
340	ZFS_AC_KERNEL_BLK_QUEUE_UPDATE_READAHEAD
341	ZFS_AC_KERNEL_BLK_QUEUE_DISCARD
342	ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE
343	ZFS_AC_KERNEL_BLK_QUEUE_FLAG_SET
344	ZFS_AC_KERNEL_BLK_QUEUE_FLAG_CLEAR
345	ZFS_AC_KERNEL_BLK_QUEUE_FLUSH
346	ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS
347	ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS
348])
349