xref: /freebsd/sys/contrib/openzfs/config/kernel-vfs-iov_iter.m4 (revision cc1a53bc1aea0675d64e9547cdca241612906592)
1dnl #
2dnl # Check for available iov_iter functionality.
3dnl #
4AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_IOV_ITER], [
5	ZFS_LINUX_TEST_SRC([iov_iter_types], [
6		#include <linux/fs.h>
7		#include <linux/uio.h>
8	],[
9		int type __attribute__ ((unused)) =
10		    ITER_IOVEC | ITER_KVEC | ITER_BVEC | ITER_PIPE;
11	])
12
13	ZFS_LINUX_TEST_SRC([iov_iter_advance], [
14		#include <linux/fs.h>
15		#include <linux/uio.h>
16	],[
17		struct iov_iter iter = { 0 };
18		size_t advance = 512;
19
20		iov_iter_advance(&iter, advance);
21	])
22
23	ZFS_LINUX_TEST_SRC([iov_iter_revert], [
24		#include <linux/fs.h>
25		#include <linux/uio.h>
26	],[
27		struct iov_iter iter = { 0 };
28		size_t revert = 512;
29
30		iov_iter_revert(&iter, revert);
31	])
32
33	ZFS_LINUX_TEST_SRC([iov_iter_fault_in_readable], [
34		#include <linux/fs.h>
35		#include <linux/uio.h>
36	],[
37		struct iov_iter iter = { 0 };
38		size_t size = 512;
39		int error __attribute__ ((unused));
40
41		error = iov_iter_fault_in_readable(&iter, size);
42	])
43
44	ZFS_LINUX_TEST_SRC([fault_in_iov_iter_readable], [
45		#include <linux/fs.h>
46		#include <linux/uio.h>
47	],[
48		struct iov_iter iter = { 0 };
49		size_t size = 512;
50		int error __attribute__ ((unused));
51
52		error = fault_in_iov_iter_readable(&iter, size);
53	])
54
55	ZFS_LINUX_TEST_SRC([iov_iter_count], [
56		#include <linux/fs.h>
57		#include <linux/uio.h>
58	],[
59		struct iov_iter iter = { 0 };
60		size_t bytes __attribute__ ((unused));
61
62		bytes = iov_iter_count(&iter);
63	])
64
65	ZFS_LINUX_TEST_SRC([copy_to_iter], [
66		#include <linux/fs.h>
67		#include <linux/uio.h>
68	],[
69		struct iov_iter iter = { 0 };
70		char buf[512] = { 0 };
71		size_t size = 512;
72		size_t bytes __attribute__ ((unused));
73
74		bytes = copy_to_iter((const void *)&buf, size, &iter);
75	])
76
77	ZFS_LINUX_TEST_SRC([copy_from_iter], [
78		#include <linux/fs.h>
79		#include <linux/uio.h>
80	],[
81		struct iov_iter iter = { 0 };
82		char buf[512] = { 0 };
83		size_t size = 512;
84		size_t bytes __attribute__ ((unused));
85
86		bytes = copy_from_iter((void *)&buf, size, &iter);
87	])
88
89	ZFS_LINUX_TEST_SRC([iov_iter_type], [
90		#include <linux/fs.h>
91		#include <linux/uio.h>
92	],[
93		struct iov_iter iter = { 0 };
94		__attribute__((unused)) enum iter_type i = iov_iter_type(&iter);
95	])
96])
97
98AC_DEFUN([ZFS_AC_KERNEL_VFS_IOV_ITER], [
99	enable_vfs_iov_iter="yes"
100
101	AC_MSG_CHECKING([whether iov_iter types are available])
102	ZFS_LINUX_TEST_RESULT([iov_iter_types], [
103		AC_MSG_RESULT(yes)
104		AC_DEFINE(HAVE_IOV_ITER_TYPES, 1,
105		    [iov_iter types are available])
106	],[
107		AC_MSG_RESULT(no)
108		enable_vfs_iov_iter="no"
109	])
110
111	AC_MSG_CHECKING([whether iov_iter_advance() is available])
112	ZFS_LINUX_TEST_RESULT([iov_iter_advance], [
113		AC_MSG_RESULT(yes)
114		AC_DEFINE(HAVE_IOV_ITER_ADVANCE, 1,
115		    [iov_iter_advance() is available])
116	],[
117		AC_MSG_RESULT(no)
118		enable_vfs_iov_iter="no"
119	])
120
121	AC_MSG_CHECKING([whether iov_iter_revert() is available])
122	ZFS_LINUX_TEST_RESULT([iov_iter_revert], [
123		AC_MSG_RESULT(yes)
124		AC_DEFINE(HAVE_IOV_ITER_REVERT, 1,
125		    [iov_iter_revert() is available])
126	],[
127		AC_MSG_RESULT(no)
128		enable_vfs_iov_iter="no"
129	])
130
131	AC_MSG_CHECKING([whether iov_iter_fault_in_readable() is available])
132	ZFS_LINUX_TEST_RESULT([iov_iter_fault_in_readable], [
133		AC_MSG_RESULT(yes)
134		AC_DEFINE(HAVE_IOV_ITER_FAULT_IN_READABLE, 1,
135		    [iov_iter_fault_in_readable() is available])
136	],[
137		AC_MSG_CHECKING([whether fault_in_iov_iter_readable() is available])
138		ZFS_LINUX_TEST_RESULT([fault_in_iov_iter_readable], [
139			AC_MSG_RESULT(yes)
140			AC_DEFINE(HAVE_FAULT_IN_IOV_ITER_READABLE, 1,
141			    [fault_in_iov_iter_readable() is available])
142		],[
143			AC_MSG_RESULT(no)
144			enable_vfs_iov_iter="no"
145		])
146	])
147
148	AC_MSG_CHECKING([whether iov_iter_count() is available])
149	ZFS_LINUX_TEST_RESULT([iov_iter_count], [
150		AC_MSG_RESULT(yes)
151		AC_DEFINE(HAVE_IOV_ITER_COUNT, 1,
152		    [iov_iter_count() is available])
153	],[
154		AC_MSG_RESULT(no)
155		enable_vfs_iov_iter="no"
156	])
157
158	AC_MSG_CHECKING([whether copy_to_iter() is available])
159	ZFS_LINUX_TEST_RESULT([copy_to_iter], [
160		AC_MSG_RESULT(yes)
161		AC_DEFINE(HAVE_COPY_TO_ITER, 1,
162		    [copy_to_iter() is available])
163	],[
164		AC_MSG_RESULT(no)
165		enable_vfs_iov_iter="no"
166	])
167
168	AC_MSG_CHECKING([whether copy_from_iter() is available])
169	ZFS_LINUX_TEST_RESULT([copy_from_iter], [
170		AC_MSG_RESULT(yes)
171		AC_DEFINE(HAVE_COPY_FROM_ITER, 1,
172		    [copy_from_iter() is available])
173	],[
174		AC_MSG_RESULT(no)
175		enable_vfs_iov_iter="no"
176	])
177
178	dnl #
179	dnl # This checks for iov_iter_type() in linux/uio.h. It is not
180	dnl # required, however, and the module will compiled without it
181	dnl # using direct access of the member attribute
182	dnl #
183	AC_MSG_CHECKING([whether iov_iter_type() is available])
184	ZFS_LINUX_TEST_RESULT([iov_iter_type], [
185		AC_MSG_RESULT(yes)
186		AC_DEFINE(HAVE_IOV_ITER_TYPE, 1,
187		    [iov_iter_type() is available])
188	],[
189		AC_MSG_RESULT(no)
190	])
191
192	dnl #
193	dnl # As of the 4.9 kernel support is provided for iovecs, kvecs,
194	dnl # bvecs and pipes in the iov_iter structure.  As long as the
195	dnl # other support interfaces are all available the iov_iter can
196	dnl # be correctly used in the uio structure.
197	dnl #
198	AS_IF([test "x$enable_vfs_iov_iter" = "xyes"], [
199		AC_DEFINE(HAVE_VFS_IOV_ITER, 1,
200		    [All required iov_iter interfaces are available])
201	])
202])
203