Linux 5.19 compat: bdev_start_io_acct() / bdev_end_io_acct()

As of the Linux 5.19 kernel the disk_*_io_acct() helper functions
have been replaced by the bdev_*_io_acct() functions.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #13515
This commit is contained in:
Brian Behlendorf 2022-05-27 21:31:03 +00:00
parent c2c2e7bb8b
commit d41e864181
2 changed files with 62 additions and 30 deletions

View File

@ -2,6 +2,19 @@ dnl #
dnl # Check for generic io accounting interface.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT], [
ZFS_LINUX_TEST_SRC([bdev_io_acct], [
#include <linux/blkdev.h>
], [
struct block_device *bdev = NULL;
struct bio *bio = NULL;
unsigned long passed_time = 0;
unsigned long start_time;
start_time = bdev_start_io_acct(bdev, bio_sectors(bio),
bio_op(bio), passed_time);
bdev_end_io_acct(bdev, bio_op(bio), start_time);
])
ZFS_LINUX_TEST_SRC([disk_io_acct], [
#include <linux/blkdev.h>
], [
@ -49,6 +62,19 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT], [
])
AC_DEFUN([ZFS_AC_KERNEL_GENERIC_IO_ACCT], [
dnl #
dnl # 5.19 API,
dnl #
dnl # disk_start_io_acct() and disk_end_io_acct() have been replaced by
dnl # bdev_start_io_acct() and bdev_end_io_acct().
dnl #
AC_MSG_CHECKING([whether generic bdev_*_io_acct() are available])
ZFS_LINUX_TEST_RESULT([bdev_io_acct], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BDEV_IO_ACCT, 1, [bdev_*_io_acct() available])
], [
AC_MSG_RESULT(no)
dnl #
dnl # 5.12 API,
dnl #
@ -110,3 +136,4 @@ AC_DEFUN([ZFS_AC_KERNEL_GENERIC_IO_ACCT], [
])
])
])
])

View File

@ -551,7 +551,10 @@ blk_generic_start_io_acct(struct request_queue *q __attribute__((unused)),
struct gendisk *disk __attribute__((unused)),
int rw __attribute__((unused)), struct bio *bio)
{
#if defined(HAVE_DISK_IO_ACCT)
#if defined(HAVE_BDEV_IO_ACCT)
return (bdev_start_io_acct(bio->bi_bdev, bio_sectors(bio),
bio_op(bio), jiffies));
#elif defined(HAVE_DISK_IO_ACCT)
return (disk_start_io_acct(disk, bio_sectors(bio), bio_op(bio)));
#elif defined(HAVE_BIO_IO_ACCT)
return (bio_start_io_acct(bio));
@ -574,7 +577,9 @@ blk_generic_end_io_acct(struct request_queue *q __attribute__((unused)),
struct gendisk *disk __attribute__((unused)),
int rw __attribute__((unused)), struct bio *bio, unsigned long start_time)
{
#if defined(HAVE_DISK_IO_ACCT)
#if defined(HAVE_BDEV_IO_ACCT)
bdev_end_io_acct(bio->bi_bdev, bio_op(bio), start_time);
#elif defined(HAVE_DISK_IO_ACCT)
disk_end_io_acct(disk, bio_op(bio), start_time);
#elif defined(HAVE_BIO_IO_ACCT)
bio_end_io_acct(bio, start_time);