4 dnl # The bio_op() helper was introduced as a replacement for explicitly
5 dnl # checking the bio->bi_rw flags. The following checks are used to
6 dnl # detect if a specific operation is supported.
8 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_OPS], [
9 ZFS_LINUX_TEST_SRC([bio_set_op_attrs], [
10 #include <linux/bio.h>
12 struct bio *bio __attribute__ ((unused)) = NULL;
13 bio_set_op_attrs(bio, 0, 0);
17 AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_OP_ATTRS], [
18 AC_MSG_CHECKING([whether bio_set_op_attrs is available])
19 ZFS_LINUX_TEST_RESULT([bio_set_op_attrs], [
21 AC_DEFINE(HAVE_BIO_SET_OP_ATTRS, 1,
22 [bio_set_op_attrs is available])
31 dnl # The bio_set_dev() helper macro was introduced as part of the transition
32 dnl # to have struct gendisk in struct bio.
36 dnl # The bio_set_dev() helper macro was updated to internally depend on
37 dnl # bio_associate_blkg() symbol which is exported GPL-only.
39 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_SET_DEV], [
40 ZFS_LINUX_TEST_SRC([bio_set_dev], [
41 #include <linux/bio.h>
44 struct block_device *bdev = NULL;
45 struct bio *bio = NULL;
46 bio_set_dev(bio, bdev);
47 ], [], [ZFS_META_LICENSE])
53 dnl # bio_set_dev is no longer a helper macro and is now an inline function,
54 dnl # meaning that the function it calls internally can no longer be overridden
57 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_SET_DEV_MACRO], [
58 ZFS_LINUX_TEST_SRC([bio_set_dev_macro], [
59 #include <linux/bio.h>
65 ], [], [ZFS_META_LICENSE])
68 AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_DEV], [
69 AC_MSG_CHECKING([whether bio_set_dev() is GPL-only])
70 ZFS_LINUX_TEST_RESULT([bio_set_dev_license], [
74 AC_DEFINE(HAVE_BIO_SET_DEV_GPL_ONLY, 1,
75 [bio_set_dev() GPL-only])
78 AC_MSG_CHECKING([whether bio_set_dev() is a macro])
79 ZFS_LINUX_TEST_RESULT([bio_set_dev_macro], [
81 AC_DEFINE(HAVE_BIO_SET_DEV_MACRO, 1,
82 [bio_set_dev() is a macro])
89 dnl # 2.6.34 API change
90 dnl # current->bio_list
92 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_CURRENT_BIO_LIST], [
93 ZFS_LINUX_TEST_SRC([current_bio_list], [
94 #include <linux/sched.h>
96 current->bio_list = (struct bio_list *) NULL;
100 AC_DEFUN([ZFS_AC_KERNEL_BIO_CURRENT_BIO_LIST], [
101 AC_MSG_CHECKING([whether current->bio_list exists])
102 ZFS_LINUX_TEST_RESULT([current_bio_list], [
105 ZFS_LINUX_TEST_ERROR([bio_list])
112 dnl # The Linux 5.5 kernel updated percpu_ref_tryget() which is inlined by
113 dnl # blkg_tryget() to use rcu_read_lock() instead of rcu_read_lock_sched().
114 dnl # As a side effect the function was converted to GPL-only.
116 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKG_TRYGET], [
117 ZFS_LINUX_TEST_SRC([blkg_tryget], [
118 #include <linux/blk-cgroup.h>
119 #include <linux/bio.h>
120 #include <linux/fs.h>
122 struct blkcg_gq blkg __attribute__ ((unused)) = {};
123 bool rc __attribute__ ((unused));
124 rc = blkg_tryget(&blkg);
125 ], [], [ZFS_META_LICENSE])
128 AC_DEFUN([ZFS_AC_KERNEL_BLKG_TRYGET], [
129 AC_MSG_CHECKING([whether blkg_tryget() is available])
130 ZFS_LINUX_TEST_RESULT([blkg_tryget], [
132 AC_DEFINE(HAVE_BLKG_TRYGET, 1, [blkg_tryget() is available])
134 AC_MSG_CHECKING([whether blkg_tryget() is GPL-only])
135 ZFS_LINUX_TEST_RESULT([blkg_tryget_license], [
139 AC_DEFINE(HAVE_BLKG_TRYGET_GPL_ONLY, 1,
140 [blkg_tryget() GPL-only])
148 dnl # Linux 5.12 API,
150 dnl # The Linux 5.12 kernel updated struct bio to create a new bi_bdev member
151 dnl # and bio->bi_disk was moved to bio->bi_bdev->bd_disk
153 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_BDEV_DISK], [
154 ZFS_LINUX_TEST_SRC([bio_bdev_disk], [
155 #include <linux/blk_types.h>
156 #include <linux/blkdev.h>
158 struct bio *b = NULL;
159 struct gendisk *d = b->bi_bdev->bd_disk;
160 blk_register_queue(d);
164 AC_DEFUN([ZFS_AC_KERNEL_BIO_BDEV_DISK], [
165 AC_MSG_CHECKING([whether bio->bi_bdev->bd_disk exists])
166 ZFS_LINUX_TEST_RESULT([bio_bdev_disk], [
168 AC_DEFINE(HAVE_BIO_BDEV_DISK, 1, [bio->bi_bdev->bd_disk exists])
177 dnl # The Linux 5.16 API for submit_bio changed the return type to be
178 dnl # void instead of int
180 AC_DEFUN([ZFS_AC_KERNEL_SRC_BDEV_SUBMIT_BIO_RETURNS_VOID], [
181 ZFS_LINUX_TEST_SRC([bio_bdev_submit_bio_void], [
182 #include <linux/blkdev.h>
184 struct block_device_operations *bdev = NULL;
185 __attribute__((unused)) void(*f)(struct bio *) = bdev->submit_bio;
189 AC_DEFUN([ZFS_AC_KERNEL_BDEV_SUBMIT_BIO_RETURNS_VOID], [
191 [whether block_device_operations->submit_bio() returns void])
192 ZFS_LINUX_TEST_RESULT([bio_bdev_submit_bio_void], [
194 AC_DEFINE(HAVE_BDEV_SUBMIT_BIO_RETURNS_VOID, 1,
195 [block_device_operations->submit_bio() returns void])
204 dnl # In 07888c665b405b1cd3577ddebfeb74f4717a84c4 ("block: pass a block_device and opf to bio_alloc")
205 dnl # bio_alloc(gfp_t gfp_mask, unsigned short nr_iovecs)
207 dnl # bio_alloc(struct block_device *bdev, unsigned short nr_vecs, unsigned int opf, gfp_t gfp_mask)
209 dnl # > NULL/0 can be passed, both for the
210 dnl # > passthrough case on a raw request_queue and to temporarily avoid
211 dnl # > refactoring some nasty code.
213 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_ALLOC_4ARG], [
214 ZFS_LINUX_TEST_SRC([bio_alloc_4arg], [
215 #include <linux/bio.h>
218 unsigned short nr_iovecs = 0;
219 struct block_device *bdev = NULL;
220 unsigned int opf = 0;
222 struct bio *__attribute__((unused)) allocated = bio_alloc(bdev, nr_iovecs, opf, gfp_mask);
226 AC_DEFUN([ZFS_AC_KERNEL_BIO_ALLOC_4ARG], [
227 AC_MSG_CHECKING([whether bio_alloc() wants 4 args])
228 ZFS_LINUX_TEST_RESULT([bio_alloc_4arg],[
230 AC_DEFINE([HAVE_BIO_ALLOC_4ARG], 1, [bio_alloc() takes 4 arguments])
236 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [
237 ZFS_AC_KERNEL_SRC_BIO_OPS
238 ZFS_AC_KERNEL_SRC_BIO_SET_DEV
239 ZFS_AC_KERNEL_SRC_BIO_CURRENT_BIO_LIST
240 ZFS_AC_KERNEL_SRC_BLKG_TRYGET
241 ZFS_AC_KERNEL_SRC_BIO_BDEV_DISK
242 ZFS_AC_KERNEL_SRC_BDEV_SUBMIT_BIO_RETURNS_VOID
243 ZFS_AC_KERNEL_SRC_BIO_SET_DEV_MACRO
244 ZFS_AC_KERNEL_SRC_BIO_ALLOC_4ARG
247 AC_DEFUN([ZFS_AC_KERNEL_BIO], [
248 ZFS_AC_KERNEL_BIO_SET_OP_ATTRS
249 ZFS_AC_KERNEL_BIO_SET_DEV
250 ZFS_AC_KERNEL_BIO_CURRENT_BIO_LIST
251 ZFS_AC_KERNEL_BLKG_TRYGET
252 ZFS_AC_KERNEL_BIO_BDEV_DISK
253 ZFS_AC_KERNEL_BDEV_SUBMIT_BIO_RETURNS_VOID
254 ZFS_AC_KERNEL_BIO_ALLOC_4ARG