From 1e767532f20030385897fea2cf84fb59b69bd13c Mon Sep 17 00:00:00 2001 From: Coleman Kane Date: Fri, 3 Dec 2021 22:00:10 -0500 Subject: [PATCH] Linux 5.16: The blk-cgroup.h header is where struct blkcg_gq is defined The definition of struct blkcg_gq was moved into blk-cgroup.h, which is a header that's been in Linux since 2015. This is used by vdev_blkg_tryget() in module/os/linux/zfs/vdev_disk.c. Since the kernel for CentOS 7 and similar-generation releases doesn't have this header, its inclusion is guarded by a configure test. Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf Signed-off-by: Coleman Kane Closes #12819 --- config/kernel-bio.m4 | 27 +++++++++++++++++++++++++++ module/os/linux/zfs/vdev_disk.c | 3 +++ 2 files changed, 30 insertions(+) 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;