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		static 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		static 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		static 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		static 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	ZFS_LINUX_TEST_SRC([blk_alloc_disk_2arg], [
54		#include <linux/blkdev.h>
55	],[
56		struct queue_limits *lim = NULL;
57		struct gendisk *disk  __attribute__ ((unused));
58		disk = blk_alloc_disk(lim, NUMA_NO_NODE);
59	])
60
61	ZFS_LINUX_TEST_SRC([blk_cleanup_disk], [
62		#include <linux/blkdev.h>
63	],[
64		struct gendisk *disk  __attribute__ ((unused));
65		blk_cleanup_disk(disk);
66	])
67])
68
69AC_DEFUN([ZFS_AC_KERNEL_MAKE_REQUEST_FN], [
70	dnl # Checked as part of the blk_alloc_queue_request_fn test
71	dnl #
72	dnl # Linux 5.9 API Change
73	dnl # make_request_fn was moved into block_device_operations->submit_bio
74	dnl #
75	AC_MSG_CHECKING([whether submit_bio is member of struct block_device_operations])
76	ZFS_LINUX_TEST_RESULT([block_device_operations_submit_bio], [
77		AC_MSG_RESULT(yes)
78
79		AC_DEFINE(HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS, 1,
80		    [submit_bio is member of struct block_device_operations])
81
82		dnl #
83		dnl # Linux 5.14 API Change:
84		dnl # blk_alloc_queue() + alloc_disk() combo replaced by
85		dnl # a single call to blk_alloc_disk().
86		dnl #
87		AC_MSG_CHECKING([whether blk_alloc_disk() exists])
88		ZFS_LINUX_TEST_RESULT([blk_alloc_disk], [
89			AC_MSG_RESULT(yes)
90			AC_DEFINE([HAVE_BLK_ALLOC_DISK], 1, [blk_alloc_disk() exists])
91
92			dnl #
93			dnl # 5.20 API change,
94			dnl # Removed blk_cleanup_disk(), put_disk() should be used.
95			dnl #
96			AC_MSG_CHECKING([whether blk_cleanup_disk() exists])
97			ZFS_LINUX_TEST_RESULT([blk_cleanup_disk], [
98				AC_MSG_RESULT(yes)
99				AC_DEFINE([HAVE_BLK_CLEANUP_DISK], 1,
100				    [blk_cleanup_disk() exists])
101			], [
102				AC_MSG_RESULT(no)
103			])
104		], [
105			AC_MSG_RESULT(no)
106		])
107
108		dnl #
109		dnl # Linux 6.9 API Change:
110		dnl # blk_alloc_queue() takes a nullable queue_limits arg.
111		dnl #
112		AC_MSG_CHECKING([whether blk_alloc_disk() exists and takes 2 args])
113		ZFS_LINUX_TEST_RESULT([blk_alloc_disk_2arg], [
114			AC_MSG_RESULT(yes)
115			AC_DEFINE([HAVE_BLK_ALLOC_DISK_2ARG], 1, [blk_alloc_disk() exists and takes 2 args])
116
117			dnl #
118			dnl # 5.20 API change,
119			dnl # Removed blk_cleanup_disk(), put_disk() should be used.
120			dnl #
121			AC_MSG_CHECKING([whether blk_cleanup_disk() exists])
122			ZFS_LINUX_TEST_RESULT([blk_cleanup_disk], [
123				AC_MSG_RESULT(yes)
124				AC_DEFINE([HAVE_BLK_CLEANUP_DISK], 1,
125				    [blk_cleanup_disk() exists])
126			], [
127				AC_MSG_RESULT(no)
128			])
129		], [
130			AC_MSG_RESULT(no)
131		])
132	],[
133		AC_MSG_RESULT(no)
134
135		dnl # Checked as part of the blk_alloc_queue_request_fn test
136		dnl #
137		dnl # Linux 5.7 API Change
138		dnl # blk_alloc_queue() expects request function.
139		dnl #
140		AC_MSG_CHECKING([whether blk_alloc_queue() expects request function])
141		ZFS_LINUX_TEST_RESULT([blk_alloc_queue_request_fn], [
142			AC_MSG_RESULT(yes)
143
144			dnl # This is currently always the case.
145			AC_MSG_CHECKING([whether make_request_fn() returns blk_qc_t])
146			AC_MSG_RESULT(yes)
147
148			AC_DEFINE(HAVE_BLK_ALLOC_QUEUE_REQUEST_FN, 1,
149			    [blk_alloc_queue() expects request function])
150			AC_DEFINE(MAKE_REQUEST_FN_RET, blk_qc_t,
151			    [make_request_fn() return type])
152			AC_DEFINE(HAVE_MAKE_REQUEST_FN_RET_QC, 1,
153			    [Noting that make_request_fn() returns blk_qc_t])
154		],[
155			dnl #
156			dnl # CentOS Stream 4.18.0-257 API Change
157			dnl # The Linux 5.7 blk_alloc_queue() change was back-
158			dnl # ported and the symbol renamed blk_alloc_queue_rh().
159			dnl # As of this kernel version they're not providing
160			dnl # any compatibility code in the kernel for this.
161			dnl #
162			ZFS_LINUX_TEST_RESULT([blk_alloc_queue_request_fn_rh], [
163				AC_MSG_RESULT(yes)
164
165				dnl # This is currently always the case.
166				AC_MSG_CHECKING([whether make_request_fn_rh() returns blk_qc_t])
167				AC_MSG_RESULT(yes)
168
169				AC_DEFINE(HAVE_BLK_ALLOC_QUEUE_REQUEST_FN_RH, 1,
170				    [blk_alloc_queue_rh() expects request function])
171				AC_DEFINE(MAKE_REQUEST_FN_RET, blk_qc_t,
172				    [make_request_fn() return type])
173				AC_DEFINE(HAVE_MAKE_REQUEST_FN_RET_QC, 1,
174				    [Noting that make_request_fn() returns blk_qc_t])
175			],[
176				AC_MSG_RESULT(no)
177
178				dnl #
179				dnl # Linux 3.2 API Change
180				dnl # make_request_fn returns void.
181				dnl #
182				AC_MSG_CHECKING(
183				    [whether make_request_fn() returns void])
184				ZFS_LINUX_TEST_RESULT([make_request_fn_void], [
185					AC_MSG_RESULT(yes)
186					AC_DEFINE(MAKE_REQUEST_FN_RET, void,
187					    [make_request_fn() return type])
188					AC_DEFINE(HAVE_MAKE_REQUEST_FN_RET_VOID, 1,
189					    [Noting that make_request_fn() returns void])
190				],[
191					AC_MSG_RESULT(no)
192
193					dnl #
194					dnl # Linux 4.4 API Change
195					dnl # make_request_fn returns blk_qc_t.
196					dnl #
197					AC_MSG_CHECKING(
198					    [whether make_request_fn() returns blk_qc_t])
199					ZFS_LINUX_TEST_RESULT([make_request_fn_blk_qc_t], [
200						AC_MSG_RESULT(yes)
201						AC_DEFINE(MAKE_REQUEST_FN_RET, blk_qc_t,
202						    [make_request_fn() return type])
203						AC_DEFINE(HAVE_MAKE_REQUEST_FN_RET_QC, 1,
204						    [Noting that make_request_fn() ]
205						    [returns blk_qc_t])
206					],[
207						ZFS_LINUX_TEST_ERROR([make_request_fn])
208					])
209				])
210			])
211		])
212	])
213])
214