xref: /freebsd/sys/contrib/openzfs/config/kernel-vfs-direct_IO.m4 (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
1dnl #
2dnl # Check for direct IO interfaces.
3dnl #
4AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_DIRECT_IO], [
5	ZFS_LINUX_TEST_SRC([direct_io_iter], [
6		#include <linux/fs.h>
7
8		static ssize_t test_direct_IO(struct kiocb *kiocb,
9		    struct iov_iter *iter) { return 0; }
10
11		static const struct address_space_operations
12		    aops __attribute__ ((unused)) = {
13			.direct_IO = test_direct_IO,
14		};
15	],[])
16
17	ZFS_LINUX_TEST_SRC([direct_io_iter_offset], [
18		#include <linux/fs.h>
19
20		static ssize_t test_direct_IO(struct kiocb *kiocb,
21		    struct iov_iter *iter, loff_t offset) { return 0; }
22
23		static const struct address_space_operations
24		    aops __attribute__ ((unused)) = {
25			.direct_IO = test_direct_IO,
26		};
27	],[])
28
29	ZFS_LINUX_TEST_SRC([direct_io_iter_rw_offset], [
30		#include <linux/fs.h>
31
32		static ssize_t test_direct_IO(int rw, struct kiocb *kiocb,
33		    struct iov_iter *iter, loff_t offset) { return 0; }
34
35		static const struct address_space_operations
36		    aops __attribute__ ((unused)) = {
37		    .direct_IO = test_direct_IO,
38		};
39	],[])
40
41	ZFS_LINUX_TEST_SRC([direct_io_iovec], [
42		#include <linux/fs.h>
43
44		static ssize_t test_direct_IO(int rw, struct kiocb *kiocb,
45		    const struct iovec *iov, loff_t offset,
46		    unsigned long nr_segs) { return 0; }
47
48		static const struct address_space_operations
49		    aops __attribute__ ((unused)) = {
50		    .direct_IO = test_direct_IO,
51		};
52	],[])
53])
54
55AC_DEFUN([ZFS_AC_KERNEL_VFS_DIRECT_IO], [
56	dnl #
57	dnl # Linux 4.6.x API change
58	dnl #
59	AC_MSG_CHECKING([whether aops->direct_IO() uses iov_iter])
60	ZFS_LINUX_TEST_RESULT([direct_io_iter], [
61		AC_MSG_RESULT([yes])
62		AC_DEFINE(HAVE_VFS_DIRECT_IO_ITER, 1,
63		    [aops->direct_IO() uses iov_iter without rw])
64	],[
65		AC_MSG_RESULT([no])
66
67		dnl #
68		dnl # Linux 4.1.x API change
69		dnl #
70		AC_MSG_CHECKING(
71		    [whether aops->direct_IO() uses offset])
72		ZFS_LINUX_TEST_RESULT([direct_io_iter_offset], [
73			AC_MSG_RESULT([yes])
74			AC_DEFINE(HAVE_VFS_DIRECT_IO_ITER_OFFSET, 1,
75			    [aops->direct_IO() uses iov_iter with offset])
76
77		],[
78			AC_MSG_RESULT([no])
79
80			dnl #
81			dnl # Linux 3.16.x API change
82			dnl #
83			AC_MSG_CHECKING(
84			    [whether aops->direct_IO() uses rw and offset])
85			ZFS_LINUX_TEST_RESULT([direct_io_iter_rw_offset], [
86				AC_MSG_RESULT([yes])
87				AC_DEFINE(HAVE_VFS_DIRECT_IO_ITER_RW_OFFSET, 1,
88				    [aops->direct_IO() uses iov_iter with ]
89				    [rw and offset])
90			],[
91				AC_MSG_RESULT([no])
92
93				dnl #
94				dnl # Ancient Linux API (predates git)
95				dnl #
96				AC_MSG_CHECKING(
97				    [whether aops->direct_IO() uses iovec])
98				ZFS_LINUX_TEST_RESULT([direct_io_iovec], [
99					AC_MSG_RESULT([yes])
100					AC_DEFINE(HAVE_VFS_DIRECT_IO_IOVEC, 1,
101					    [aops->direct_IO() uses iovec])
102				],[
103					ZFS_LINUX_TEST_ERROR([direct IO])
104					AC_MSG_RESULT([no])
105				])
106			])
107		])
108	])
109])
110