xref: /freebsd/sys/contrib/openzfs/config/kernel-make-request-fn.m4 (revision c1d255d3ffdbe447de3ab875bf4e7d7accc5bfc5)
1dnl #
2dnl # Check for make_request_fn interface.
3dnl #
4AC_DEFUN([ZFS_AC_KERNEL_SRC_MAKE_REQUEST_FN], [
5	ZFS_LINUX_TEST_SRC([make_request_fn_void], [
6		#include <linux/blkdev.h>
7		void make_request(struct request_queue *q,
8		    struct bio *bio) { return; }
9	],[
10		blk_queue_make_request(NULL, &make_request);
11	])
12
13	ZFS_LINUX_TEST_SRC([make_request_fn_blk_qc_t], [
14		#include <linux/blkdev.h>
15		blk_qc_t make_request(struct request_queue *q,
16		    struct bio *bio) { return (BLK_QC_T_NONE); }
17	],[
18		blk_queue_make_request(NULL, &make_request);
19	])
20
21	ZFS_LINUX_TEST_SRC([blk_alloc_queue_request_fn], [
22		#include <linux/blkdev.h>
23		blk_qc_t make_request(struct request_queue *q,
24		    struct bio *bio) { return (BLK_QC_T_NONE); }
25	],[
26		struct request_queue *q __attribute__ ((unused));
27		q = blk_alloc_queue(make_request, NUMA_NO_NODE);
28	])
29
30	ZFS_LINUX_TEST_SRC([blk_alloc_queue_request_fn_rh], [
31		#include <linux/blkdev.h>
32		blk_qc_t make_request(struct request_queue *q,
33		    struct bio *bio) { return (BLK_QC_T_NONE); }
34	],[
35		struct request_queue *q __attribute__ ((unused));
36		q = blk_alloc_queue_rh(make_request, NUMA_NO_NODE);
37	])
38
39	ZFS_LINUX_TEST_SRC([block_device_operations_submit_bio], [
40		#include <linux/blkdev.h>
41	],[
42		struct block_device_operations o;
43		o.submit_bio = NULL;
44	])
45
46	ZFS_LINUX_TEST_SRC([blk_alloc_disk], [
47		#include <linux/blkdev.h>
48	],[
49		struct gendisk *disk  __attribute__ ((unused));
50		disk = blk_alloc_disk(NUMA_NO_NODE);
51	])
52])
53
54AC_DEFUN([ZFS_AC_KERNEL_MAKE_REQUEST_FN], [
55	dnl # Checked as part of the blk_alloc_queue_request_fn test
56	dnl #
57	dnl # Linux 5.9 API Change
58	dnl # make_request_fn was moved into block_device_operations->submit_bio
59	dnl #
60	AC_MSG_CHECKING([whether submit_bio is member of struct block_device_operations])
61	ZFS_LINUX_TEST_RESULT([block_device_operations_submit_bio], [
62		AC_MSG_RESULT(yes)
63
64		AC_DEFINE(HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS, 1,
65		    [submit_bio is member of struct block_device_operations])
66
67		dnl #
68		dnl # Linux 5.14 API Change:
69		dnl # blk_alloc_queue() + alloc_disk() combo replaced by
70		dnl # a single call to blk_alloc_disk().
71		dnl #
72		AC_MSG_CHECKING([whether blk_alloc_disk() exists])
73		ZFS_LINUX_TEST_RESULT([blk_alloc_disk], [
74			AC_MSG_RESULT(yes)
75			AC_DEFINE([HAVE_BLK_ALLOC_DISK], 1, [blk_alloc_disk() exists])
76		], [
77			AC_MSG_RESULT(no)
78		])
79	],[
80		AC_MSG_RESULT(no)
81
82		dnl # Checked as part of the blk_alloc_queue_request_fn test
83		dnl #
84		dnl # Linux 5.7 API Change
85		dnl # blk_alloc_queue() expects request function.
86		dnl #
87		AC_MSG_CHECKING([whether blk_alloc_queue() expects request function])
88		ZFS_LINUX_TEST_RESULT([blk_alloc_queue_request_fn], [
89			AC_MSG_RESULT(yes)
90
91			dnl # This is currently always the case.
92			AC_MSG_CHECKING([whether make_request_fn() returns blk_qc_t])
93			AC_MSG_RESULT(yes)
94
95			AC_DEFINE(HAVE_BLK_ALLOC_QUEUE_REQUEST_FN, 1,
96			    [blk_alloc_queue() expects request function])
97			AC_DEFINE(MAKE_REQUEST_FN_RET, blk_qc_t,
98			    [make_request_fn() return type])
99			AC_DEFINE(HAVE_MAKE_REQUEST_FN_RET_QC, 1,
100			    [Noting that make_request_fn() returns blk_qc_t])
101		],[
102			dnl #
103			dnl # CentOS Stream 4.18.0-257 API Change
104			dnl # The Linux 5.7 blk_alloc_queue() change was back-
105			dnl # ported and the symbol renamed blk_alloc_queue_rh().
106			dnl # As of this kernel version they're not providing
107			dnl # any compatibility code in the kernel for this.
108			dnl #
109			ZFS_LINUX_TEST_RESULT([blk_alloc_queue_request_fn_rh], [
110				AC_MSG_RESULT(yes)
111
112				dnl # This is currently always the case.
113				AC_MSG_CHECKING([whether make_request_fn_rh() returns blk_qc_t])
114				AC_MSG_RESULT(yes)
115
116				AC_DEFINE(HAVE_BLK_ALLOC_QUEUE_REQUEST_FN_RH, 1,
117				    [blk_alloc_queue_rh() expects request function])
118				AC_DEFINE(MAKE_REQUEST_FN_RET, blk_qc_t,
119				    [make_request_fn() return type])
120				AC_DEFINE(HAVE_MAKE_REQUEST_FN_RET_QC, 1,
121				    [Noting that make_request_fn() returns blk_qc_t])
122			],[
123				AC_MSG_RESULT(no)
124
125				dnl #
126				dnl # Linux 3.2 API Change
127				dnl # make_request_fn returns void.
128				dnl #
129				AC_MSG_CHECKING(
130				    [whether make_request_fn() returns void])
131				ZFS_LINUX_TEST_RESULT([make_request_fn_void], [
132					AC_MSG_RESULT(yes)
133					AC_DEFINE(MAKE_REQUEST_FN_RET, void,
134					    [make_request_fn() return type])
135					AC_DEFINE(HAVE_MAKE_REQUEST_FN_RET_VOID, 1,
136					    [Noting that make_request_fn() returns void])
137				],[
138					AC_MSG_RESULT(no)
139
140					dnl #
141					dnl # Linux 4.4 API Change
142					dnl # make_request_fn returns blk_qc_t.
143					dnl #
144					AC_MSG_CHECKING(
145					    [whether make_request_fn() returns blk_qc_t])
146					ZFS_LINUX_TEST_RESULT([make_request_fn_blk_qc_t], [
147						AC_MSG_RESULT(yes)
148						AC_DEFINE(MAKE_REQUEST_FN_RET, blk_qc_t,
149						    [make_request_fn() return type])
150						AC_DEFINE(HAVE_MAKE_REQUEST_FN_RET_QC, 1,
151						    [Noting that make_request_fn() ]
152						    [returns blk_qc_t])
153					],[
154						ZFS_LINUX_TEST_ERROR([make_request_fn])
155					])
156				])
157			])
158		])
159	])
160])
161