Skip to content

Commit d939930

Browse files
ckanebehlendorf
authored andcommitted
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
1 parent 8e43fa1 commit d939930

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

config/kernel-bio.m4

+29
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,33 @@ AC_DEFUN([ZFS_AC_KERNEL_BLKG_TRYGET], [
369369
])
370370
])
371371

372+
dnl #
373+
dnl # Linux 5.12 API,
374+
dnl #
375+
dnl # The Linux 5.12 kernel updated struct bio to create a new bi_bdev member
376+
dnl # and bio->bi_disk was moved to bio->bi_bdev->bd_disk
377+
dnl #
378+
AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_BDEV_DISK], [
379+
ZFS_LINUX_TEST_SRC([bio_bdev_disk], [
380+
#include <linux/blk_types.h>
381+
#include <linux/blkdev.h>
382+
],[
383+
struct bio *b = NULL;
384+
struct gendisk *d = b->bi_bdev->bd_disk;
385+
blk_register_queue(d);
386+
])
387+
])
388+
389+
AC_DEFUN([ZFS_AC_KERNEL_BIO_BDEV_DISK], [
390+
AC_MSG_CHECKING([whether bio->bi_bdev->bd_disk exists])
391+
ZFS_LINUX_TEST_RESULT([bio_bdev_disk], [
392+
AC_MSG_RESULT(yes)
393+
AC_DEFINE(HAVE_BIO_BDEV_DISK, 1, [bio->bi_bdev->bd_disk exists])
394+
],[
395+
AC_MSG_RESULT(no)
396+
])
397+
])
398+
372399
AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [
373400
ZFS_AC_KERNEL_SRC_REQ
374401
ZFS_AC_KERNEL_SRC_BIO_OPS
@@ -379,6 +406,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [
379406
ZFS_AC_KERNEL_SRC_BIO_SUBMIT_BIO
380407
ZFS_AC_KERNEL_SRC_BIO_CURRENT_BIO_LIST
381408
ZFS_AC_KERNEL_SRC_BLKG_TRYGET
409+
ZFS_AC_KERNEL_SRC_BIO_BDEV_DISK
382410
])
383411

384412
AC_DEFUN([ZFS_AC_KERNEL_BIO], [
@@ -400,4 +428,5 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO], [
400428
ZFS_AC_KERNEL_BIO_SUBMIT_BIO
401429
ZFS_AC_KERNEL_BIO_CURRENT_BIO_LIST
402430
ZFS_AC_KERNEL_BLKG_TRYGET
431+
ZFS_AC_KERNEL_BIO_BDEV_DISK
403432
])

module/os/linux/zfs/vdev_disk.c

+4
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,11 @@ vdev_blkg_tryget(struct blkcg_gq *blkg)
494494
static inline void
495495
vdev_bio_associate_blkg(struct bio *bio)
496496
{
497+
#if defined(HAVE_BIO_BDEV_DISK)
498+
struct request_queue *q = bio->bi_bdev->bd_disk->queue;
499+
#else
497500
struct request_queue *q = bio->bi_disk->queue;
501+
#endif
498502

499503
ASSERT3P(q, !=, NULL);
500504
ASSERT3P(bio->bi_blkg, ==, NULL);

module/os/linux/zfs/zvol_os.c

+4
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,11 @@ zvol_request(struct request_queue *q, struct bio *bio)
307307
#endif
308308
{
309309
#ifdef HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS
310+
#if defined(HAVE_BIO_BDEV_DISK)
311+
struct request_queue *q = bio->bi_bdev->bd_disk->queue;
312+
#else
310313
struct request_queue *q = bio->bi_disk->queue;
314+
#endif
311315
#endif
312316
zvol_state_t *zv = q->queuedata;
313317
fstrans_cookie_t cookie = spl_fstrans_mark();

0 commit comments

Comments
 (0)