2 dnl # 2.6.36 API change,
3 dnl # REQ_FAILFAST_{DEV|TRANSPORT|DRIVER}
8 dnl # REQ_FLUSH was renamed to REQ_PREFLUSH
10 AC_DEFUN([ZFS_AC_KERNEL_SRC_REQ], [
11 ZFS_LINUX_TEST_SRC([req_failfast_mask], [
12 #include <linux/bio.h>
14 int flags __attribute__ ((unused));
15 flags = REQ_FAILFAST_MASK;
18 ZFS_LINUX_TEST_SRC([req_discard], [
19 #include <linux/bio.h>
21 int flags __attribute__ ((unused));
25 ZFS_LINUX_TEST_SRC([req_flush], [
26 #include <linux/bio.h>
28 int flags __attribute__ ((unused));
32 ZFS_LINUX_TEST_SRC([req_preflush], [
33 #include <linux/bio.h>
35 int flags __attribute__ ((unused));
40 AC_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], [
45 ZFS_LINUX_TEST_ERROR([REQ_FAILFAST_MASK])
49 AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_DISCARD], [
50 AC_MSG_CHECKING([whether REQ_DISCARD is defined])
51 ZFS_LINUX_TEST_RESULT([req_discard], [
53 AC_DEFINE(HAVE_REQ_DISCARD, 1, [REQ_DISCARD is defined])
59 AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_FLUSH], [
60 AC_MSG_CHECKING([whether REQ_FLUSH is defined])
61 ZFS_LINUX_TEST_RESULT([req_flush], [
63 AC_DEFINE(HAVE_REQ_FLUSH, 1, [REQ_FLUSH is defined])
69 AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_PREFLUSH], [
70 AC_MSG_CHECKING([whether REQ_PREFLUSH is defined])
71 ZFS_LINUX_TEST_RESULT([req_preflush], [
73 AC_DEFINE(HAVE_REQ_PREFLUSH, 1, [REQ_PREFLUSH is defined])
82 dnl # The bio_op() helper was introduced as a replacement for explicitly
83 dnl # checking the bio->bi_rw flags. The following checks are used to
84 dnl # detect if a specific operation is supported.
86 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_OPS], [
87 ZFS_LINUX_TEST_SRC([req_op_discard], [
88 #include <linux/blk_types.h>
90 int op __attribute__ ((unused)) = REQ_OP_DISCARD;
93 ZFS_LINUX_TEST_SRC([req_op_secure_erase], [
94 #include <linux/blk_types.h>
96 int op __attribute__ ((unused)) = REQ_OP_SECURE_ERASE;
99 ZFS_LINUX_TEST_SRC([req_op_flush], [
100 #include <linux/blk_types.h>
102 int op __attribute__ ((unused)) = REQ_OP_FLUSH;
105 ZFS_LINUX_TEST_SRC([bio_bi_opf], [
106 #include <linux/bio.h>
108 struct bio bio __attribute__ ((unused));
112 ZFS_LINUX_TEST_SRC([bio_set_op_attrs], [
113 #include <linux/bio.h>
115 struct bio *bio __attribute__ ((unused)) = NULL;
116 bio_set_op_attrs(bio, 0, 0);
120 AC_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], [
124 AC_DEFINE(HAVE_REQ_OP_DISCARD, 1, [REQ_OP_DISCARD is defined])
130 AC_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], [
134 AC_DEFINE(HAVE_REQ_OP_SECURE_ERASE, 1,
135 [REQ_OP_SECURE_ERASE is defined])
141 AC_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], [
145 AC_DEFINE(HAVE_REQ_OP_FLUSH, 1, [REQ_OP_FLUSH is defined])
151 AC_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], [
155 AC_DEFINE(HAVE_BIO_BI_OPF, 1, [bio->bi_opf is defined])
161 AC_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], [
165 AC_DEFINE(HAVE_BIO_SET_OP_ATTRS, 1,
166 [bio_set_op_attrs is available])
173 dnl # Linux 4.14 API,
175 dnl # The bio_set_dev() helper macro was introduced as part of the transition
176 dnl # to have struct gendisk in struct bio.
180 dnl # The bio_set_dev() helper macro was updated to internally depend on
181 dnl # bio_associate_blkg() symbol which is exported GPL-only.
183 AC_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>
188 struct block_device *bdev = NULL;
189 struct bio *bio = NULL;
190 bio_set_dev(bio, bdev);
191 ], [], [ZFS_META_LICENSE])
197 dnl # bio_set_dev is no longer a helper macro and is now an inline function,
198 dnl # meaning that the function it calls internally can no longer be overridden
201 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_SET_DEV_MACRO], [
202 ZFS_LINUX_TEST_SRC([bio_set_dev_macro], [
203 #include <linux/bio.h>
204 #include <linux/fs.h>
209 ], [], [ZFS_META_LICENSE])
212 AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_DEV], [
213 AC_MSG_CHECKING([whether bio_set_dev() is available])
214 ZFS_LINUX_TEST_RESULT([bio_set_dev], [
216 AC_DEFINE(HAVE_BIO_SET_DEV, 1, [bio_set_dev() is available])
218 AC_MSG_CHECKING([whether bio_set_dev() is GPL-only])
219 ZFS_LINUX_TEST_RESULT([bio_set_dev_license], [
223 AC_DEFINE(HAVE_BIO_SET_DEV_GPL_ONLY, 1,
224 [bio_set_dev() GPL-only])
227 AC_MSG_CHECKING([whether bio_set_dev() is a macro])
228 ZFS_LINUX_TEST_RESULT([bio_set_dev_macro], [
230 AC_DEFINE(HAVE_BIO_SET_DEV_MACRO, 1,
231 [bio_set_dev() is a macro])
242 dnl # Error argument dropped from bio_endio in favor of newly introduced
243 dnl # bio->bi_error. This also replaces bio->bi_flags value BIO_UPTODATE.
244 dnl # Introduced by torvalds/linux@4246a0b63bd8f56a1469b12eafeb875b1041a451
245 dnl # ("block: add a bi_error field to struct bio").
247 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_END_IO_T_ARGS], [
248 ZFS_LINUX_TEST_SRC([bio_end_io_t_args], [
249 #include <linux/bio.h>
250 void wanted_end_io(struct bio *bio) { return; }
251 bio_end_io_t *end_io __attribute__ ((unused)) = wanted_end_io;
255 AC_DEFUN([ZFS_AC_KERNEL_BIO_END_IO_T_ARGS], [
256 AC_MSG_CHECKING([whether bio_end_io_t wants 1 arg])
257 ZFS_LINUX_TEST_RESULT([bio_end_io_t_args], [
259 AC_DEFINE(HAVE_1ARG_BIO_END_IO_T, 1,
260 [bio_end_io_t wants 1 arg])
267 dnl # 4.13 API change
268 dnl # The bio->bi_error field was replaced with bio->bi_status which is an
269 dnl # enum which describes all possible error types.
271 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_BI_STATUS], [
272 ZFS_LINUX_TEST_SRC([bio_bi_status], [
273 #include <linux/bio.h>
275 struct bio bio __attribute__ ((unused));
276 blk_status_t status __attribute__ ((unused)) = BLK_STS_OK;
277 bio.bi_status = status;
281 AC_DEFUN([ZFS_AC_KERNEL_BIO_BI_STATUS], [
282 AC_MSG_CHECKING([whether bio->bi_status exists])
283 ZFS_LINUX_TEST_RESULT([bio_bi_status], [
285 AC_DEFINE(HAVE_BIO_BI_STATUS, 1, [bio->bi_status exists])
292 dnl # 3.14 API change,
293 dnl # Immutable biovecs. A number of fields of struct bio are moved to
294 dnl # struct bvec_iter.
296 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_BVEC_ITER], [
297 ZFS_LINUX_TEST_SRC([bio_bvec_iter], [
298 #include <linux/bio.h>
301 bio.bi_iter.bi_sector = 0;
305 AC_DEFUN([ZFS_AC_KERNEL_BIO_BVEC_ITER], [
306 AC_MSG_CHECKING([whether bio has bi_iter])
307 ZFS_LINUX_TEST_RESULT([bio_bvec_iter], [
309 AC_DEFINE(HAVE_BIO_BVEC_ITER, 1, [bio has bi_iter])
317 dnl # The rw argument has been removed from submit_bio/submit_bio_wait.
318 dnl # Callers are now expected to set bio->bi_rw instead of passing it in.
320 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_SUBMIT_BIO], [
321 ZFS_LINUX_TEST_SRC([submit_bio], [
322 #include <linux/bio.h>
324 struct bio *bio = NULL;
325 (void) submit_bio(bio);
329 AC_DEFUN([ZFS_AC_KERNEL_BIO_SUBMIT_BIO], [
330 AC_MSG_CHECKING([whether submit_bio() wants 1 arg])
331 ZFS_LINUX_TEST_RESULT([submit_bio], [
333 AC_DEFINE(HAVE_1ARG_SUBMIT_BIO, 1, [submit_bio() wants 1 arg])
340 dnl # 2.6.34 API change
341 dnl # current->bio_list
343 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_CURRENT_BIO_LIST], [
344 ZFS_LINUX_TEST_SRC([current_bio_list], [
345 #include <linux/sched.h>
347 current->bio_list = (struct bio_list *) NULL;
351 AC_DEFUN([ZFS_AC_KERNEL_BIO_CURRENT_BIO_LIST], [
352 AC_MSG_CHECKING([whether current->bio_list exists])
353 ZFS_LINUX_TEST_RESULT([current_bio_list], [
356 ZFS_LINUX_TEST_ERROR([bio_list])
363 dnl # The Linux 5.5 kernel updated percpu_ref_tryget() which is inlined by
364 dnl # blkg_tryget() to use rcu_read_lock() instead of rcu_read_lock_sched().
365 dnl # As a side effect the function was converted to GPL-only.
367 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKG_TRYGET], [
368 ZFS_LINUX_TEST_SRC([blkg_tryget], [
369 #include <linux/blk-cgroup.h>
370 #include <linux/bio.h>
371 #include <linux/fs.h>
373 struct blkcg_gq blkg __attribute__ ((unused)) = {};
374 bool rc __attribute__ ((unused));
375 rc = blkg_tryget(&blkg);
376 ], [], [ZFS_META_LICENSE])
379 AC_DEFUN([ZFS_AC_KERNEL_BLKG_TRYGET], [
380 AC_MSG_CHECKING([whether blkg_tryget() is available])
381 ZFS_LINUX_TEST_RESULT([blkg_tryget], [
383 AC_DEFINE(HAVE_BLKG_TRYGET, 1, [blkg_tryget() is available])
385 AC_MSG_CHECKING([whether blkg_tryget() is GPL-only])
386 ZFS_LINUX_TEST_RESULT([blkg_tryget_license], [
390 AC_DEFINE(HAVE_BLKG_TRYGET_GPL_ONLY, 1,
391 [blkg_tryget() GPL-only])
399 dnl # Linux 5.12 API,
401 dnl # The Linux 5.12 kernel updated struct bio to create a new bi_bdev member
402 dnl # and bio->bi_disk was moved to bio->bi_bdev->bd_disk
404 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_BDEV_DISK], [
405 ZFS_LINUX_TEST_SRC([bio_bdev_disk], [
406 #include <linux/blk_types.h>
407 #include <linux/blkdev.h>
409 struct bio *b = NULL;
410 struct gendisk *d = b->bi_bdev->bd_disk;
411 blk_register_queue(d);
415 AC_DEFUN([ZFS_AC_KERNEL_BIO_BDEV_DISK], [
416 AC_MSG_CHECKING([whether bio->bi_bdev->bd_disk exists])
417 ZFS_LINUX_TEST_RESULT([bio_bdev_disk], [
419 AC_DEFINE(HAVE_BIO_BDEV_DISK, 1, [bio->bi_bdev->bd_disk exists])
428 dnl # The Linux 5.16 API for submit_bio changed the return type to be
429 dnl # void instead of int
431 AC_DEFUN([ZFS_AC_KERNEL_SRC_BDEV_SUBMIT_BIO_RETURNS_VOID], [
432 ZFS_LINUX_TEST_SRC([bio_bdev_submit_bio_void], [
433 #include <linux/blkdev.h>
435 struct block_device_operations *bdev = NULL;
436 __attribute__((unused)) void(*f)(struct bio *) = bdev->submit_bio;
440 AC_DEFUN([ZFS_AC_KERNEL_BDEV_SUBMIT_BIO_RETURNS_VOID], [
442 [whether block_device_operations->submit_bio() returns void])
443 ZFS_LINUX_TEST_RESULT([bio_bdev_submit_bio_void], [
445 AC_DEFINE(HAVE_BDEV_SUBMIT_BIO_RETURNS_VOID, 1,
446 [block_device_operations->submit_bio() returns void])
455 dnl # The Linux 5.16 API moved struct blkcg_gq into linux/blk-cgroup.h, which
456 dnl # has been around since 2015. This test looks for the presence of that
457 dnl # header, so that it can be conditionally included where it exists, but
458 dnl # still be backward compatible with kernels that pre-date its introduction.
460 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_CGROUP_HEADER], [
461 ZFS_LINUX_TEST_SRC([blk_cgroup_header], [
462 #include <linux/blk-cgroup.h>
466 AC_DEFUN([ZFS_AC_KERNEL_BLK_CGROUP_HEADER], [
467 AC_MSG_CHECKING([whether linux/blk-cgroup.h exists])
468 ZFS_LINUX_TEST_RESULT([blk_cgroup_header],[
470 AC_DEFINE(HAVE_LINUX_BLK_CGROUP_HEADER, 1,
471 [linux/blk-cgroup.h exists])
480 dnl # In 07888c665b405b1cd3577ddebfeb74f4717a84c4 ("block: pass a block_device and opf to bio_alloc")
481 dnl # bio_alloc(gfp_t gfp_mask, unsigned short nr_iovecs)
483 dnl # bio_alloc(struct block_device *bdev, unsigned short nr_vecs, unsigned int opf, gfp_t gfp_mask)
485 dnl # > NULL/0 can be passed, both for the
486 dnl # > passthrough case on a raw request_queue and to temporarily avoid
487 dnl # > refactoring some nasty code.
489 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_ALLOC_4ARG], [
490 ZFS_LINUX_TEST_SRC([bio_alloc_4arg], [
491 #include <linux/bio.h>
494 unsigned short nr_iovecs = 0;
495 struct block_device *bdev = NULL;
496 unsigned int opf = 0;
498 struct bio *__attribute__((unused)) allocated = bio_alloc(bdev, nr_iovecs, opf, gfp_mask);
502 AC_DEFUN([ZFS_AC_KERNEL_BIO_ALLOC_4ARG], [
503 AC_MSG_CHECKING([whether bio_alloc() wants 4 args])
504 ZFS_LINUX_TEST_RESULT([bio_alloc_4arg],[
506 AC_DEFINE([HAVE_BIO_ALLOC_4ARG], 1, [bio_alloc() takes 4 arguments])
512 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [
513 ZFS_AC_KERNEL_SRC_REQ
514 ZFS_AC_KERNEL_SRC_BIO_OPS
515 ZFS_AC_KERNEL_SRC_BIO_SET_DEV
516 ZFS_AC_KERNEL_SRC_BIO_END_IO_T_ARGS
517 ZFS_AC_KERNEL_SRC_BIO_BI_STATUS
518 ZFS_AC_KERNEL_SRC_BIO_BVEC_ITER
519 ZFS_AC_KERNEL_SRC_BIO_SUBMIT_BIO
520 ZFS_AC_KERNEL_SRC_BIO_CURRENT_BIO_LIST
521 ZFS_AC_KERNEL_SRC_BLKG_TRYGET
522 ZFS_AC_KERNEL_SRC_BIO_BDEV_DISK
523 ZFS_AC_KERNEL_SRC_BDEV_SUBMIT_BIO_RETURNS_VOID
524 ZFS_AC_KERNEL_SRC_BIO_SET_DEV_MACRO
525 ZFS_AC_KERNEL_SRC_BLK_CGROUP_HEADER
526 ZFS_AC_KERNEL_SRC_BIO_ALLOC_4ARG
529 AC_DEFUN([ZFS_AC_KERNEL_BIO], [
530 ZFS_AC_KERNEL_BIO_REQ_FAILFAST_MASK
531 ZFS_AC_KERNEL_BIO_REQ_DISCARD
532 ZFS_AC_KERNEL_BIO_REQ_FLUSH
533 ZFS_AC_KERNEL_BIO_REQ_PREFLUSH
535 ZFS_AC_KERNEL_BIO_REQ_OP_DISCARD
536 ZFS_AC_KERNEL_BIO_REQ_OP_SECURE_ERASE
537 ZFS_AC_KERNEL_BIO_REQ_OP_FLUSH
538 ZFS_AC_KERNEL_BIO_BI_OPF
539 ZFS_AC_KERNEL_BIO_SET_OP_ATTRS
541 ZFS_AC_KERNEL_BIO_SET_DEV
542 ZFS_AC_KERNEL_BIO_END_IO_T_ARGS
543 ZFS_AC_KERNEL_BIO_BI_STATUS
544 ZFS_AC_KERNEL_BIO_BVEC_ITER
545 ZFS_AC_KERNEL_BIO_SUBMIT_BIO
546 ZFS_AC_KERNEL_BIO_CURRENT_BIO_LIST
547 ZFS_AC_KERNEL_BLKG_TRYGET
548 ZFS_AC_KERNEL_BIO_BDEV_DISK
549 ZFS_AC_KERNEL_BDEV_SUBMIT_BIO_RETURNS_VOID
550 ZFS_AC_KERNEL_BLK_CGROUP_HEADER
551 ZFS_AC_KERNEL_BIO_ALLOC_4ARG