From d939930fccbf7382c3525bba59cc04e9afc28fdc Mon Sep 17 00:00:00 2001 From: Coleman Kane Date: Mon, 22 Feb 2021 21:07:51 -0500 Subject: [PATCH] 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 Signed-off-by: Coleman Kane Closes #11639 --- config/kernel-bio.m4 | 29 +++++++++++++++++++++++++++++ module/os/linux/zfs/vdev_disk.c | 4 ++++ module/os/linux/zfs/zvol_os.c | 4 ++++ 3 files changed, 37 insertions(+) diff --git a/config/kernel-bio.m4 b/config/kernel-bio.m4 index 0c533531dceb..d8692bd39999 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 + #include + ],[ + 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 b373f2c2e83c..ff71ef4cd065 100644 --- a/module/os/linux/zfs/vdev_disk.c +++ b/module/os/linux/zfs/vdev_disk.c @@ -494,7 +494,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 0caf31307718..0d62b1490702 100644 --- a/module/os/linux/zfs/zvol_os.c +++ b/module/os/linux/zfs/zvol_os.c @@ -307,7 +307,11 @@ 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();