Skip to content

Commit 6c19899

Browse files
ckanebehlendorf
authored andcommitted
Linux 5.12 compat: replace bio_*_io_acct with disk_*_io_acct
The bio_*_acct functions became GPL exports, which causes the kernel modules to refuse to compile. This replaces code with alternate function calls to the disk_*_io_acct interfaces, which are not GPL exports. This change was added in kernel commit 99dfc43ecbf67f12a06512918aaba61d55863efc. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Coleman Kane <[email protected]> Closes #11639
1 parent a0eb5a7 commit 6c19899

File tree

2 files changed

+53
-24
lines changed

2 files changed

+53
-24
lines changed

config/kernel-generic_io_acct.m4

+47-22
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ dnl #
22
dnl # Check for generic io accounting interface.
33
dnl #
44
AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT], [
5+
ZFS_LINUX_TEST_SRC([disk_io_acct], [
6+
#include <linux/blkdev.h>
7+
], [
8+
struct gendisk *disk = NULL;
9+
struct bio *bio = NULL;
10+
unsigned long start_time;
11+
12+
start_time = disk_start_io_acct(disk, bio_sectors(bio), bio_op(bio));
13+
disk_end_io_acct(disk, bio_op(bio), start_time);
14+
])
15+
516
ZFS_LINUX_TEST_SRC([bio_io_acct], [
617
#include <linux/blkdev.h>
718
], [
@@ -39,48 +50,62 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT], [
3950

4051
AC_DEFUN([ZFS_AC_KERNEL_GENERIC_IO_ACCT], [
4152
dnl #
42-
dnl # 5.7 API,
53+
dnl # 5.12 API,
4354
dnl #
44-
dnl # Added bio_start_io_acct() and bio_end_io_acct() helpers.
55+
dnl # bio_start_io_acct() and bio_end_io_acct() became GPL-exported
56+
dnl # so use disk_start_io_acct() and disk_end_io_acct() instead
4557
dnl #
46-
AC_MSG_CHECKING([whether generic bio_*_io_acct() are available])
47-
ZFS_LINUX_TEST_RESULT([bio_io_acct], [
58+
AC_MSG_CHECKING([whether generic disk_*_io_acct() are available])
59+
ZFS_LINUX_TEST_RESULT([disk_io_acct], [
4860
AC_MSG_RESULT(yes)
49-
AC_DEFINE(HAVE_BIO_IO_ACCT, 1, [bio_*_io_acct() available])
61+
AC_DEFINE(HAVE_DISK_IO_ACCT, 1, [disk_*_io_acct() available])
5062
], [
5163
AC_MSG_RESULT(no)
5264
5365
dnl #
54-
dnl # 4.14 API,
66+
dnl # 5.7 API,
5567
dnl #
56-
dnl # generic_start_io_acct/generic_end_io_acct now require
57-
dnl # request_queue to be provided. No functional changes,
58-
dnl # but preparation for inflight accounting.
68+
dnl # Added bio_start_io_acct() and bio_end_io_acct() helpers.
5969
dnl #
60-
AC_MSG_CHECKING([whether generic_*_io_acct wants 4 args])
61-
ZFS_LINUX_TEST_RESULT_SYMBOL([generic_acct_4args],
62-
[generic_start_io_acct], [block/bio.c], [
70+
AC_MSG_CHECKING([whether generic bio_*_io_acct() are available])
71+
ZFS_LINUX_TEST_RESULT([bio_io_acct], [
6372
AC_MSG_RESULT(yes)
64-
AC_DEFINE(HAVE_GENERIC_IO_ACCT_4ARG, 1,
65-
[generic_*_io_acct() 4 arg available])
73+
AC_DEFINE(HAVE_BIO_IO_ACCT, 1, [bio_*_io_acct() available])
6674
], [
6775
AC_MSG_RESULT(no)
6876
6977
dnl #
70-
dnl # 3.19 API addition
78+
dnl # 4.14 API,
7179
dnl #
72-
dnl # torvalds/linux@394ffa50 allows us to increment
73-
dnl # iostat counters without generic_make_request().
80+
dnl # generic_start_io_acct/generic_end_io_acct now require
81+
dnl # request_queue to be provided. No functional changes,
82+
dnl # but preparation for inflight accounting.
7483
dnl #
75-
AC_MSG_CHECKING(
76-
[whether generic_*_io_acct wants 3 args])
77-
ZFS_LINUX_TEST_RESULT_SYMBOL([generic_acct_3args],
84+
AC_MSG_CHECKING([whether generic_*_io_acct wants 4 args])
85+
ZFS_LINUX_TEST_RESULT_SYMBOL([generic_acct_4args],
7886
[generic_start_io_acct], [block/bio.c], [
7987
AC_MSG_RESULT(yes)
80-
AC_DEFINE(HAVE_GENERIC_IO_ACCT_3ARG, 1,
81-
[generic_*_io_acct() 3 arg available])
88+
AC_DEFINE(HAVE_GENERIC_IO_ACCT_4ARG, 1,
89+
[generic_*_io_acct() 4 arg available])
8290
], [
8391
AC_MSG_RESULT(no)
92+
93+
dnl #
94+
dnl # 3.19 API addition
95+
dnl #
96+
dnl # torvalds/linux@394ffa50 allows us to increment
97+
dnl # iostat counters without generic_make_request().
98+
dnl #
99+
AC_MSG_CHECKING(
100+
[whether generic_*_io_acct wants 3 args])
101+
ZFS_LINUX_TEST_RESULT_SYMBOL([generic_acct_3args],
102+
[generic_start_io_acct], [block/bio.c], [
103+
AC_MSG_RESULT(yes)
104+
AC_DEFINE(HAVE_GENERIC_IO_ACCT_3ARG, 1,
105+
[generic_*_io_acct() 3 arg available])
106+
], [
107+
AC_MSG_RESULT(no)
108+
])
84109
])
85110
])
86111
])

include/os/linux/kernel/linux/blkdev_compat.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,9 @@ blk_generic_start_io_acct(struct request_queue *q __attribute__((unused)),
520520
struct gendisk *disk __attribute__((unused)),
521521
int rw __attribute__((unused)), struct bio *bio)
522522
{
523-
#if defined(HAVE_BIO_IO_ACCT)
523+
#if defined(HAVE_DISK_IO_ACCT)
524+
return (disk_start_io_acct(disk, bio_sectors(bio), bio_op(bio)));
525+
#elif defined(HAVE_BIO_IO_ACCT)
524526
return (bio_start_io_acct(bio));
525527
#elif defined(HAVE_GENERIC_IO_ACCT_3ARG)
526528
unsigned long start_time = jiffies;
@@ -541,7 +543,9 @@ blk_generic_end_io_acct(struct request_queue *q __attribute__((unused)),
541543
struct gendisk *disk __attribute__((unused)),
542544
int rw __attribute__((unused)), struct bio *bio, unsigned long start_time)
543545
{
544-
#if defined(HAVE_BIO_IO_ACCT)
546+
#if defined(HAVE_DISK_IO_ACCT)
547+
disk_end_io_acct(disk, bio_op(bio), start_time);
548+
#elif defined(HAVE_BIO_IO_ACCT)
545549
bio_end_io_acct(bio, start_time);
546550
#elif defined(HAVE_GENERIC_IO_ACCT_3ARG)
547551
generic_end_io_acct(rw, &disk->part0, start_time);

0 commit comments

Comments
 (0)