xref: /freebsd/sys/contrib/openzfs/config/kernel-generic_io_acct.m4 (revision 7a7741af18d6c8a804cc643cb7ecda9d730c6aa6)
1dnl #
2dnl # Check for generic io accounting interface.
3dnl #
4AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT], [
5	ZFS_LINUX_TEST_SRC([bdev_io_acct_63], [
6		#include <linux/blkdev.h>
7	], [
8		struct block_device *bdev = NULL;
9		struct bio *bio = NULL;
10		unsigned long passed_time = 0;
11		unsigned long start_time;
12
13		start_time = bdev_start_io_acct(bdev, bio_op(bio),
14		    passed_time);
15		bdev_end_io_acct(bdev, bio_op(bio), bio_sectors(bio), start_time);
16	])
17
18	ZFS_LINUX_TEST_SRC([bdev_io_acct_old], [
19		#include <linux/blkdev.h>
20	], [
21		struct block_device *bdev = NULL;
22		struct bio *bio = NULL;
23		unsigned long passed_time = 0;
24		unsigned long start_time;
25
26		start_time = bdev_start_io_acct(bdev, bio_sectors(bio),
27		    bio_op(bio), passed_time);
28		bdev_end_io_acct(bdev, bio_op(bio), start_time);
29	])
30
31	ZFS_LINUX_TEST_SRC([disk_io_acct], [
32		#include <linux/blkdev.h>
33	], [
34		struct gendisk *disk = NULL;
35		struct bio *bio = NULL;
36		unsigned long start_time;
37
38		start_time = disk_start_io_acct(disk, bio_sectors(bio), bio_op(bio));
39		disk_end_io_acct(disk, bio_op(bio), start_time);
40	])
41
42	ZFS_LINUX_TEST_SRC([bio_io_acct], [
43		#include <linux/blkdev.h>
44	], [
45		struct bio *bio = NULL;
46		unsigned long start_time;
47
48		start_time = bio_start_io_acct(bio);
49		bio_end_io_acct(bio, start_time);
50	])
51
52	ZFS_LINUX_TEST_SRC([generic_acct_4args], [
53		#include <linux/bio.h>
54
55		void (*generic_start_io_acct_f)(struct request_queue *, int,
56		    unsigned long, struct hd_struct *) = &generic_start_io_acct;
57		void (*generic_end_io_acct_f)(struct request_queue *, int,
58		    struct hd_struct *, unsigned long) = &generic_end_io_acct;
59	], [
60		generic_start_io_acct(NULL, 0, 0, NULL);
61		generic_end_io_acct(NULL, 0, NULL, 0);
62	])
63])
64
65AC_DEFUN([ZFS_AC_KERNEL_GENERIC_IO_ACCT], [
66	dnl #
67	dnl # Linux 6.3, and then backports thereof, changed
68	dnl # the signatures on bdev_start_io_acct/bdev_end_io_acct
69	dnl #
70	AC_MSG_CHECKING([whether 6.3+ bdev_*_io_acct() are available])
71	ZFS_LINUX_TEST_RESULT([bdev_io_acct_63], [
72		AC_MSG_RESULT(yes)
73		AC_DEFINE(HAVE_BDEV_IO_ACCT_63, 1, [bdev_*_io_acct() available])
74	], [
75		AC_MSG_RESULT(no)
76
77		dnl #
78		dnl # 5.19 API,
79		dnl #
80		dnl # disk_start_io_acct() and disk_end_io_acct() have been replaced by
81		dnl # bdev_start_io_acct() and bdev_end_io_acct().
82		dnl #
83		AC_MSG_CHECKING([whether pre-6.3 bdev_*_io_acct() are available])
84		ZFS_LINUX_TEST_RESULT([bdev_io_acct_old], [
85			AC_MSG_RESULT(yes)
86			AC_DEFINE(HAVE_BDEV_IO_ACCT_OLD, 1, [bdev_*_io_acct() available])
87		], [
88			AC_MSG_RESULT(no)
89			dnl #
90			dnl # 5.12 API,
91			dnl #
92			dnl # bio_start_io_acct() and bio_end_io_acct() became GPL-exported
93			dnl # so use disk_start_io_acct() and disk_end_io_acct() instead
94			dnl #
95			AC_MSG_CHECKING([whether generic disk_*_io_acct() are available])
96			ZFS_LINUX_TEST_RESULT([disk_io_acct], [
97				AC_MSG_RESULT(yes)
98				AC_DEFINE(HAVE_DISK_IO_ACCT, 1, [disk_*_io_acct() available])
99			], [
100				AC_MSG_RESULT(no)
101
102				dnl #
103				dnl # 5.7 API,
104				dnl #
105				dnl # Added bio_start_io_acct() and bio_end_io_acct() helpers.
106				dnl #
107				AC_MSG_CHECKING([whether generic bio_*_io_acct() are available])
108				ZFS_LINUX_TEST_RESULT([bio_io_acct], [
109					AC_MSG_RESULT(yes)
110					AC_DEFINE(HAVE_BIO_IO_ACCT, 1, [bio_*_io_acct() available])
111				], [
112					AC_MSG_RESULT(no)
113
114					dnl #
115					dnl # 4.14 API,
116					dnl #
117					dnl # generic_start_io_acct/generic_end_io_acct now require
118					dnl # request_queue to be provided. No functional changes,
119					dnl # but preparation for inflight accounting.
120					dnl #
121					AC_MSG_CHECKING([whether generic_*_io_acct wants 4 args])
122					ZFS_LINUX_TEST_RESULT_SYMBOL([generic_acct_4args],
123					    [generic_start_io_acct], [block/bio.c], [
124						AC_MSG_RESULT(yes)
125						AC_DEFINE(HAVE_GENERIC_IO_ACCT_4ARG, 1,
126						    [generic_*_io_acct() 4 arg available])
127					], [
128						AC_MSG_RESULT(no)
129					])
130				])
131			])
132		])
133	])
134])
135