ZIL: Assert record sizes in different places
[zfs.git] / config / kernel-blk-queue.m4
blobbb5903b313ebbad372a699e084493447eb596c5a
1 dnl #
2 dnl # 2.6.39 API change,
3 dnl # blk_start_plug() and blk_finish_plug()
4 dnl #
5 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_PLUG], [
6         ZFS_LINUX_TEST_SRC([blk_plug], [
7                 #include <linux/blkdev.h>
8         ],[
9                 struct blk_plug plug __attribute__ ((unused));
11                 blk_start_plug(&plug);
12                 blk_finish_plug(&plug);
13         ])
16 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_PLUG], [
17         AC_MSG_CHECKING([whether struct blk_plug is available])
18         ZFS_LINUX_TEST_RESULT([blk_plug], [
19                 AC_MSG_RESULT(yes)
20         ],[
21                 ZFS_LINUX_TEST_ERROR([blk_plug])
22         ])
25 dnl #
26 dnl # 2.6.32 - 4.11: statically allocated bdi in request_queue
27 dnl # 4.12: dynamically allocated bdi in request_queue
28 dnl #
29 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_BDI], [
30         ZFS_LINUX_TEST_SRC([blk_queue_bdi], [
31                 #include <linux/blkdev.h>
32         ],[
33                 struct request_queue q;
34                 struct backing_dev_info bdi;
35                 q.backing_dev_info = &bdi;
36         ])
39 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_BDI], [
40         AC_MSG_CHECKING([whether blk_queue bdi is dynamic])
41         ZFS_LINUX_TEST_RESULT([blk_queue_bdi], [
42                 AC_MSG_RESULT(yes)
43                 AC_DEFINE(HAVE_BLK_QUEUE_BDI_DYNAMIC, 1,
44                     [blk queue backing_dev_info is dynamic])
45         ],[
46                 AC_MSG_RESULT(no)
47         ])
50 dnl #
51 dnl # 5.9: added blk_queue_update_readahead(),
52 dnl # 5.15: renamed to disk_update_readahead()
53 dnl #
54 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_UPDATE_READAHEAD], [
55         ZFS_LINUX_TEST_SRC([blk_queue_update_readahead], [
56                 #include <linux/blkdev.h>
57         ],[
58                 struct request_queue q;
59                 blk_queue_update_readahead(&q);
60         ])
62         ZFS_LINUX_TEST_SRC([disk_update_readahead], [
63                 #include <linux/blkdev.h>
64         ],[
65                 struct gendisk disk;
66                 disk_update_readahead(&disk);
67         ])
70 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_UPDATE_READAHEAD], [
71         AC_MSG_CHECKING([whether blk_queue_update_readahead() exists])
72         ZFS_LINUX_TEST_RESULT([blk_queue_update_readahead], [
73                 AC_MSG_RESULT(yes)
74                 AC_DEFINE(HAVE_BLK_QUEUE_UPDATE_READAHEAD, 1,
75                     [blk_queue_update_readahead() exists])
76         ],[
77                 AC_MSG_RESULT(no)
79                 AC_MSG_CHECKING([whether disk_update_readahead() exists])
80                 ZFS_LINUX_TEST_RESULT([disk_update_readahead], [
81                         AC_MSG_RESULT(yes)
82                         AC_DEFINE(HAVE_DISK_UPDATE_READAHEAD, 1,
83                             [disk_update_readahead() exists])
84                 ],[
85                         AC_MSG_RESULT(no)
86                 ])
87         ])
90 dnl #
91 dnl # 5.19: bdev_max_discard_sectors() available
92 dnl # 2.6.32: blk_queue_discard() available
93 dnl #
94 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD], [
95         ZFS_LINUX_TEST_SRC([bdev_max_discard_sectors], [
96                 #include <linux/blkdev.h>
97         ],[
98                 struct block_device *bdev __attribute__ ((unused)) = NULL;
99                 unsigned int error __attribute__ ((unused));
101                 error = bdev_max_discard_sectors(bdev);
102         ])
104         ZFS_LINUX_TEST_SRC([blk_queue_discard], [
105                 #include <linux/blkdev.h>
106         ],[
107                 struct request_queue r;
108                 struct request_queue *q = &r;
109                 int value __attribute__ ((unused));
110                 memset(q, 0, sizeof(r));
111                 value = blk_queue_discard(q);
112         ],[-Wframe-larger-than=8192])
115 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_DISCARD], [
116         AC_MSG_CHECKING([whether bdev_max_discard_sectors() is available])
117         ZFS_LINUX_TEST_RESULT([bdev_max_discard_sectors], [
118                 AC_MSG_RESULT(yes)
119                 AC_DEFINE(HAVE_BDEV_MAX_DISCARD_SECTORS, 1,
120                     [bdev_max_discard_sectors() is available])
121         ],[
122                 AC_MSG_RESULT(no)
124                 AC_MSG_CHECKING([whether blk_queue_discard() is available])
125                 ZFS_LINUX_TEST_RESULT([blk_queue_discard], [
126                         AC_MSG_RESULT(yes)
127                         AC_DEFINE(HAVE_BLK_QUEUE_DISCARD, 1,
128                             [blk_queue_discard() is available])
129                 ],[
130                         ZFS_LINUX_TEST_ERROR([blk_queue_discard])
131                 ])
132         ])
135 dnl #
136 dnl # 5.19: bdev_max_secure_erase_sectors() available
137 dnl # 4.8: blk_queue_secure_erase() available
138 dnl # 2.6.36: blk_queue_secdiscard() available
139 dnl #
140 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE], [
141         ZFS_LINUX_TEST_SRC([bdev_max_secure_erase_sectors], [
142                 #include <linux/blkdev.h>
143         ],[
144                 struct block_device *bdev __attribute__ ((unused)) = NULL;
145                 unsigned int error __attribute__ ((unused));
147                 error = bdev_max_secure_erase_sectors(bdev);
148         ])
150         ZFS_LINUX_TEST_SRC([blk_queue_secure_erase], [
151                 #include <linux/blkdev.h>
152         ],[
153                 struct request_queue r;
154                 struct request_queue *q = &r;
155                 int value __attribute__ ((unused));
156                 memset(q, 0, sizeof(r));
157                 value = blk_queue_secure_erase(q);
158         ],[-Wframe-larger-than=8192])
160         ZFS_LINUX_TEST_SRC([blk_queue_secdiscard], [
161                 #include <linux/blkdev.h>
162         ],[
163                 struct request_queue r;
164                 struct request_queue *q = &r;
165                 int value __attribute__ ((unused));
166                 memset(q, 0, sizeof(r));
167                 value = blk_queue_secdiscard(q);
168         ])
171 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE], [
172         AC_MSG_CHECKING([whether bdev_max_secure_erase_sectors() is available])
173         ZFS_LINUX_TEST_RESULT([bdev_max_secure_erase_sectors], [
174                 AC_MSG_RESULT(yes)
175                 AC_DEFINE(HAVE_BDEV_MAX_SECURE_ERASE_SECTORS, 1,
176                     [bdev_max_secure_erase_sectors() is available])
177         ],[
178                 AC_MSG_RESULT(no)
180                 AC_MSG_CHECKING([whether blk_queue_secure_erase() is available])
181                 ZFS_LINUX_TEST_RESULT([blk_queue_secure_erase], [
182                         AC_MSG_RESULT(yes)
183                         AC_DEFINE(HAVE_BLK_QUEUE_SECURE_ERASE, 1,
184                             [blk_queue_secure_erase() is available])
185                 ],[
186                         AC_MSG_RESULT(no)
188                         AC_MSG_CHECKING([whether blk_queue_secdiscard() is available])
189                         ZFS_LINUX_TEST_RESULT([blk_queue_secdiscard], [
190                                 AC_MSG_RESULT(yes)
191                         AC_DEFINE(HAVE_BLK_QUEUE_SECDISCARD, 1,
192                                     [blk_queue_secdiscard() is available])
193                         ],[
194                                 ZFS_LINUX_TEST_ERROR([blk_queue_secure_erase])
195                         ])
196                 ])
197         ])
200 dnl #
201 dnl # 4.16 API change,
202 dnl # Introduction of blk_queue_flag_set and blk_queue_flag_clear
203 dnl #
204 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_SET], [
205         ZFS_LINUX_TEST_SRC([blk_queue_flag_set], [
206                 #include <linux/kernel.h>
207                 #include <linux/blkdev.h>
208         ],[
209                 struct request_queue *q = NULL;
210                 blk_queue_flag_set(0, q);
211         ])
214 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_FLAG_SET], [
215         AC_MSG_CHECKING([whether blk_queue_flag_set() exists])
216         ZFS_LINUX_TEST_RESULT([blk_queue_flag_set], [
217                 AC_MSG_RESULT(yes)
218                 AC_DEFINE(HAVE_BLK_QUEUE_FLAG_SET, 1,
219                     [blk_queue_flag_set() exists])
220         ],[
221                 AC_MSG_RESULT(no)
222         ])
225 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_CLEAR], [
226         ZFS_LINUX_TEST_SRC([blk_queue_flag_clear], [
227                 #include <linux/kernel.h>
228                 #include <linux/blkdev.h>
229         ],[
230                 struct request_queue *q = NULL;
231                 blk_queue_flag_clear(0, q);
232         ])
235 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_FLAG_CLEAR], [
236         AC_MSG_CHECKING([whether blk_queue_flag_clear() exists])
237         ZFS_LINUX_TEST_RESULT([blk_queue_flag_clear], [
238                 AC_MSG_RESULT(yes)
239                 AC_DEFINE(HAVE_BLK_QUEUE_FLAG_CLEAR, 1,
240                     [blk_queue_flag_clear() exists])
241         ],[
242                 AC_MSG_RESULT(no)
243         ])
246 dnl #
247 dnl # 2.6.36 API change,
248 dnl # Added blk_queue_flush() interface, while the previous interface
249 dnl # was available to all the new one is GPL-only.  Thus in addition to
250 dnl # detecting if this function is available we determine if it is
251 dnl # GPL-only.  If the GPL-only interface is there we implement our own
252 dnl # compatibility function, otherwise we use the function.  The hope
253 dnl # is that long term this function will be opened up.
254 dnl #
255 dnl # 4.7 API change,
256 dnl # Replace blk_queue_flush with blk_queue_write_cache
257 dnl #
258 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLUSH], [
259         ZFS_LINUX_TEST_SRC([blk_queue_flush], [
260                 #include <linux/blkdev.h>
261         ], [
262                 struct request_queue *q __attribute__ ((unused)) = NULL;
263                 (void) blk_queue_flush(q, REQ_FLUSH);
264         ], [], [ZFS_META_LICENSE])
266         ZFS_LINUX_TEST_SRC([blk_queue_write_cache], [
267                 #include <linux/kernel.h>
268                 #include <linux/blkdev.h>
269         ], [
270                 struct request_queue *q __attribute__ ((unused)) = NULL;
271                 blk_queue_write_cache(q, true, true);
272         ], [], [ZFS_META_LICENSE])
275 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_FLUSH], [
276         AC_MSG_CHECKING([whether blk_queue_flush() is available])
277         ZFS_LINUX_TEST_RESULT([blk_queue_flush], [
278                 AC_MSG_RESULT(yes)
279                 AC_DEFINE(HAVE_BLK_QUEUE_FLUSH, 1,
280                     [blk_queue_flush() is available])
282                 AC_MSG_CHECKING([whether blk_queue_flush() is GPL-only])
283                 ZFS_LINUX_TEST_RESULT([blk_queue_flush_license], [
284                         AC_MSG_RESULT(no)
285                 ],[
286                         AC_MSG_RESULT(yes)
287                         AC_DEFINE(HAVE_BLK_QUEUE_FLUSH_GPL_ONLY, 1,
288                             [blk_queue_flush() is GPL-only])
289                 ])
290         ],[
291                 AC_MSG_RESULT(no)
292         ])
294         dnl #
295         dnl # 4.7 API change
296         dnl # Replace blk_queue_flush with blk_queue_write_cache
297         dnl #
298         AC_MSG_CHECKING([whether blk_queue_write_cache() exists])
299         ZFS_LINUX_TEST_RESULT([blk_queue_write_cache], [
300                 AC_MSG_RESULT(yes)
301                 AC_DEFINE(HAVE_BLK_QUEUE_WRITE_CACHE, 1,
302                     [blk_queue_write_cache() exists])
304                 AC_MSG_CHECKING([whether blk_queue_write_cache() is GPL-only])
305                 ZFS_LINUX_TEST_RESULT([blk_queue_write_cache_license], [
306                         AC_MSG_RESULT(no)
307                 ],[
308                         AC_MSG_RESULT(yes)
309                         AC_DEFINE(HAVE_BLK_QUEUE_WRITE_CACHE_GPL_ONLY, 1,
310                             [blk_queue_write_cache() is GPL-only])
311                 ])
312         ],[
313                 AC_MSG_RESULT(no)
314         ])
317 dnl #
318 dnl # 2.6.34 API change
319 dnl # blk_queue_max_hw_sectors() replaces blk_queue_max_sectors().
320 dnl #
321 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_HW_SECTORS], [
322         ZFS_LINUX_TEST_SRC([blk_queue_max_hw_sectors], [
323                 #include <linux/blkdev.h>
324         ], [
325                 struct request_queue *q __attribute__ ((unused)) = NULL;
326                 (void) blk_queue_max_hw_sectors(q, BLK_SAFE_MAX_SECTORS);
327         ], [])
330 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS], [
331         AC_MSG_CHECKING([whether blk_queue_max_hw_sectors() is available])
332         ZFS_LINUX_TEST_RESULT([blk_queue_max_hw_sectors], [
333                 AC_MSG_RESULT(yes)
334         ],[
335                 ZFS_LINUX_TEST_ERROR([blk_queue_max_hw_sectors])
336         ])
339 dnl #
340 dnl # 2.6.34 API change
341 dnl # blk_queue_max_segments() consolidates blk_queue_max_hw_segments()
342 dnl # and blk_queue_max_phys_segments().
343 dnl #
344 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_SEGMENTS], [
345         ZFS_LINUX_TEST_SRC([blk_queue_max_segments], [
346                 #include <linux/blkdev.h>
347         ], [
348                 struct request_queue *q __attribute__ ((unused)) = NULL;
349                 (void) blk_queue_max_segments(q, BLK_MAX_SEGMENTS);
350         ], [])
353 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS], [
354         AC_MSG_CHECKING([whether blk_queue_max_segments() is available])
355         ZFS_LINUX_TEST_RESULT([blk_queue_max_segments], [
356                 AC_MSG_RESULT(yes)
357         ], [
358                 ZFS_LINUX_TEST_ERROR([blk_queue_max_segments])
359         ])
362 dnl #
363 dnl # See if kernel supports block multi-queue and blk_status_t.
364 dnl # blk_status_t represents the new status codes introduced in the 4.13
365 dnl # kernel patch:
366 dnl #
367 dnl #  block: introduce new block status code type
368 dnl #
369 dnl # We do not currently support the "old" block multi-queue interfaces from
370 dnl # prior kernels.
371 dnl #
372 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_MQ], [
373         ZFS_LINUX_TEST_SRC([blk_mq], [
374                 #include <linux/blk-mq.h>
375         ], [
376                 struct blk_mq_tag_set tag_set __attribute__ ((unused)) = {0};
377                 (void) blk_mq_alloc_tag_set(&tag_set);
378                 return BLK_STS_OK;
379         ], [])
382 AC_DEFUN([ZFS_AC_KERNEL_BLK_MQ], [
383         AC_MSG_CHECKING([whether block multiqueue with blk_status_t is available])
384         ZFS_LINUX_TEST_RESULT([blk_mq], [
385                 AC_MSG_RESULT(yes)
386                 AC_DEFINE(HAVE_BLK_MQ, 1, [block multiqueue is available])
387         ], [
388                 AC_MSG_RESULT(no)
389         ])
392 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE], [
393         ZFS_AC_KERNEL_SRC_BLK_QUEUE_PLUG
394         ZFS_AC_KERNEL_SRC_BLK_QUEUE_BDI
395         ZFS_AC_KERNEL_SRC_BLK_QUEUE_UPDATE_READAHEAD
396         ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD
397         ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE
398         ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_SET
399         ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_CLEAR
400         ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLUSH
401         ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_HW_SECTORS
402         ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_SEGMENTS
403         ZFS_AC_KERNEL_SRC_BLK_MQ
406 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE], [
407         ZFS_AC_KERNEL_BLK_QUEUE_PLUG
408         ZFS_AC_KERNEL_BLK_QUEUE_BDI
409         ZFS_AC_KERNEL_BLK_QUEUE_UPDATE_READAHEAD
410         ZFS_AC_KERNEL_BLK_QUEUE_DISCARD
411         ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE
412         ZFS_AC_KERNEL_BLK_QUEUE_FLAG_SET
413         ZFS_AC_KERNEL_BLK_QUEUE_FLAG_CLEAR
414         ZFS_AC_KERNEL_BLK_QUEUE_FLUSH
415         ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS
416         ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS
417         ZFS_AC_KERNEL_BLK_MQ