1dnl # 2dnl # Linux 4.8 API, 3dnl # 4dnl # The bio_op() helper was introduced as a replacement for explicitly 5dnl # checking the bio->bi_rw flags. The following checks are used to 6dnl # detect if a specific operation is supported. 7dnl # 8AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_OPS], [ 9 ZFS_LINUX_TEST_SRC([bio_set_op_attrs], [ 10 #include <linux/bio.h> 11 ],[ 12 struct bio *bio __attribute__ ((unused)) = NULL; 13 bio_set_op_attrs(bio, 0, 0); 14 ]) 15]) 16 17AC_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], [ 20 AC_MSG_RESULT(yes) 21 AC_DEFINE(HAVE_BIO_SET_OP_ATTRS, 1, 22 [bio_set_op_attrs is available]) 23 ],[ 24 AC_MSG_RESULT(no) 25 ]) 26]) 27 28dnl # 29dnl # Linux 4.14 API, 30dnl # 31dnl # The bio_set_dev() helper macro was introduced as part of the transition 32dnl # to have struct gendisk in struct bio. 33dnl # 34dnl # Linux 5.0 API, 35dnl # 36dnl # The bio_set_dev() helper macro was updated to internally depend on 37dnl # bio_associate_blkg() symbol which is exported GPL-only. 38dnl # 39AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_SET_DEV], [ 40 ZFS_LINUX_TEST_SRC([bio_set_dev], [ 41 #include <linux/bio.h> 42 #include <linux/fs.h> 43 ],[ 44 struct block_device *bdev = NULL; 45 struct bio *bio = NULL; 46 bio_set_dev(bio, bdev); 47 ], [], [ZFS_META_LICENSE]) 48]) 49 50dnl # 51dnl # Linux 5.16 API 52dnl # 53dnl # bio_set_dev is no longer a helper macro and is now an inline function, 54dnl # meaning that the function it calls internally can no longer be overridden 55dnl # by our code 56dnl # 57AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_SET_DEV_MACRO], [ 58 ZFS_LINUX_TEST_SRC([bio_set_dev_macro], [ 59 #include <linux/bio.h> 60 #include <linux/fs.h> 61 ],[ 62 #ifndef bio_set_dev 63 #error Not a macro 64 #endif 65 ], [], [ZFS_META_LICENSE]) 66]) 67 68AC_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], [ 71 AC_MSG_RESULT(no) 72 ],[ 73 AC_MSG_RESULT(yes) 74 AC_DEFINE(HAVE_BIO_SET_DEV_GPL_ONLY, 1, 75 [bio_set_dev() GPL-only]) 76 ]) 77 78 AC_MSG_CHECKING([whether bio_set_dev() is a macro]) 79 ZFS_LINUX_TEST_RESULT([bio_set_dev_macro], [ 80 AC_MSG_RESULT(yes) 81 AC_DEFINE(HAVE_BIO_SET_DEV_MACRO, 1, 82 [bio_set_dev() is a macro]) 83 ],[ 84 AC_MSG_RESULT(no) 85 ]) 86]) 87 88dnl # 89dnl # 2.6.34 API change 90dnl # current->bio_list 91dnl # 92AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_CURRENT_BIO_LIST], [ 93 ZFS_LINUX_TEST_SRC([current_bio_list], [ 94 #include <linux/sched.h> 95 ], [ 96 current->bio_list = (struct bio_list *) NULL; 97 ]) 98]) 99 100AC_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], [ 103 AC_MSG_RESULT(yes) 104 ],[ 105 ZFS_LINUX_TEST_ERROR([bio_list]) 106 ]) 107]) 108 109dnl # 110dnl # Linux 5.5 API, 111dnl # 112dnl # The Linux 5.5 kernel updated percpu_ref_tryget() which is inlined by 113dnl # blkg_tryget() to use rcu_read_lock() instead of rcu_read_lock_sched(). 114dnl # As a side effect the function was converted to GPL-only. 115dnl # 116AC_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> 121 ],[ 122 struct blkcg_gq blkg __attribute__ ((unused)) = {}; 123 bool rc __attribute__ ((unused)); 124 rc = blkg_tryget(&blkg); 125 ], [], [ZFS_META_LICENSE]) 126]) 127 128AC_DEFUN([ZFS_AC_KERNEL_BLKG_TRYGET], [ 129 AC_MSG_CHECKING([whether blkg_tryget() is available]) 130 ZFS_LINUX_TEST_RESULT([blkg_tryget], [ 131 AC_MSG_RESULT(yes) 132 AC_DEFINE(HAVE_BLKG_TRYGET, 1, [blkg_tryget() is available]) 133 134 AC_MSG_CHECKING([whether blkg_tryget() is GPL-only]) 135 ZFS_LINUX_TEST_RESULT([blkg_tryget_license], [ 136 AC_MSG_RESULT(no) 137 ],[ 138 AC_MSG_RESULT(yes) 139 AC_DEFINE(HAVE_BLKG_TRYGET_GPL_ONLY, 1, 140 [blkg_tryget() GPL-only]) 141 ]) 142 ],[ 143 AC_MSG_RESULT(no) 144 ]) 145]) 146 147dnl # 148dnl # Linux 5.12 API, 149dnl # 150dnl # The Linux 5.12 kernel updated struct bio to create a new bi_bdev member 151dnl # and bio->bi_disk was moved to bio->bi_bdev->bd_disk 152dnl # 153AC_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> 157 ],[ 158 struct bio *b = NULL; 159 struct gendisk *d = b->bi_bdev->bd_disk; 160 blk_register_queue(d); 161 ]) 162]) 163 164AC_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], [ 167 AC_MSG_RESULT(yes) 168 AC_DEFINE(HAVE_BIO_BDEV_DISK, 1, [bio->bi_bdev->bd_disk exists]) 169 ],[ 170 AC_MSG_RESULT(no) 171 ]) 172]) 173 174dnl # 175dnl # Linux 5.16 API 176dnl # 177dnl # The Linux 5.16 API for submit_bio changed the return type to be 178dnl # void instead of int 179dnl # 180AC_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> 183 ],[ 184 struct block_device_operations *bdev = NULL; 185 __attribute__((unused)) void(*f)(struct bio *) = bdev->submit_bio; 186 ]) 187]) 188 189AC_DEFUN([ZFS_AC_KERNEL_BDEV_SUBMIT_BIO_RETURNS_VOID], [ 190 AC_MSG_CHECKING( 191 [whether block_device_operations->submit_bio() returns void]) 192 ZFS_LINUX_TEST_RESULT([bio_bdev_submit_bio_void], [ 193 AC_MSG_RESULT(yes) 194 AC_DEFINE(HAVE_BDEV_SUBMIT_BIO_RETURNS_VOID, 1, 195 [block_device_operations->submit_bio() returns void]) 196 ],[ 197 AC_MSG_RESULT(no) 198 ]) 199]) 200 201dnl # 202dnl # Linux 5.18 API 203dnl # 204dnl # In 07888c665b405b1cd3577ddebfeb74f4717a84c4 ("block: pass a block_device and opf to bio_alloc") 205dnl # bio_alloc(gfp_t gfp_mask, unsigned short nr_iovecs) 206dnl # became 207dnl # bio_alloc(struct block_device *bdev, unsigned short nr_vecs, unsigned int opf, gfp_t gfp_mask) 208dnl # however 209dnl # > NULL/0 can be passed, both for the 210dnl # > passthrough case on a raw request_queue and to temporarily avoid 211dnl # > refactoring some nasty code. 212dnl # 213AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_ALLOC_4ARG], [ 214 ZFS_LINUX_TEST_SRC([bio_alloc_4arg], [ 215 #include <linux/bio.h> 216 ],[ 217 gfp_t gfp_mask = 0; 218 unsigned short nr_iovecs = 0; 219 struct block_device *bdev = NULL; 220 unsigned int opf = 0; 221 222 struct bio *__attribute__((unused)) allocated = bio_alloc(bdev, nr_iovecs, opf, gfp_mask); 223 ]) 224]) 225 226AC_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],[ 229 AC_MSG_RESULT(yes) 230 AC_DEFINE([HAVE_BIO_ALLOC_4ARG], 1, [bio_alloc() takes 4 arguments]) 231 ],[ 232 AC_MSG_RESULT(no) 233 ]) 234]) 235 236AC_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 245]) 246 247AC_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 255]) 256