xref: /freebsd/sys/contrib/openzfs/config/kernel-bio.m4 (revision 3332f1b444d4a73238e9f59cca27bfc95fe936bd)
1dnl #
2dnl # 2.6.36 API change,
3dnl # REQ_FAILFAST_{DEV|TRANSPORT|DRIVER}
4dnl # REQ_DISCARD
5dnl # REQ_FLUSH
6dnl #
7dnl # 4.8 - 4.9 API,
8dnl # REQ_FLUSH was renamed to REQ_PREFLUSH
9dnl #
10AC_DEFUN([ZFS_AC_KERNEL_SRC_REQ], [
11	ZFS_LINUX_TEST_SRC([req_failfast_mask], [
12		#include <linux/bio.h>
13	],[
14		int flags __attribute__ ((unused));
15		flags = REQ_FAILFAST_MASK;
16	])
17
18	ZFS_LINUX_TEST_SRC([req_discard], [
19		#include <linux/bio.h>
20	],[
21		int flags __attribute__ ((unused));
22		flags = REQ_DISCARD;
23	])
24
25	ZFS_LINUX_TEST_SRC([req_flush], [
26		#include <linux/bio.h>
27	],[
28		int flags __attribute__ ((unused));
29		flags = REQ_FLUSH;
30	])
31
32	ZFS_LINUX_TEST_SRC([req_preflush], [
33		#include <linux/bio.h>
34	],[
35		int flags __attribute__ ((unused));
36		flags = REQ_PREFLUSH;
37	])
38])
39
40AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_FAILFAST_MASK], [
41	AC_MSG_CHECKING([whether REQ_FAILFAST_MASK is defined])
42	ZFS_LINUX_TEST_RESULT([req_failfast_mask], [
43		AC_MSG_RESULT(yes)
44	],[
45		ZFS_LINUX_TEST_ERROR([REQ_FAILFAST_MASK])
46	])
47])
48
49AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_DISCARD], [
50	AC_MSG_CHECKING([whether REQ_DISCARD is defined])
51	ZFS_LINUX_TEST_RESULT([req_discard], [
52		AC_MSG_RESULT(yes)
53		AC_DEFINE(HAVE_REQ_DISCARD, 1, [REQ_DISCARD is defined])
54	],[
55		AC_MSG_RESULT(no)
56	])
57])
58
59AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_FLUSH], [
60	AC_MSG_CHECKING([whether REQ_FLUSH is defined])
61	ZFS_LINUX_TEST_RESULT([req_flush], [
62		AC_MSG_RESULT(yes)
63		AC_DEFINE(HAVE_REQ_FLUSH, 1, [REQ_FLUSH is defined])
64	],[
65		AC_MSG_RESULT(no)
66	])
67])
68
69AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_PREFLUSH], [
70	AC_MSG_CHECKING([whether REQ_PREFLUSH is defined])
71	ZFS_LINUX_TEST_RESULT([req_preflush], [
72		AC_MSG_RESULT(yes)
73		AC_DEFINE(HAVE_REQ_PREFLUSH, 1, [REQ_PREFLUSH is defined])
74	],[
75		AC_MSG_RESULT(no)
76	])
77])
78
79dnl #
80dnl # Linux 4.8 API,
81dnl #
82dnl # The bio_op() helper was introduced as a replacement for explicitly
83dnl # checking the bio->bi_rw flags.  The following checks are used to
84dnl # detect if a specific operation is supported.
85dnl #
86AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_OPS], [
87	ZFS_LINUX_TEST_SRC([req_op_discard], [
88		#include <linux/blk_types.h>
89	],[
90		int op __attribute__ ((unused)) = REQ_OP_DISCARD;
91	])
92
93	ZFS_LINUX_TEST_SRC([req_op_secure_erase], [
94		#include <linux/blk_types.h>
95	],[
96		int op __attribute__ ((unused)) = REQ_OP_SECURE_ERASE;
97	])
98
99	ZFS_LINUX_TEST_SRC([req_op_flush], [
100		#include <linux/blk_types.h>
101	],[
102		int op __attribute__ ((unused)) = REQ_OP_FLUSH;
103	])
104
105	ZFS_LINUX_TEST_SRC([bio_bi_opf], [
106		#include <linux/bio.h>
107	],[
108		struct bio bio __attribute__ ((unused));
109		bio.bi_opf = 0;
110	])
111
112	ZFS_LINUX_TEST_SRC([bio_set_op_attrs], [
113		#include <linux/bio.h>
114	],[
115		struct bio *bio __attribute__ ((unused)) = NULL;
116		bio_set_op_attrs(bio, 0, 0);
117	])
118])
119
120AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_OP_DISCARD], [
121	AC_MSG_CHECKING([whether REQ_OP_DISCARD is defined])
122	ZFS_LINUX_TEST_RESULT([req_op_discard], [
123		AC_MSG_RESULT(yes)
124		AC_DEFINE(HAVE_REQ_OP_DISCARD, 1, [REQ_OP_DISCARD is defined])
125	],[
126		AC_MSG_RESULT(no)
127	])
128])
129
130AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_OP_SECURE_ERASE], [
131	AC_MSG_CHECKING([whether REQ_OP_SECURE_ERASE is defined])
132	ZFS_LINUX_TEST_RESULT([req_op_secure_erase], [
133		AC_MSG_RESULT(yes)
134		AC_DEFINE(HAVE_REQ_OP_SECURE_ERASE, 1,
135		    [REQ_OP_SECURE_ERASE is defined])
136	],[
137		AC_MSG_RESULT(no)
138	])
139])
140
141AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_OP_FLUSH], [
142	AC_MSG_CHECKING([whether REQ_OP_FLUSH is defined])
143	ZFS_LINUX_TEST_RESULT([req_op_flush], [
144		AC_MSG_RESULT(yes)
145		AC_DEFINE(HAVE_REQ_OP_FLUSH, 1, [REQ_OP_FLUSH is defined])
146	],[
147		AC_MSG_RESULT(no)
148	])
149])
150
151AC_DEFUN([ZFS_AC_KERNEL_BIO_BI_OPF], [
152	AC_MSG_CHECKING([whether bio->bi_opf is defined])
153	ZFS_LINUX_TEST_RESULT([bio_bi_opf], [
154		AC_MSG_RESULT(yes)
155		AC_DEFINE(HAVE_BIO_BI_OPF, 1, [bio->bi_opf is defined])
156	],[
157		AC_MSG_RESULT(no)
158	])
159])
160
161AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_OP_ATTRS], [
162	AC_MSG_CHECKING([whether bio_set_op_attrs is available])
163	ZFS_LINUX_TEST_RESULT([bio_set_op_attrs], [
164		AC_MSG_RESULT(yes)
165		AC_DEFINE(HAVE_BIO_SET_OP_ATTRS, 1,
166		    [bio_set_op_attrs is available])
167	],[
168		AC_MSG_RESULT(no)
169	])
170])
171
172dnl #
173dnl # Linux 4.14 API,
174dnl #
175dnl # The bio_set_dev() helper macro was introduced as part of the transition
176dnl # to have struct gendisk in struct bio.
177dnl #
178dnl # Linux 5.0 API,
179dnl #
180dnl # The bio_set_dev() helper macro was updated to internally depend on
181dnl # bio_associate_blkg() symbol which is exported GPL-only.
182dnl #
183AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_SET_DEV], [
184	ZFS_LINUX_TEST_SRC([bio_set_dev], [
185		#include <linux/bio.h>
186		#include <linux/fs.h>
187	],[
188		struct block_device *bdev = NULL;
189		struct bio *bio = NULL;
190		bio_set_dev(bio, bdev);
191	], [], [ZFS_META_LICENSE])
192])
193
194AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_DEV], [
195	AC_MSG_CHECKING([whether bio_set_dev() is available])
196	ZFS_LINUX_TEST_RESULT([bio_set_dev], [
197		AC_MSG_RESULT(yes)
198		AC_DEFINE(HAVE_BIO_SET_DEV, 1, [bio_set_dev() is available])
199
200		AC_MSG_CHECKING([whether bio_set_dev() is GPL-only])
201		ZFS_LINUX_TEST_RESULT([bio_set_dev_license], [
202			AC_MSG_RESULT(no)
203		],[
204			AC_MSG_RESULT(yes)
205			AC_DEFINE(HAVE_BIO_SET_DEV_GPL_ONLY, 1,
206			    [bio_set_dev() GPL-only])
207		])
208	],[
209		AC_MSG_RESULT(no)
210	])
211])
212
213dnl #
214dnl # 4.3 API change
215dnl # Error argument dropped from bio_endio in favor of newly introduced
216dnl # bio->bi_error. This also replaces bio->bi_flags value BIO_UPTODATE.
217dnl # Introduced by torvalds/linux@4246a0b63bd8f56a1469b12eafeb875b1041a451
218dnl # ("block: add a bi_error field to struct bio").
219dnl #
220AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_END_IO_T_ARGS], [
221	ZFS_LINUX_TEST_SRC([bio_end_io_t_args], [
222		#include <linux/bio.h>
223		void wanted_end_io(struct bio *bio) { return; }
224		bio_end_io_t *end_io __attribute__ ((unused)) = wanted_end_io;
225	], [])
226])
227
228AC_DEFUN([ZFS_AC_KERNEL_BIO_END_IO_T_ARGS], [
229	AC_MSG_CHECKING([whether bio_end_io_t wants 1 arg])
230	ZFS_LINUX_TEST_RESULT([bio_end_io_t_args], [
231		AC_MSG_RESULT(yes)
232		AC_DEFINE(HAVE_1ARG_BIO_END_IO_T, 1,
233		    [bio_end_io_t wants 1 arg])
234	], [
235		AC_MSG_RESULT(no)
236	])
237])
238
239dnl #
240dnl # 4.13 API change
241dnl # The bio->bi_error field was replaced with bio->bi_status which is an
242dnl # enum which describes all possible error types.
243dnl #
244AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_BI_STATUS], [
245	ZFS_LINUX_TEST_SRC([bio_bi_status], [
246		#include <linux/bio.h>
247	], [
248		struct bio bio __attribute__ ((unused));
249		blk_status_t status __attribute__ ((unused)) = BLK_STS_OK;
250		bio.bi_status = status;
251	])
252])
253
254AC_DEFUN([ZFS_AC_KERNEL_BIO_BI_STATUS], [
255	AC_MSG_CHECKING([whether bio->bi_status exists])
256	ZFS_LINUX_TEST_RESULT([bio_bi_status], [
257		AC_MSG_RESULT(yes)
258		AC_DEFINE(HAVE_BIO_BI_STATUS, 1, [bio->bi_status exists])
259	],[
260		AC_MSG_RESULT(no)
261	])
262])
263
264dnl #
265dnl # 3.14 API change,
266dnl # Immutable biovecs. A number of fields of struct bio are moved to
267dnl # struct bvec_iter.
268dnl #
269AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_BVEC_ITER], [
270	ZFS_LINUX_TEST_SRC([bio_bvec_iter], [
271		#include <linux/bio.h>
272	],[
273		struct bio bio;
274		bio.bi_iter.bi_sector = 0;
275	])
276])
277
278AC_DEFUN([ZFS_AC_KERNEL_BIO_BVEC_ITER], [
279	AC_MSG_CHECKING([whether bio has bi_iter])
280	ZFS_LINUX_TEST_RESULT([bio_bvec_iter], [
281		AC_MSG_RESULT(yes)
282		AC_DEFINE(HAVE_BIO_BVEC_ITER, 1, [bio has bi_iter])
283	],[
284		AC_MSG_RESULT(no)
285	])
286])
287
288dnl #
289dnl # 4.8 API change
290dnl # The rw argument has been removed from submit_bio/submit_bio_wait.
291dnl # Callers are now expected to set bio->bi_rw instead of passing it in.
292dnl #
293AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_SUBMIT_BIO], [
294	ZFS_LINUX_TEST_SRC([submit_bio], [
295		#include <linux/bio.h>
296	],[
297		struct bio *bio = NULL;
298		(void) submit_bio(bio);
299	])
300])
301
302AC_DEFUN([ZFS_AC_KERNEL_BIO_SUBMIT_BIO], [
303	AC_MSG_CHECKING([whether submit_bio() wants 1 arg])
304	ZFS_LINUX_TEST_RESULT([submit_bio], [
305		AC_MSG_RESULT(yes)
306		AC_DEFINE(HAVE_1ARG_SUBMIT_BIO, 1, [submit_bio() wants 1 arg])
307	],[
308		AC_MSG_RESULT(no)
309	])
310])
311
312dnl #
313dnl # 2.6.34 API change
314dnl # current->bio_list
315dnl #
316AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_CURRENT_BIO_LIST], [
317	ZFS_LINUX_TEST_SRC([current_bio_list], [
318		#include <linux/sched.h>
319	], [
320		current->bio_list = (struct bio_list *) NULL;
321	])
322])
323
324AC_DEFUN([ZFS_AC_KERNEL_BIO_CURRENT_BIO_LIST], [
325	AC_MSG_CHECKING([whether current->bio_list exists])
326	ZFS_LINUX_TEST_RESULT([current_bio_list], [
327		AC_MSG_RESULT(yes)
328	],[
329		ZFS_LINUX_TEST_ERROR([bio_list])
330	])
331])
332
333dnl #
334dnl # Linux 5.5 API,
335dnl #
336dnl # The Linux 5.5 kernel updated percpu_ref_tryget() which is inlined by
337dnl # blkg_tryget() to use rcu_read_lock() instead of rcu_read_lock_sched().
338dnl # As a side effect the function was converted to GPL-only.
339dnl #
340AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKG_TRYGET], [
341	ZFS_LINUX_TEST_SRC([blkg_tryget], [
342		#include <linux/blk-cgroup.h>
343		#include <linux/bio.h>
344		#include <linux/fs.h>
345	],[
346		struct blkcg_gq blkg __attribute__ ((unused)) = {};
347		bool rc __attribute__ ((unused));
348		rc = blkg_tryget(&blkg);
349	], [], [ZFS_META_LICENSE])
350])
351
352AC_DEFUN([ZFS_AC_KERNEL_BLKG_TRYGET], [
353	AC_MSG_CHECKING([whether blkg_tryget() is available])
354	ZFS_LINUX_TEST_RESULT([blkg_tryget], [
355		AC_MSG_RESULT(yes)
356		AC_DEFINE(HAVE_BLKG_TRYGET, 1, [blkg_tryget() is available])
357
358		AC_MSG_CHECKING([whether blkg_tryget() is GPL-only])
359		ZFS_LINUX_TEST_RESULT([blkg_tryget_license], [
360			AC_MSG_RESULT(no)
361		],[
362			AC_MSG_RESULT(yes)
363			AC_DEFINE(HAVE_BLKG_TRYGET_GPL_ONLY, 1,
364			    [blkg_tryget() GPL-only])
365		])
366	],[
367		AC_MSG_RESULT(no)
368	])
369])
370
371dnl #
372dnl # Linux 5.12 API,
373dnl #
374dnl # The Linux 5.12 kernel updated struct bio to create a new bi_bdev member
375dnl # and bio->bi_disk was moved to bio->bi_bdev->bd_disk
376dnl #
377AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_BDEV_DISK], [
378	ZFS_LINUX_TEST_SRC([bio_bdev_disk], [
379		#include <linux/blk_types.h>
380		#include <linux/blkdev.h>
381	],[
382		struct bio *b = NULL;
383		struct gendisk *d = b->bi_bdev->bd_disk;
384		blk_register_queue(d);
385	])
386])
387
388AC_DEFUN([ZFS_AC_KERNEL_BIO_BDEV_DISK], [
389	AC_MSG_CHECKING([whether bio->bi_bdev->bd_disk exists])
390	ZFS_LINUX_TEST_RESULT([bio_bdev_disk], [
391		AC_MSG_RESULT(yes)
392		AC_DEFINE(HAVE_BIO_BDEV_DISK, 1, [bio->bi_bdev->bd_disk exists])
393	],[
394		AC_MSG_RESULT(no)
395	])
396])
397
398AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [
399	ZFS_AC_KERNEL_SRC_REQ
400	ZFS_AC_KERNEL_SRC_BIO_OPS
401	ZFS_AC_KERNEL_SRC_BIO_SET_DEV
402	ZFS_AC_KERNEL_SRC_BIO_END_IO_T_ARGS
403	ZFS_AC_KERNEL_SRC_BIO_BI_STATUS
404	ZFS_AC_KERNEL_SRC_BIO_BVEC_ITER
405	ZFS_AC_KERNEL_SRC_BIO_SUBMIT_BIO
406	ZFS_AC_KERNEL_SRC_BIO_CURRENT_BIO_LIST
407	ZFS_AC_KERNEL_SRC_BLKG_TRYGET
408	ZFS_AC_KERNEL_SRC_BIO_BDEV_DISK
409])
410
411AC_DEFUN([ZFS_AC_KERNEL_BIO], [
412	ZFS_AC_KERNEL_BIO_REQ_FAILFAST_MASK
413	ZFS_AC_KERNEL_BIO_REQ_DISCARD
414	ZFS_AC_KERNEL_BIO_REQ_FLUSH
415	ZFS_AC_KERNEL_BIO_REQ_PREFLUSH
416
417	ZFS_AC_KERNEL_BIO_REQ_OP_DISCARD
418	ZFS_AC_KERNEL_BIO_REQ_OP_SECURE_ERASE
419	ZFS_AC_KERNEL_BIO_REQ_OP_FLUSH
420	ZFS_AC_KERNEL_BIO_BI_OPF
421	ZFS_AC_KERNEL_BIO_SET_OP_ATTRS
422
423	ZFS_AC_KERNEL_BIO_SET_DEV
424	ZFS_AC_KERNEL_BIO_END_IO_T_ARGS
425	ZFS_AC_KERNEL_BIO_BI_STATUS
426	ZFS_AC_KERNEL_BIO_BVEC_ITER
427	ZFS_AC_KERNEL_BIO_SUBMIT_BIO
428	ZFS_AC_KERNEL_BIO_CURRENT_BIO_LIST
429	ZFS_AC_KERNEL_BLKG_TRYGET
430	ZFS_AC_KERNEL_BIO_BDEV_DISK
431])
432