diff --git a/config/kernel-bio.m4 b/config/kernel-bio.m4 index df5e9de3be..d088d7023c 100644 --- a/config/kernel-bio.m4 +++ b/config/kernel-bio.m4 @@ -449,6 +449,31 @@ AC_DEFUN([ZFS_AC_KERNEL_BDEV_SUBMIT_BIO_RETURNS_VOID], [ ]) ]) +dnl # +dnl # Linux 5.16 API +dnl # +dnl # The Linux 5.16 API moved struct blkcg_gq into linux/blk-cgroup.h, which +dnl # has been around since 2015. This test looks for the presence of that +dnl # header, so that it can be conditionally included where it exists, but +dnl # still be backward compatible with kernels that pre-date its introduction. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_CGROUP_HEADER], [ + ZFS_LINUX_TEST_SRC([blk_cgroup_header], [ + #include + ], []) +]) + +AC_DEFUN([ZFS_AC_KERNEL_BLK_CGROUP_HEADER], [ + AC_MSG_CHECKING([for existence of linux/blk-cgroup.h]) + ZFS_LINUX_TEST_RESULT([blk_cgroup_header],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_LINUX_BLK_CGROUP_HEADER, 1, + [linux/blk-cgroup.h exists]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [ ZFS_AC_KERNEL_SRC_REQ ZFS_AC_KERNEL_SRC_BIO_OPS @@ -462,6 +487,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [ ZFS_AC_KERNEL_SRC_BIO_BDEV_DISK ZFS_AC_KERNEL_SRC_BDEV_SUBMIT_BIO_RETURNS_VOID ZFS_AC_KERNEL_SRC_BIO_SET_DEV_MACRO + ZFS_AC_KERNEL_SRC_BLK_CGROUP_HEADER ]) AC_DEFUN([ZFS_AC_KERNEL_BIO], [ @@ -485,4 +511,5 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO], [ ZFS_AC_KERNEL_BLKG_TRYGET ZFS_AC_KERNEL_BIO_BDEV_DISK ZFS_AC_KERNEL_BDEV_SUBMIT_BIO_RETURNS_VOID + ZFS_AC_KERNEL_BLK_CGROUP_HEADER ]) diff --git a/module/os/linux/zfs/vdev_disk.c b/module/os/linux/zfs/vdev_disk.c index a7a1b0535b..46b459f5c8 100644 --- a/module/os/linux/zfs/vdev_disk.c +++ b/module/os/linux/zfs/vdev_disk.c @@ -37,6 +37,9 @@ #include #include #include +#ifdef HAVE_LINUX_BLK_CGROUP_HEADER +#include +#endif typedef struct vdev_disk { struct block_device *vd_bdev;