summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColeman Kane <[email protected]>2021-02-22 21:07:51 -0500
committerBrian Behlendorf <[email protected]>2021-03-05 12:57:46 -0800
commita0eb5a77a0f2f0f30469b951f2213c2cbf8f17c8 (patch)
tree212cffbc99d717e613dfdb36ef5c98f5c6c75582
parentfe77c4832031554c4663cb26ac4a9df7729dfda6 (diff)
Linux 5.12 compat: bio->bi_disk member moved
The struct bio member bi_disk was moved underneath a new member named bi_bdev. So all attempts to reference bio->bi_disk need to now become bio->bi_bdev->bd_disk. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Coleman Kane <[email protected]> Closes #11639
-rw-r--r--config/kernel-bio.m429
-rw-r--r--module/os/linux/zfs/vdev_disk.c4
-rw-r--r--module/os/linux/zfs/zvol_os.c4
3 files changed, 37 insertions, 0 deletions
diff --git a/config/kernel-bio.m4 b/config/kernel-bio.m4
index 0c533531d..d8692bd39 100644
--- a/config/kernel-bio.m4
+++ b/config/kernel-bio.m4
@@ -369,6 +369,33 @@ AC_DEFUN([ZFS_AC_KERNEL_BLKG_TRYGET], [
])
])
+dnl #
+dnl # Linux 5.12 API,
+dnl #
+dnl # The Linux 5.12 kernel updated struct bio to create a new bi_bdev member
+dnl # and bio->bi_disk was moved to bio->bi_bdev->bd_disk
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_BDEV_DISK], [
+ ZFS_LINUX_TEST_SRC([bio_bdev_disk], [
+ #include <linux/blk_types.h>
+ #include <linux/blkdev.h>
+ ],[
+ struct bio *b = NULL;
+ struct gendisk *d = b->bi_bdev->bd_disk;
+ blk_register_queue(d);
+ ])
+])
+
+AC_DEFUN([ZFS_AC_KERNEL_BIO_BDEV_DISK], [
+ AC_MSG_CHECKING([whether bio->bi_bdev->bd_disk exists])
+ ZFS_LINUX_TEST_RESULT([bio_bdev_disk], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_BIO_BDEV_DISK, 1, [bio->bi_bdev->bd_disk exists])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
+
AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [
ZFS_AC_KERNEL_SRC_REQ
ZFS_AC_KERNEL_SRC_BIO_OPS
@@ -379,6 +406,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [
ZFS_AC_KERNEL_SRC_BIO_SUBMIT_BIO
ZFS_AC_KERNEL_SRC_BIO_CURRENT_BIO_LIST
ZFS_AC_KERNEL_SRC_BLKG_TRYGET
+ ZFS_AC_KERNEL_SRC_BIO_BDEV_DISK
])
AC_DEFUN([ZFS_AC_KERNEL_BIO], [
@@ -400,4 +428,5 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO], [
ZFS_AC_KERNEL_BIO_SUBMIT_BIO
ZFS_AC_KERNEL_BIO_CURRENT_BIO_LIST
ZFS_AC_KERNEL_BLKG_TRYGET
+ ZFS_AC_KERNEL_BIO_BDEV_DISK
])
diff --git a/module/os/linux/zfs/vdev_disk.c b/module/os/linux/zfs/vdev_disk.c
index f38b87cfa..08c333134 100644
--- a/module/os/linux/zfs/vdev_disk.c
+++ b/module/os/linux/zfs/vdev_disk.c
@@ -499,7 +499,11 @@ vdev_blkg_tryget(struct blkcg_gq *blkg)
static inline void
vdev_bio_associate_blkg(struct bio *bio)
{
+#if defined(HAVE_BIO_BDEV_DISK)
+ struct request_queue *q = bio->bi_bdev->bd_disk->queue;
+#else
struct request_queue *q = bio->bi_disk->queue;
+#endif
ASSERT3P(q, !=, NULL);
ASSERT3P(bio->bi_blkg, ==, NULL);
diff --git a/module/os/linux/zfs/zvol_os.c b/module/os/linux/zfs/zvol_os.c
index cdc207670..6158d58dd 100644
--- a/module/os/linux/zfs/zvol_os.c
+++ b/module/os/linux/zfs/zvol_os.c
@@ -307,8 +307,12 @@ zvol_request(struct request_queue *q, struct bio *bio)
#endif
{
#ifdef HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS
+#if defined(HAVE_BIO_BDEV_DISK)
+ struct request_queue *q = bio->bi_bdev->bd_disk->queue;
+#else
struct request_queue *q = bio->bi_disk->queue;
#endif
+#endif
zvol_state_t *zv = q->queuedata;
fstrans_cookie_t cookie = spl_fstrans_mark();
uint64_t offset = BIO_BI_SECTOR(bio) << 9;