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