From 435a451e5c5ecb7cc773ea68f7f05b1e0a9659c3 Mon Sep 17 00:00:00 2001 From: Coleman Kane Date: Thu, 2 Dec 2021 22:54:05 -0500 Subject: [PATCH] Linux 5.16: block_device_operations->submit_bio now returns void The return type for the submit_bio member of struct block_device_operations was changed to no longer return a value. Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf Signed-off-by: Coleman Kane Closes #12819 --- config/kernel-bio.m4 | 29 +++++++++++++++++++++++++++++ module/os/linux/zfs/zvol_os.c | 10 ++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/config/kernel-bio.m4 b/config/kernel-bio.m4 index aad4d31cf..1d715b2de 100644 --- a/config/kernel-bio.m4 +++ b/config/kernel-bio.m4 @@ -395,6 +395,33 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO_BDEV_DISK], [ ]) ]) +dnl # +dnl # Linux 5.16 API +dnl # +dnl # The Linux 5.16 API for submit_bio changed the return type to be +dnl # void instead of int +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_BDEV_SUBMIT_BIO_RETURNS_VOID], [ + ZFS_LINUX_TEST_SRC([bio_bdev_submit_bio_void], [ + #include + ],[ + struct block_device_operations *bdev = NULL; + __attribute__((unused)) void(*f)(struct bio *) = bdev->submit_bio; + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_BDEV_SUBMIT_BIO_RETURNS_VOID], [ + AC_MSG_CHECKING( + [whether block_device_operations->submit_bio() returns void]) + ZFS_LINUX_TEST_RESULT([bio_bdev_submit_bio_void], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BDEV_SUBMIT_BIO_RETURNS_VOID, 1, + [block_device_operations->submit_bio() returns void]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [ ZFS_AC_KERNEL_SRC_REQ ZFS_AC_KERNEL_SRC_BIO_OPS @@ -406,6 +433,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [ ZFS_AC_KERNEL_SRC_BIO_CURRENT_BIO_LIST ZFS_AC_KERNEL_SRC_BLKG_TRYGET ZFS_AC_KERNEL_SRC_BIO_BDEV_DISK + ZFS_AC_KERNEL_SRC_BDEV_SUBMIT_BIO_RETURNS_VOID ]) AC_DEFUN([ZFS_AC_KERNEL_BIO], [ @@ -428,4 +456,5 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO], [ ZFS_AC_KERNEL_BIO_CURRENT_BIO_LIST ZFS_AC_KERNEL_BLKG_TRYGET ZFS_AC_KERNEL_BIO_BDEV_DISK + ZFS_AC_KERNEL_BDEV_SUBMIT_BIO_RETURNS_VOID ]) diff --git a/module/os/linux/zfs/zvol_os.c b/module/os/linux/zfs/zvol_os.c index 75a31b38d..44caadd58 100644 --- a/module/os/linux/zfs/zvol_os.c +++ b/module/os/linux/zfs/zvol_os.c @@ -337,8 +337,13 @@ zvol_read_task(void *arg) } #ifdef HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS +#ifdef HAVE_BDEV_SUBMIT_BIO_RETURNS_VOID +static void +zvol_submit_bio(struct bio *bio) +#else static blk_qc_t zvol_submit_bio(struct bio *bio) +#endif #else static MAKE_REQUEST_FN_RET zvol_request(struct request_queue *q, struct bio *bio) @@ -479,8 +484,9 @@ zvol_request(struct request_queue *q, struct bio *bio) out: spl_fstrans_unmark(cookie); -#if defined(HAVE_MAKE_REQUEST_FN_RET_QC) || \ - defined(HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS) +#if (defined(HAVE_MAKE_REQUEST_FN_RET_QC) || \ + defined(HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS)) && \ + !defined(HAVE_BDEV_SUBMIT_BIO_RETURNS_VOID) return (BLK_QC_T_NONE); #endif }