]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - config/kernel-bio.m4
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / config / kernel-bio.m4
1 dnl #
2 dnl # 2.6.36 API change,
3 dnl # REQ_FAILFAST_{DEV|TRANSPORT|DRIVER}
4 dnl # REQ_DISCARD
5 dnl # REQ_FLUSH
6 dnl #
7 dnl # 4.8 - 4.9 API,
8 dnl # REQ_FLUSH was renamed to REQ_PREFLUSH
9 dnl #
10 AC_DEFUN([ZFS_AC_KERNEL_SRC_REQ], [
11         ZFS_LINUX_TEST_SRC([req_failfast_mask], [
12                 #include <linux/bio.h>
13         ],[
14                 int flags __attribute__ ((unused));
15                 flags = REQ_FAILFAST_MASK;
16         ])
17
18         ZFS_LINUX_TEST_SRC([req_discard], [
19                 #include <linux/bio.h>
20         ],[
21                 int flags __attribute__ ((unused));
22                 flags = REQ_DISCARD;
23         ])
24
25         ZFS_LINUX_TEST_SRC([req_flush], [
26                 #include <linux/bio.h>
27         ],[
28                 int flags __attribute__ ((unused));
29                 flags = REQ_FLUSH;
30         ])
31
32         ZFS_LINUX_TEST_SRC([req_preflush], [
33                 #include <linux/bio.h>
34         ],[
35                 int flags __attribute__ ((unused));
36                 flags = REQ_PREFLUSH;
37         ])
38 ])
39
40 AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_FAILFAST_MASK], [
41         AC_MSG_CHECKING([whether REQ_FAILFAST_MASK is defined])
42         ZFS_LINUX_TEST_RESULT([req_failfast_mask], [
43                 AC_MSG_RESULT(yes)
44         ],[
45                 ZFS_LINUX_TEST_ERROR([REQ_FAILFAST_MASK])
46         ])
47 ])
48
49 AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_DISCARD], [
50         AC_MSG_CHECKING([whether REQ_DISCARD is defined])
51         ZFS_LINUX_TEST_RESULT([req_discard], [
52                 AC_MSG_RESULT(yes)
53                 AC_DEFINE(HAVE_REQ_DISCARD, 1, [REQ_DISCARD is defined])
54         ],[
55                 AC_MSG_RESULT(no)
56         ])
57 ])
58
59 AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_FLUSH], [
60         AC_MSG_CHECKING([whether REQ_FLUSH is defined])
61         ZFS_LINUX_TEST_RESULT([req_flush], [
62                 AC_MSG_RESULT(yes)
63                 AC_DEFINE(HAVE_REQ_FLUSH, 1, [REQ_FLUSH is defined])
64         ],[
65                 AC_MSG_RESULT(no)
66         ])
67 ])
68
69 AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_PREFLUSH], [
70         AC_MSG_CHECKING([whether REQ_PREFLUSH is defined])
71         ZFS_LINUX_TEST_RESULT([req_preflush], [
72                 AC_MSG_RESULT(yes)
73                 AC_DEFINE(HAVE_REQ_PREFLUSH, 1, [REQ_PREFLUSH is defined])
74         ],[
75                 AC_MSG_RESULT(no)
76         ])
77 ])
78
79 dnl #
80 dnl # Linux 4.8 API,
81 dnl #
82 dnl # The bio_op() helper was introduced as a replacement for explicitly
83 dnl # checking the bio->bi_rw flags.  The following checks are used to
84 dnl # detect if a specific operation is supported.
85 dnl #
86 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_OPS], [
87         ZFS_LINUX_TEST_SRC([req_op_discard], [
88                 #include <linux/blk_types.h>
89         ],[
90                 int op __attribute__ ((unused)) = REQ_OP_DISCARD;
91         ])
92
93         ZFS_LINUX_TEST_SRC([req_op_secure_erase], [
94                 #include <linux/blk_types.h>
95         ],[
96                 int op __attribute__ ((unused)) = REQ_OP_SECURE_ERASE;
97         ])
98
99         ZFS_LINUX_TEST_SRC([req_op_flush], [
100                 #include <linux/blk_types.h>
101         ],[
102                 int op __attribute__ ((unused)) = REQ_OP_FLUSH;
103         ])
104
105         ZFS_LINUX_TEST_SRC([bio_bi_opf], [
106                 #include <linux/bio.h>
107         ],[
108                 struct bio bio __attribute__ ((unused));
109                 bio.bi_opf = 0;
110         ])
111
112         ZFS_LINUX_TEST_SRC([bio_set_op_attrs], [
113                 #include <linux/bio.h>
114         ],[
115                 struct bio *bio __attribute__ ((unused)) = NULL;
116                 bio_set_op_attrs(bio, 0, 0);
117         ])
118 ])
119
120 AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_OP_DISCARD], [
121         AC_MSG_CHECKING([whether REQ_OP_DISCARD is defined])
122         ZFS_LINUX_TEST_RESULT([req_op_discard], [
123                 AC_MSG_RESULT(yes)
124                 AC_DEFINE(HAVE_REQ_OP_DISCARD, 1, [REQ_OP_DISCARD is defined])
125         ],[
126                 AC_MSG_RESULT(no)
127         ])
128 ])
129
130 AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_OP_SECURE_ERASE], [
131         AC_MSG_CHECKING([whether REQ_OP_SECURE_ERASE is defined])
132         ZFS_LINUX_TEST_RESULT([req_op_secure_erase], [
133                 AC_MSG_RESULT(yes)
134                 AC_DEFINE(HAVE_REQ_OP_SECURE_ERASE, 1,
135                     [REQ_OP_SECURE_ERASE is defined])
136         ],[
137                 AC_MSG_RESULT(no)
138         ])
139 ])
140
141 AC_DEFUN([ZFS_AC_KERNEL_BIO_REQ_OP_FLUSH], [
142         AC_MSG_CHECKING([whether REQ_OP_FLUSH is defined])
143         ZFS_LINUX_TEST_RESULT([req_op_flush], [
144                 AC_MSG_RESULT(yes)
145                 AC_DEFINE(HAVE_REQ_OP_FLUSH, 1, [REQ_OP_FLUSH is defined])
146         ],[
147                 AC_MSG_RESULT(no)
148         ])
149 ])
150
151 AC_DEFUN([ZFS_AC_KERNEL_BIO_BI_OPF], [
152         AC_MSG_CHECKING([whether bio->bi_opf is defined])
153         ZFS_LINUX_TEST_RESULT([bio_bi_opf], [
154                 AC_MSG_RESULT(yes)
155                 AC_DEFINE(HAVE_BIO_BI_OPF, 1, [bio->bi_opf is defined])
156         ],[
157                 AC_MSG_RESULT(no)
158         ])
159 ])
160
161 AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_OP_ATTRS], [
162         AC_MSG_CHECKING([whether bio_set_op_attrs is available])
163         ZFS_LINUX_TEST_RESULT([bio_set_op_attrs], [
164                 AC_MSG_RESULT(yes)
165                 AC_DEFINE(HAVE_BIO_SET_OP_ATTRS, 1,
166                     [bio_set_op_attrs is available])
167         ],[
168                 AC_MSG_RESULT(no)
169         ])
170 ])
171
172 dnl #
173 dnl # Linux 4.14 API,
174 dnl #
175 dnl # The bio_set_dev() helper macro was introduced as part of the transition
176 dnl # to have struct gendisk in struct bio.
177 dnl #
178 dnl # Linux 5.0 API,
179 dnl #
180 dnl # The bio_set_dev() helper macro was updated to internally depend on
181 dnl # bio_associate_blkg() symbol which is exported GPL-only.
182 dnl #
183 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_SET_DEV], [
184         ZFS_LINUX_TEST_SRC([bio_set_dev], [
185                 #include <linux/bio.h>
186                 #include <linux/fs.h>
187         ],[
188                 struct block_device *bdev = NULL;
189                 struct bio *bio = NULL;
190                 bio_set_dev(bio, bdev);
191         ], [], [$ZFS_META_LICENSE])
192 ])
193
194 AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_DEV], [
195         AC_MSG_CHECKING([whether bio_set_dev() is available])
196         ZFS_LINUX_TEST_RESULT([bio_set_dev], [
197                 AC_MSG_RESULT(yes)
198                 AC_DEFINE(HAVE_BIO_SET_DEV, 1, [bio_set_dev() is available])
199
200                 AC_MSG_CHECKING([whether bio_set_dev() is GPL-only])
201                 ZFS_LINUX_TEST_RESULT([bio_set_dev_license], [
202                         AC_MSG_RESULT(no)
203                 ],[
204                         AC_MSG_RESULT(yes)
205                         AC_DEFINE(HAVE_BIO_SET_DEV_GPL_ONLY, 1,
206                             [bio_set_dev() GPL-only])
207                 ])
208         ],[
209                 AC_MSG_RESULT(no)
210         ])
211 ])
212
213 dnl #
214 dnl # 4.3 API change
215 dnl # Error argument dropped from bio_endio in favor of newly introduced
216 dnl # bio->bi_error. This also replaces bio->bi_flags value BIO_UPTODATE.
217 dnl # Introduced by torvalds/linux@4246a0b63bd8f56a1469b12eafeb875b1041a451
218 dnl # ("block: add a bi_error field to struct bio").
219 dnl #
220 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_END_IO_T_ARGS], [
221         ZFS_LINUX_TEST_SRC([bio_end_io_t_args], [
222                 #include <linux/bio.h>
223                 void wanted_end_io(struct bio *bio) { return; }
224                 bio_end_io_t *end_io __attribute__ ((unused)) = wanted_end_io;
225         ], [])
226 ])
227
228 AC_DEFUN([ZFS_AC_KERNEL_BIO_END_IO_T_ARGS], [
229         AC_MSG_CHECKING([whether bio_end_io_t wants 1 arg])
230         ZFS_LINUX_TEST_RESULT([bio_end_io_t_args], [
231                 AC_MSG_RESULT(yes)
232                 AC_DEFINE(HAVE_1ARG_BIO_END_IO_T, 1,
233                     [bio_end_io_t wants 1 arg])
234         ], [
235                 AC_MSG_RESULT(no)
236         ])
237 ])
238
239 dnl #
240 dnl # 4.13 API change
241 dnl # The bio->bi_error field was replaced with bio->bi_status which is an
242 dnl # enum which describes all possible error types.
243 dnl #
244 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_BI_STATUS], [
245         ZFS_LINUX_TEST_SRC([bio_bi_status], [
246                 #include <linux/bio.h>
247         ], [
248                 struct bio bio __attribute__ ((unused));
249                 blk_status_t status __attribute__ ((unused)) = BLK_STS_OK;
250                 bio.bi_status = status;
251         ])
252 ])
253
254 AC_DEFUN([ZFS_AC_KERNEL_BIO_BI_STATUS], [
255         AC_MSG_CHECKING([whether bio->bi_status exists])
256         ZFS_LINUX_TEST_RESULT([bio_bi_status], [
257                 AC_MSG_RESULT(yes)
258                 AC_DEFINE(HAVE_BIO_BI_STATUS, 1, [bio->bi_status exists])
259         ],[
260                 AC_MSG_RESULT(no)
261         ])
262 ])
263
264 dnl #
265 dnl # 3.14 API change,
266 dnl # Immutable biovecs. A number of fields of struct bio are moved to
267 dnl # struct bvec_iter.
268 dnl #
269 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_BVEC_ITER], [
270         ZFS_LINUX_TEST_SRC([bio_bvec_iter], [
271                 #include <linux/bio.h>
272         ],[
273                 struct bio bio;
274                 bio.bi_iter.bi_sector = 0;
275         ])
276 ])
277
278 AC_DEFUN([ZFS_AC_KERNEL_BIO_BVEC_ITER], [
279         AC_MSG_CHECKING([whether bio has bi_iter])
280         ZFS_LINUX_TEST_RESULT([bio_bvec_iter], [
281                 AC_MSG_RESULT(yes)
282                 AC_DEFINE(HAVE_BIO_BVEC_ITER, 1, [bio has bi_iter])
283         ],[
284                 AC_MSG_RESULT(no)
285         ])
286 ])
287
288 dnl #
289 dnl # 4.8 API change
290 dnl # The rw argument has been removed from submit_bio/submit_bio_wait.
291 dnl # Callers are now expected to set bio->bi_rw instead of passing it in.
292 dnl #
293 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_SUBMIT_BIO], [
294         ZFS_LINUX_TEST_SRC([submit_bio], [
295                 #include <linux/bio.h>
296         ],[
297                 blk_qc_t blk_qc;
298                 struct bio *bio = NULL;
299                 blk_qc = submit_bio(bio);
300         ])
301 ])
302
303 AC_DEFUN([ZFS_AC_KERNEL_BIO_SUBMIT_BIO], [
304         AC_MSG_CHECKING([whether submit_bio() wants 1 arg])
305         ZFS_LINUX_TEST_RESULT([submit_bio], [
306                 AC_MSG_RESULT(yes)
307                 AC_DEFINE(HAVE_1ARG_SUBMIT_BIO, 1, [submit_bio() wants 1 arg])
308         ],[
309                 AC_MSG_RESULT(no)
310         ])
311 ])
312
313 dnl #
314 dnl # 2.6.34 API change
315 dnl # current->bio_list
316 dnl #
317 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_CURRENT_BIO_LIST], [
318         ZFS_LINUX_TEST_SRC([current_bio_list], [
319                 #include <linux/sched.h>
320         ], [
321                 current->bio_list = (struct bio_list *) NULL;
322         ])
323 ])
324
325 AC_DEFUN([ZFS_AC_KERNEL_BIO_CURRENT_BIO_LIST], [
326         AC_MSG_CHECKING([whether current->bio_list exists])
327         ZFS_LINUX_TEST_RESULT([current_bio_list], [
328                 AC_MSG_RESULT(yes)
329         ],[
330                 ZFS_LINUX_TEST_ERROR([bio_list])
331         ])
332 ])
333
334 dnl #
335 dnl # Linux 5.5 API,
336 dnl #
337 dnl # The Linux 5.5 kernel updated percpu_ref_tryget() which is inlined by
338 dnl # blkg_tryget() to use rcu_read_lock() instead of rcu_read_lock_sched().
339 dnl # As a side effect the function was converted to GPL-only.
340 dnl #
341 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKG_TRYGET], [
342         ZFS_LINUX_TEST_SRC([blkg_tryget], [
343                 #include <linux/blk-cgroup.h>
344                 #include <linux/bio.h>
345                 #include <linux/fs.h>
346         ],[
347                 struct blkcg_gq blkg __attribute__ ((unused));
348                 bool rc __attribute__ ((unused));
349                 rc = blkg_tryget(&blkg);
350         ], [], [$ZFS_META_LICENSE])
351 ])
352
353 AC_DEFUN([ZFS_AC_KERNEL_BLKG_TRYGET], [
354         AC_MSG_CHECKING([whether blkg_tryget() is available])
355         ZFS_LINUX_TEST_RESULT([blkg_tryget], [
356                 AC_MSG_RESULT(yes)
357                 AC_DEFINE(HAVE_BLKG_TRYGET, 1, [blkg_tryget() is available])
358
359                 AC_MSG_CHECKING([whether blkg_tryget() is GPL-only])
360                 ZFS_LINUX_TEST_RESULT([blkg_tryget_license], [
361                         AC_MSG_RESULT(no)
362                 ],[
363                         AC_MSG_RESULT(yes)
364                         AC_DEFINE(HAVE_BLKG_TRYGET_GPL_ONLY, 1,
365                             [blkg_tryget() GPL-only])
366                 ])
367         ],[
368                 AC_MSG_RESULT(no)
369         ])
370 ])
371
372 AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [
373         ZFS_AC_KERNEL_SRC_REQ
374         ZFS_AC_KERNEL_SRC_BIO_OPS
375         ZFS_AC_KERNEL_SRC_BIO_SET_DEV
376         ZFS_AC_KERNEL_SRC_BIO_END_IO_T_ARGS
377         ZFS_AC_KERNEL_SRC_BIO_BI_STATUS
378         ZFS_AC_KERNEL_SRC_BIO_BVEC_ITER
379         ZFS_AC_KERNEL_SRC_BIO_SUBMIT_BIO
380         ZFS_AC_KERNEL_SRC_BIO_CURRENT_BIO_LIST
381         ZFS_AC_KERNEL_SRC_BLKG_TRYGET
382 ])
383
384 AC_DEFUN([ZFS_AC_KERNEL_BIO], [
385         ZFS_AC_KERNEL_BIO_REQ_FAILFAST_MASK
386         ZFS_AC_KERNEL_BIO_REQ_DISCARD
387         ZFS_AC_KERNEL_BIO_REQ_FLUSH
388         ZFS_AC_KERNEL_BIO_REQ_PREFLUSH
389
390         ZFS_AC_KERNEL_BIO_REQ_OP_DISCARD
391         ZFS_AC_KERNEL_BIO_REQ_OP_SECURE_ERASE
392         ZFS_AC_KERNEL_BIO_REQ_OP_FLUSH
393         ZFS_AC_KERNEL_BIO_BI_OPF
394         ZFS_AC_KERNEL_BIO_SET_OP_ATTRS
395
396         ZFS_AC_KERNEL_BIO_SET_DEV
397         ZFS_AC_KERNEL_BIO_END_IO_T_ARGS
398         ZFS_AC_KERNEL_BIO_BI_STATUS
399         ZFS_AC_KERNEL_BIO_BVEC_ITER
400         ZFS_AC_KERNEL_BIO_SUBMIT_BIO
401         ZFS_AC_KERNEL_BIO_CURRENT_BIO_LIST
402         ZFS_AC_KERNEL_BLKG_TRYGET
403 ])