xref: /freebsd/sys/contrib/openzfs/config/kernel-generic_io_acct.m4 (revision c66ec88fed842fbaad62c30d510644ceb7bd2d71)
1dnl #
2dnl # Check for generic io accounting interface.
3dnl #
4AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT], [
5	ZFS_LINUX_TEST_SRC([bio_io_acct], [
6		#include <linux/blkdev.h>
7	], [
8		struct bio *bio = NULL;
9		unsigned long start_time;
10
11		start_time = bio_start_io_acct(bio);
12		bio_end_io_acct(bio, start_time);
13	])
14
15	ZFS_LINUX_TEST_SRC([generic_acct_3args], [
16		#include <linux/bio.h>
17
18		void (*generic_start_io_acct_f)(int, unsigned long,
19		    struct hd_struct *) = &generic_start_io_acct;
20		void (*generic_end_io_acct_f)(int, struct hd_struct *,
21		    unsigned long) = &generic_end_io_acct;
22	], [
23		generic_start_io_acct(0, 0, NULL);
24		generic_end_io_acct(0, NULL, 0);
25	])
26
27	ZFS_LINUX_TEST_SRC([generic_acct_4args], [
28		#include <linux/bio.h>
29
30		void (*generic_start_io_acct_f)(struct request_queue *, int,
31		    unsigned long, struct hd_struct *) = &generic_start_io_acct;
32		void (*generic_end_io_acct_f)(struct request_queue *, int,
33		    struct hd_struct *, unsigned long) = &generic_end_io_acct;
34	], [
35		generic_start_io_acct(NULL, 0, 0, NULL);
36		generic_end_io_acct(NULL, 0, NULL, 0);
37	])
38])
39
40AC_DEFUN([ZFS_AC_KERNEL_GENERIC_IO_ACCT], [
41	dnl #
42	dnl # 5.7 API,
43	dnl #
44	dnl # Added bio_start_io_acct() and bio_end_io_acct() helpers.
45	dnl #
46	AC_MSG_CHECKING([whether generic bio_*_io_acct() are available])
47	ZFS_LINUX_TEST_RESULT([bio_io_acct], [
48		AC_MSG_RESULT(yes)
49		AC_DEFINE(HAVE_BIO_IO_ACCT, 1, [bio_*_io_acct() available])
50	], [
51		AC_MSG_RESULT(no)
52
53		dnl #
54		dnl # 4.14 API,
55		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.
59		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], [
63			AC_MSG_RESULT(yes)
64			AC_DEFINE(HAVE_GENERIC_IO_ACCT_4ARG, 1,
65			    [generic_*_io_acct() 4 arg available])
66		], [
67			AC_MSG_RESULT(no)
68
69			dnl #
70			dnl # 3.19 API addition
71			dnl #
72			dnl # torvalds/linux@394ffa50 allows us to increment
73			dnl # iostat counters without generic_make_request().
74			dnl #
75			AC_MSG_CHECKING(
76			    [whether generic_*_io_acct wants 3 args])
77			ZFS_LINUX_TEST_RESULT_SYMBOL([generic_acct_3args],
78			    [generic_start_io_acct], [block/bio.c], [
79				AC_MSG_RESULT(yes)
80				AC_DEFINE(HAVE_GENERIC_IO_ACCT_3ARG, 1,
81				    [generic_*_io_acct() 3 arg available])
82			], [
83				AC_MSG_RESULT(no)
84			])
85		])
86	])
87])
88