1dnl #
2dnl # Check for generic io accounting interface.
3dnl #
4AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT], [
5	ZFS_LINUX_TEST_SRC([generic_acct_3args], [
6		#include <linux/bio.h>
7
8		void (*generic_start_io_acct_f)(int, unsigned long,
9		    struct hd_struct *) = &generic_start_io_acct;
10		void (*generic_end_io_acct_f)(int, struct hd_struct *,
11		    unsigned long) = &generic_end_io_acct;
12	], [
13		generic_start_io_acct(0, 0, NULL);
14		generic_end_io_acct(0, NULL, 0);
15	])
16
17	ZFS_LINUX_TEST_SRC([generic_acct_4args], [
18		#include <linux/bio.h>
19
20		void (*generic_start_io_acct_f)(struct request_queue *, int,
21		    unsigned long, struct hd_struct *) = &generic_start_io_acct;
22		void (*generic_end_io_acct_f)(struct request_queue *, int,
23		    struct hd_struct *, unsigned long) = &generic_end_io_acct;
24	], [
25		generic_start_io_acct(NULL, 0, 0, NULL);
26		generic_end_io_acct(NULL, 0, NULL, 0);
27	])
28])
29
30AC_DEFUN([ZFS_AC_KERNEL_GENERIC_IO_ACCT], [
31	dnl #
32	dnl # 3.19 API addition
33	dnl #
34	dnl # torvalds/linux@394ffa50 allows us to increment iostat
35	dnl # counters without generic_make_request().
36	dnl #
37	AC_MSG_CHECKING([whether generic IO accounting wants 3 args])
38	ZFS_LINUX_TEST_RESULT_SYMBOL([generic_acct_3args],
39	    [generic_start_io_acct], [block/bio.c], [
40		AC_MSG_RESULT(yes)
41		AC_DEFINE(HAVE_GENERIC_IO_ACCT_3ARG, 1,
42		    [generic_start_io_acct()/generic_end_io_acct() available])
43	], [
44		AC_MSG_RESULT(no)
45
46		dnl #
47		dnl # Linux 4.14 API,
48		dnl #
49		dnl # generic_start_io_acct/generic_end_io_acct now require
50		dnl # request_queue to be provided. No functional changes,
51		dnl # but preparation for inflight accounting.
52		dnl #
53		AC_MSG_CHECKING([whether generic IO accounting wants 4 args])
54		ZFS_LINUX_TEST_RESULT_SYMBOL([generic_acct_4args],
55		    [generic_start_io_acct], [block/bio.c], [
56			AC_MSG_RESULT(yes)
57			AC_DEFINE(HAVE_GENERIC_IO_ACCT_4ARG, 1,
58			    [generic_start_io_acct()/generic_end_io_acct() ]
59			    [4 arg available])
60		], [
61			AC_MSG_RESULT(no)
62		])
63	])
64])
65