xref: /freebsd/sys/contrib/openzfs/config/kernel-blk-queue.m4 (revision a58ece87303f882367105c92a27268ed6befa655)
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 # 6.11: bdi no longer available through request_queue, so get it from
29dnl #       the gendisk attached to the queue
30dnl #
31AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_BDI], [
32	ZFS_LINUX_TEST_SRC([blk_queue_bdi], [
33		#include <linux/blkdev.h>
34	],[
35		struct request_queue q;
36		struct backing_dev_info bdi;
37		q.backing_dev_info = &bdi;
38	])
39])
40
41AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_BDI], [
42	AC_MSG_CHECKING([whether blk_queue bdi is dynamic])
43	ZFS_LINUX_TEST_RESULT([blk_queue_bdi], [
44		AC_MSG_RESULT(yes)
45		AC_DEFINE(HAVE_BLK_QUEUE_BDI_DYNAMIC, 1,
46		    [blk queue backing_dev_info is dynamic])
47	],[
48		AC_MSG_RESULT(no)
49	])
50])
51
52AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISK_BDI], [
53	ZFS_LINUX_TEST_SRC([blk_queue_disk_bdi], [
54		#include <linux/blkdev.h>
55		#include <linux/backing-dev.h>
56	], [
57		struct request_queue q;
58		struct gendisk disk;
59		struct backing_dev_info bdi __attribute__ ((unused));
60		q.disk = &disk;
61		q.disk->bdi = &bdi;
62	])
63])
64
65AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_DISK_BDI], [
66	AC_MSG_CHECKING([whether backing_dev_info is available through queue gendisk])
67	ZFS_LINUX_TEST_RESULT([blk_queue_disk_bdi], [
68		AC_MSG_RESULT(yes)
69		AC_DEFINE(HAVE_BLK_QUEUE_DISK_BDI, 1,
70		    [backing_dev_info is available through queue gendisk])
71	],[
72		AC_MSG_RESULT(no)
73	])
74])
75
76dnl #
77dnl # 5.9: added blk_queue_update_readahead(),
78dnl # 5.15: renamed to disk_update_readahead()
79dnl #
80AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_UPDATE_READAHEAD], [
81	ZFS_LINUX_TEST_SRC([blk_queue_update_readahead], [
82		#include <linux/blkdev.h>
83	],[
84		struct request_queue q;
85		blk_queue_update_readahead(&q);
86	])
87
88	ZFS_LINUX_TEST_SRC([disk_update_readahead], [
89		#include <linux/blkdev.h>
90	],[
91		struct gendisk disk;
92		disk_update_readahead(&disk);
93	])
94])
95
96AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_UPDATE_READAHEAD], [
97	AC_MSG_CHECKING([whether blk_queue_update_readahead() exists])
98	ZFS_LINUX_TEST_RESULT([blk_queue_update_readahead], [
99		AC_MSG_RESULT(yes)
100		AC_DEFINE(HAVE_BLK_QUEUE_UPDATE_READAHEAD, 1,
101		    [blk_queue_update_readahead() exists])
102	],[
103		AC_MSG_RESULT(no)
104
105		AC_MSG_CHECKING([whether disk_update_readahead() exists])
106		ZFS_LINUX_TEST_RESULT([disk_update_readahead], [
107			AC_MSG_RESULT(yes)
108			AC_DEFINE(HAVE_DISK_UPDATE_READAHEAD, 1,
109			    [disk_update_readahead() exists])
110		],[
111			AC_MSG_RESULT(no)
112		])
113	])
114])
115
116dnl #
117dnl # 5.19: bdev_max_discard_sectors() available
118dnl # 2.6.32: blk_queue_discard() available
119dnl #
120AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD], [
121	ZFS_LINUX_TEST_SRC([bdev_max_discard_sectors], [
122		#include <linux/blkdev.h>
123	],[
124		struct block_device *bdev __attribute__ ((unused)) = NULL;
125		unsigned int error __attribute__ ((unused));
126
127		error = bdev_max_discard_sectors(bdev);
128	])
129
130	ZFS_LINUX_TEST_SRC([blk_queue_discard], [
131		#include <linux/blkdev.h>
132	],[
133		struct request_queue r;
134		struct request_queue *q = &r;
135		int value __attribute__ ((unused));
136		memset(q, 0, sizeof(r));
137		value = blk_queue_discard(q);
138	],[-Wframe-larger-than=8192])
139])
140
141AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_DISCARD], [
142	AC_MSG_CHECKING([whether bdev_max_discard_sectors() is available])
143	ZFS_LINUX_TEST_RESULT([bdev_max_discard_sectors], [
144		AC_MSG_RESULT(yes)
145		AC_DEFINE(HAVE_BDEV_MAX_DISCARD_SECTORS, 1,
146		    [bdev_max_discard_sectors() is available])
147	],[
148		AC_MSG_RESULT(no)
149
150		AC_MSG_CHECKING([whether blk_queue_discard() is available])
151		ZFS_LINUX_TEST_RESULT([blk_queue_discard], [
152			AC_MSG_RESULT(yes)
153			AC_DEFINE(HAVE_BLK_QUEUE_DISCARD, 1,
154			    [blk_queue_discard() is available])
155		],[
156			ZFS_LINUX_TEST_ERROR([blk_queue_discard])
157		])
158	])
159])
160
161dnl #
162dnl # 5.19: bdev_max_secure_erase_sectors() available
163dnl # 4.8: blk_queue_secure_erase() available
164dnl # 2.6.36: blk_queue_secdiscard() available
165dnl #
166AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE], [
167	ZFS_LINUX_TEST_SRC([bdev_max_secure_erase_sectors], [
168		#include <linux/blkdev.h>
169	],[
170		struct block_device *bdev __attribute__ ((unused)) = NULL;
171		unsigned int error __attribute__ ((unused));
172
173		error = bdev_max_secure_erase_sectors(bdev);
174	])
175
176	ZFS_LINUX_TEST_SRC([blk_queue_secure_erase], [
177		#include <linux/blkdev.h>
178	],[
179		struct request_queue r;
180		struct request_queue *q = &r;
181		int value __attribute__ ((unused));
182		memset(q, 0, sizeof(r));
183		value = blk_queue_secure_erase(q);
184	],[-Wframe-larger-than=8192])
185
186	ZFS_LINUX_TEST_SRC([blk_queue_secdiscard], [
187		#include <linux/blkdev.h>
188	],[
189		struct request_queue r;
190		struct request_queue *q = &r;
191		int value __attribute__ ((unused));
192		memset(q, 0, sizeof(r));
193		value = blk_queue_secdiscard(q);
194	])
195])
196
197AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE], [
198	AC_MSG_CHECKING([whether bdev_max_secure_erase_sectors() is available])
199	ZFS_LINUX_TEST_RESULT([bdev_max_secure_erase_sectors], [
200		AC_MSG_RESULT(yes)
201		AC_DEFINE(HAVE_BDEV_MAX_SECURE_ERASE_SECTORS, 1,
202		    [bdev_max_secure_erase_sectors() is available])
203	],[
204		AC_MSG_RESULT(no)
205
206		AC_MSG_CHECKING([whether blk_queue_secure_erase() is available])
207		ZFS_LINUX_TEST_RESULT([blk_queue_secure_erase], [
208			AC_MSG_RESULT(yes)
209			AC_DEFINE(HAVE_BLK_QUEUE_SECURE_ERASE, 1,
210			    [blk_queue_secure_erase() is available])
211		],[
212			AC_MSG_RESULT(no)
213
214			AC_MSG_CHECKING([whether blk_queue_secdiscard() is available])
215			ZFS_LINUX_TEST_RESULT([blk_queue_secdiscard], [
216				AC_MSG_RESULT(yes)
217			AC_DEFINE(HAVE_BLK_QUEUE_SECDISCARD, 1,
218				    [blk_queue_secdiscard() is available])
219			],[
220				ZFS_LINUX_TEST_ERROR([blk_queue_secure_erase])
221			])
222		])
223	])
224])
225
226dnl #
227dnl # 4.16 API change,
228dnl # Introduction of blk_queue_flag_set and blk_queue_flag_clear
229dnl #
230AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_SET], [
231	ZFS_LINUX_TEST_SRC([blk_queue_flag_set], [
232		#include <linux/kernel.h>
233		#include <linux/blkdev.h>
234	],[
235		struct request_queue *q = NULL;
236		blk_queue_flag_set(0, q);
237	])
238])
239
240AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_FLAG_SET], [
241	AC_MSG_CHECKING([whether blk_queue_flag_set() exists])
242	ZFS_LINUX_TEST_RESULT([blk_queue_flag_set], [
243		AC_MSG_RESULT(yes)
244		AC_DEFINE(HAVE_BLK_QUEUE_FLAG_SET, 1,
245		    [blk_queue_flag_set() exists])
246	],[
247		AC_MSG_RESULT(no)
248	])
249])
250
251AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_CLEAR], [
252	ZFS_LINUX_TEST_SRC([blk_queue_flag_clear], [
253		#include <linux/kernel.h>
254		#include <linux/blkdev.h>
255	],[
256		struct request_queue *q = NULL;
257		blk_queue_flag_clear(0, q);
258	])
259])
260
261AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_FLAG_CLEAR], [
262	AC_MSG_CHECKING([whether blk_queue_flag_clear() exists])
263	ZFS_LINUX_TEST_RESULT([blk_queue_flag_clear], [
264		AC_MSG_RESULT(yes)
265		AC_DEFINE(HAVE_BLK_QUEUE_FLAG_CLEAR, 1,
266		    [blk_queue_flag_clear() exists])
267	],[
268		AC_MSG_RESULT(no)
269	])
270])
271
272dnl #
273dnl # 2.6.36 API change,
274dnl # Added blk_queue_flush() interface, while the previous interface
275dnl # was available to all the new one is GPL-only.  Thus in addition to
276dnl # detecting if this function is available we determine if it is
277dnl # GPL-only.  If the GPL-only interface is there we implement our own
278dnl # compatibility function, otherwise we use the function.  The hope
279dnl # is that long term this function will be opened up.
280dnl #
281dnl # 4.7 API change,
282dnl # Replace blk_queue_flush with blk_queue_write_cache
283dnl #
284AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLUSH], [
285	ZFS_LINUX_TEST_SRC([blk_queue_flush], [
286		#include <linux/blkdev.h>
287	], [
288		struct request_queue *q __attribute__ ((unused)) = NULL;
289		(void) blk_queue_flush(q, REQ_FLUSH);
290	], [], [ZFS_META_LICENSE])
291
292	ZFS_LINUX_TEST_SRC([blk_queue_write_cache], [
293		#include <linux/kernel.h>
294		#include <linux/blkdev.h>
295	], [
296		struct request_queue *q __attribute__ ((unused)) = NULL;
297		blk_queue_write_cache(q, true, true);
298	], [], [ZFS_META_LICENSE])
299])
300
301AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_FLUSH], [
302	AC_MSG_CHECKING([whether blk_queue_flush() is available])
303	ZFS_LINUX_TEST_RESULT([blk_queue_flush], [
304		AC_MSG_RESULT(yes)
305		AC_DEFINE(HAVE_BLK_QUEUE_FLUSH, 1,
306		    [blk_queue_flush() is available])
307
308		AC_MSG_CHECKING([whether blk_queue_flush() is GPL-only])
309		ZFS_LINUX_TEST_RESULT([blk_queue_flush_license], [
310			AC_MSG_RESULT(no)
311		],[
312			AC_MSG_RESULT(yes)
313			AC_DEFINE(HAVE_BLK_QUEUE_FLUSH_GPL_ONLY, 1,
314			    [blk_queue_flush() is GPL-only])
315		])
316	],[
317		AC_MSG_RESULT(no)
318	])
319
320	dnl #
321	dnl # 4.7 API change
322	dnl # Replace blk_queue_flush with blk_queue_write_cache
323	dnl #
324	AC_MSG_CHECKING([whether blk_queue_write_cache() exists])
325	ZFS_LINUX_TEST_RESULT([blk_queue_write_cache], [
326		AC_MSG_RESULT(yes)
327		AC_DEFINE(HAVE_BLK_QUEUE_WRITE_CACHE, 1,
328		    [blk_queue_write_cache() exists])
329
330		AC_MSG_CHECKING([whether blk_queue_write_cache() is GPL-only])
331		ZFS_LINUX_TEST_RESULT([blk_queue_write_cache_license], [
332			AC_MSG_RESULT(no)
333		],[
334			AC_MSG_RESULT(yes)
335			AC_DEFINE(HAVE_BLK_QUEUE_WRITE_CACHE_GPL_ONLY, 1,
336			    [blk_queue_write_cache() is GPL-only])
337		])
338	],[
339		AC_MSG_RESULT(no)
340	])
341])
342
343dnl #
344dnl # 2.6.34 API change
345dnl # blk_queue_max_hw_sectors() replaces blk_queue_max_sectors().
346dnl #
347AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_HW_SECTORS], [
348	ZFS_LINUX_TEST_SRC([blk_queue_max_hw_sectors], [
349		#include <linux/blkdev.h>
350	], [
351		struct request_queue *q __attribute__ ((unused)) = NULL;
352		(void) blk_queue_max_hw_sectors(q, BLK_SAFE_MAX_SECTORS);
353	], [])
354])
355
356AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS], [
357	AC_MSG_CHECKING([whether blk_queue_max_hw_sectors() is available])
358	ZFS_LINUX_TEST_RESULT([blk_queue_max_hw_sectors], [
359		AC_MSG_RESULT(yes)
360	],[
361		AC_MSG_RESULT(no)
362	])
363])
364
365dnl #
366dnl # 2.6.34 API change
367dnl # blk_queue_max_segments() consolidates blk_queue_max_hw_segments()
368dnl # and blk_queue_max_phys_segments().
369dnl #
370AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_SEGMENTS], [
371	ZFS_LINUX_TEST_SRC([blk_queue_max_segments], [
372		#include <linux/blkdev.h>
373	], [
374		struct request_queue *q __attribute__ ((unused)) = NULL;
375		(void) blk_queue_max_segments(q, BLK_MAX_SEGMENTS);
376	], [])
377])
378
379AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS], [
380	AC_MSG_CHECKING([whether blk_queue_max_segments() is available])
381	ZFS_LINUX_TEST_RESULT([blk_queue_max_segments], [
382		AC_MSG_RESULT(yes)
383	], [
384		AC_MSG_RESULT(no)
385	])
386])
387
388dnl #
389dnl # See if kernel supports block multi-queue and blk_status_t.
390dnl # blk_status_t represents the new status codes introduced in the 4.13
391dnl # kernel patch:
392dnl #
393dnl #  block: introduce new block status code type
394dnl #
395dnl # We do not currently support the "old" block multi-queue interfaces from
396dnl # prior kernels.
397dnl #
398AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_MQ], [
399	ZFS_LINUX_TEST_SRC([blk_mq], [
400		#include <linux/blk-mq.h>
401	], [
402		struct blk_mq_tag_set tag_set __attribute__ ((unused)) = {0};
403		(void) blk_mq_alloc_tag_set(&tag_set);
404		return BLK_STS_OK;
405	], [])
406	ZFS_LINUX_TEST_SRC([blk_mq_rq_hctx], [
407		#include <linux/blk-mq.h>
408		#include <linux/blkdev.h>
409	], [
410		struct request rq = {0};
411		struct blk_mq_hw_ctx *hctx = NULL;
412		rq.mq_hctx = hctx;
413	], [])
414])
415
416AC_DEFUN([ZFS_AC_KERNEL_BLK_MQ], [
417	AC_MSG_CHECKING([whether block multiqueue with blk_status_t is available])
418	ZFS_LINUX_TEST_RESULT([blk_mq], [
419		AC_MSG_RESULT(yes)
420		AC_DEFINE(HAVE_BLK_MQ, 1, [block multiqueue is available])
421		AC_MSG_CHECKING([whether block multiqueue hardware context is cached in struct request])
422		ZFS_LINUX_TEST_RESULT([blk_mq_rq_hctx], [
423			AC_MSG_RESULT(yes)
424			AC_DEFINE(HAVE_BLK_MQ_RQ_HCTX, 1, [block multiqueue hardware context is cached in struct request])
425		], [
426			AC_MSG_RESULT(no)
427		])
428	], [
429		AC_MSG_RESULT(no)
430	])
431])
432
433AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE], [
434	ZFS_AC_KERNEL_SRC_BLK_QUEUE_PLUG
435	ZFS_AC_KERNEL_SRC_BLK_QUEUE_BDI
436	ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISK_BDI
437	ZFS_AC_KERNEL_SRC_BLK_QUEUE_UPDATE_READAHEAD
438	ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD
439	ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE
440	ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_SET
441	ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_CLEAR
442	ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLUSH
443	ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_HW_SECTORS
444	ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_SEGMENTS
445	ZFS_AC_KERNEL_SRC_BLK_MQ
446])
447
448AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE], [
449	ZFS_AC_KERNEL_BLK_QUEUE_PLUG
450	ZFS_AC_KERNEL_BLK_QUEUE_BDI
451	ZFS_AC_KERNEL_BLK_QUEUE_DISK_BDI
452	ZFS_AC_KERNEL_BLK_QUEUE_UPDATE_READAHEAD
453	ZFS_AC_KERNEL_BLK_QUEUE_DISCARD
454	ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE
455	ZFS_AC_KERNEL_BLK_QUEUE_FLAG_SET
456	ZFS_AC_KERNEL_BLK_QUEUE_FLAG_CLEAR
457	ZFS_AC_KERNEL_BLK_QUEUE_FLUSH
458	ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS
459	ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS
460	ZFS_AC_KERNEL_BLK_MQ
461])
462