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