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