Linux 6.4 compat: iter_iov() function now used to get old iov member
[zfs.git] / config / kernel-vfs-iov_iter.m4
blobcc5a7ab0c237d73c994e40299cfd790b45902665
1 dnl #
2 dnl # Check for available iov_iter functionality.
3 dnl #
4 AC_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         ])
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;
20                 iov_iter_advance(&iter, advance);
21         ])
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;
30                 iov_iter_revert(&iter, revert);
31         ])
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));
41                 error = iov_iter_fault_in_readable(&iter, size);
42         ])
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));
52                 error = fault_in_iov_iter_readable(&iter, size);
53         ])
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));
62                 bytes = iov_iter_count(&iter);
63         ])
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));
74                 bytes = copy_to_iter((const void *)&buf, size, &iter);
75         ])
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));
86                 bytes = copy_from_iter((void *)&buf, size, &iter);
87         ])
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         ])
97         ZFS_LINUX_TEST_SRC([iter_iov], [
98                 #include <linux/fs.h>
99                 #include <linux/uio.h>
100         ],[
101                 struct iov_iter iter = { 0 };
102                 __attribute__((unused)) const struct iovec *iov = iter_iov(&iter);
103         ])
106 AC_DEFUN([ZFS_AC_KERNEL_VFS_IOV_ITER], [
107         enable_vfs_iov_iter="yes"
109         AC_MSG_CHECKING([whether iov_iter types are available])
110         ZFS_LINUX_TEST_RESULT([iov_iter_types], [
111                 AC_MSG_RESULT(yes)
112                 AC_DEFINE(HAVE_IOV_ITER_TYPES, 1,
113                     [iov_iter types are available])
114         ],[
115                 AC_MSG_RESULT(no)
116                 enable_vfs_iov_iter="no"
117         ])
119         AC_MSG_CHECKING([whether iov_iter_advance() is available])
120         ZFS_LINUX_TEST_RESULT([iov_iter_advance], [
121                 AC_MSG_RESULT(yes)
122                 AC_DEFINE(HAVE_IOV_ITER_ADVANCE, 1,
123                     [iov_iter_advance() is available])
124         ],[
125                 AC_MSG_RESULT(no)
126                 enable_vfs_iov_iter="no"
127         ])
129         AC_MSG_CHECKING([whether iov_iter_revert() is available])
130         ZFS_LINUX_TEST_RESULT([iov_iter_revert], [
131                 AC_MSG_RESULT(yes)
132                 AC_DEFINE(HAVE_IOV_ITER_REVERT, 1,
133                     [iov_iter_revert() is available])
134         ],[
135                 AC_MSG_RESULT(no)
136                 enable_vfs_iov_iter="no"
137         ])
139         AC_MSG_CHECKING([whether iov_iter_fault_in_readable() is available])
140         ZFS_LINUX_TEST_RESULT([iov_iter_fault_in_readable], [
141                 AC_MSG_RESULT(yes)
142                 AC_DEFINE(HAVE_IOV_ITER_FAULT_IN_READABLE, 1,
143                     [iov_iter_fault_in_readable() is available])
144         ],[
145                 AC_MSG_RESULT(no)
147                 AC_MSG_CHECKING([whether fault_in_iov_iter_readable() is available])
148                 ZFS_LINUX_TEST_RESULT([fault_in_iov_iter_readable], [
149                         AC_MSG_RESULT(yes)
150                         AC_DEFINE(HAVE_FAULT_IN_IOV_ITER_READABLE, 1,
151                             [fault_in_iov_iter_readable() is available])
152                 ],[
153                         AC_MSG_RESULT(no)
154                         enable_vfs_iov_iter="no"
155                 ])
156         ])
158         AC_MSG_CHECKING([whether iov_iter_count() is available])
159         ZFS_LINUX_TEST_RESULT([iov_iter_count], [
160                 AC_MSG_RESULT(yes)
161                 AC_DEFINE(HAVE_IOV_ITER_COUNT, 1,
162                     [iov_iter_count() is available])
163         ],[
164                 AC_MSG_RESULT(no)
165                 enable_vfs_iov_iter="no"
166         ])
168         AC_MSG_CHECKING([whether copy_to_iter() is available])
169         ZFS_LINUX_TEST_RESULT([copy_to_iter], [
170                 AC_MSG_RESULT(yes)
171                 AC_DEFINE(HAVE_COPY_TO_ITER, 1,
172                     [copy_to_iter() is available])
173         ],[
174                 AC_MSG_RESULT(no)
175                 enable_vfs_iov_iter="no"
176         ])
178         AC_MSG_CHECKING([whether copy_from_iter() is available])
179         ZFS_LINUX_TEST_RESULT([copy_from_iter], [
180                 AC_MSG_RESULT(yes)
181                 AC_DEFINE(HAVE_COPY_FROM_ITER, 1,
182                     [copy_from_iter() is available])
183         ],[
184                 AC_MSG_RESULT(no)
185                 enable_vfs_iov_iter="no"
186         ])
188         dnl #
189         dnl # This checks for iov_iter_type() in linux/uio.h. It is not
190         dnl # required, however, and the module will compiled without it
191         dnl # using direct access of the member attribute
192         dnl #
193         AC_MSG_CHECKING([whether iov_iter_type() is available])
194         ZFS_LINUX_TEST_RESULT([iov_iter_type], [
195                 AC_MSG_RESULT(yes)
196                 AC_DEFINE(HAVE_IOV_ITER_TYPE, 1,
197                     [iov_iter_type() is available])
198         ],[
199                 AC_MSG_RESULT(no)
200         ])
202         dnl #
203         dnl # As of the 4.9 kernel support is provided for iovecs, kvecs,
204         dnl # bvecs and pipes in the iov_iter structure.  As long as the
205         dnl # other support interfaces are all available the iov_iter can
206         dnl # be correctly used in the uio structure.
207         dnl #
208         AS_IF([test "x$enable_vfs_iov_iter" = "xyes"], [
209                 AC_DEFINE(HAVE_VFS_IOV_ITER, 1,
210                     [All required iov_iter interfaces are available])
211         ])
213         dnl #
214         dnl # Kernel 6.5 introduces the iter_iov() function that returns the
215         dnl # __iov member of an iov_iter*. The iov member was renamed to this
216         dnl # __iov member, and is intended to be accessed via the helper
217         dnl # function now.
218         dnl #
219         AC_MSG_CHECKING([whether iter_iov() is available])
220         ZFS_LINUX_TEST_RESULT([iter_iov], [
221                 AC_MSG_RESULT(yes)
222                 AC_DEFINE(HAVE_ITER_IOV, 1,
223                     [iter_iov() is available])
224         ],[
225                 AC_MSG_RESULT(no)
226         ])