ZAP: Add by_dnode variants to lookup/prefetch_uint64
[zfs.git] / config / kernel-blkdev.m4
blob83190c6fbe3f04f3ad92c80ed19eef969af3c2d8
1 dnl #
2 dnl # 2.6.38 API change,
3 dnl # Added blkdev_get_by_path()
4 dnl #
5 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH], [
6         ZFS_LINUX_TEST_SRC([blkdev_get_by_path], [
7                 #include <linux/fs.h>
8                 #include <linux/blkdev.h>
9         ], [
10                 struct block_device *bdev __attribute__ ((unused)) = NULL;
11                 const char *path = "path";
12                 fmode_t mode = 0;
13                 void *holder = NULL;
15                 bdev = blkdev_get_by_path(path, mode, holder);
16         ])
19 dnl #
20 dnl # 6.5.x API change,
21 dnl # blkdev_get_by_path() takes 4 args
22 dnl #
23 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH_4ARG], [
24         ZFS_LINUX_TEST_SRC([blkdev_get_by_path_4arg], [
25                 #include <linux/fs.h>
26                 #include <linux/blkdev.h>
27         ], [
28                 struct block_device *bdev __attribute__ ((unused)) = NULL;
29                 const char *path = "path";
30                 fmode_t mode = 0;
31                 void *holder = NULL;
32                 struct blk_holder_ops h;
34                 bdev = blkdev_get_by_path(path, mode, holder, &h);
35         ])
38 dnl #
39 dnl # 6.8.x API change
40 dnl # bdev_open_by_path() replaces blkdev_get_by_path()
41 dnl #
42 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_OPEN_BY_PATH], [
43         ZFS_LINUX_TEST_SRC([bdev_open_by_path], [
44                 #include <linux/fs.h>
45                 #include <linux/blkdev.h>
46         ], [
47                 struct bdev_handle *bdh __attribute__ ((unused)) = NULL;
48                 const char *path = "path";
49                 fmode_t mode = 0;
50                 void *holder = NULL;
51                 struct blk_holder_ops h;
53                 bdh = bdev_open_by_path(path, mode, holder, &h);
54         ])
57 dnl #
58 dnl # 6.9.x API change
59 dnl # bdev_file_open_by_path() replaced bdev_open_by_path(),
60 dnl # and returns struct file*
61 dnl #
62 AC_DEFUN([ZFS_AC_KERNEL_SRC_BDEV_FILE_OPEN_BY_PATH], [
63         ZFS_LINUX_TEST_SRC([bdev_file_open_by_path], [
64                 #include <linux/fs.h>
65                 #include <linux/blkdev.h>
66         ], [
67                 struct file *file __attribute__ ((unused)) = NULL;
68                 const char *path = "path";
69                 fmode_t mode = 0;
70                 void *holder = NULL;
71                 struct blk_holder_ops h;
73                 file = bdev_file_open_by_path(path, mode, holder, &h);
74         ])
77 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH], [
78         AC_MSG_CHECKING([whether blkdev_get_by_path() exists and takes 3 args])
79         ZFS_LINUX_TEST_RESULT([blkdev_get_by_path], [
80                 AC_MSG_RESULT(yes)
81         ], [
82                 AC_MSG_RESULT(no)
83                 AC_MSG_CHECKING([whether blkdev_get_by_path() exists and takes 4 args])
84                 ZFS_LINUX_TEST_RESULT([blkdev_get_by_path_4arg], [
85                         AC_DEFINE(HAVE_BLKDEV_GET_BY_PATH_4ARG, 1,
86                                 [blkdev_get_by_path() exists and takes 4 args])
87                         AC_MSG_RESULT(yes)
88                 ], [
89                         AC_MSG_RESULT(no)
90                         AC_MSG_CHECKING([whether bdev_open_by_path() exists])
91                         ZFS_LINUX_TEST_RESULT([bdev_open_by_path], [
92                                 AC_DEFINE(HAVE_BDEV_OPEN_BY_PATH, 1,
93                                         [bdev_open_by_path() exists])
94                                 AC_MSG_RESULT(yes)
95                         ], [
96                                 AC_MSG_RESULT(no)
97                                 AC_MSG_CHECKING([whether bdev_file_open_by_path() exists])
98                                 ZFS_LINUX_TEST_RESULT([bdev_file_open_by_path], [
99                                         AC_DEFINE(HAVE_BDEV_FILE_OPEN_BY_PATH, 1,
100                                                 [bdev_file_open_by_path() exists])
101                                         AC_MSG_RESULT(yes)
102                                 ], [
103                                         AC_MSG_RESULT(no)
104                                         ZFS_LINUX_TEST_ERROR([blkdev_get_by_path()])
105                                 ])
106                         ])
107                 ])
108         ])
111 dnl #
112 dnl # 6.5.x API change
113 dnl # blk_mode_t was added as a type to supercede some places where fmode_t
114 dnl # is used
115 dnl #
116 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BLK_MODE_T], [
117         ZFS_LINUX_TEST_SRC([blk_mode_t], [
118                 #include <linux/fs.h>
119                 #include <linux/blkdev.h>
120         ], [
121                 blk_mode_t m __attribute((unused)) = (blk_mode_t)0;
122         ])
125 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BLK_MODE_T], [
126         AC_MSG_CHECKING([whether blk_mode_t is defined])
127         ZFS_LINUX_TEST_RESULT([blk_mode_t], [
128                 AC_MSG_RESULT(yes)
129                 AC_DEFINE(HAVE_BLK_MODE_T, 1, [blk_mode_t is defined])
130         ], [
131                 AC_MSG_RESULT(no)
132         ])
135 dnl #
136 dnl # 2.6.38 API change,
137 dnl # Added blkdev_put()
138 dnl #
139 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_PUT], [
140         ZFS_LINUX_TEST_SRC([blkdev_put], [
141                 #include <linux/fs.h>
142                 #include <linux/blkdev.h>
143         ], [
144                 struct block_device *bdev = NULL;
145                 fmode_t mode = 0;
147                 blkdev_put(bdev, mode);
148         ])
151 dnl #
152 dnl # 6.5.x API change.
153 dnl # blkdev_put() takes (void* holder) as arg 2
154 dnl #
155 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_PUT_HOLDER], [
156         ZFS_LINUX_TEST_SRC([blkdev_put_holder], [
157                 #include <linux/fs.h>
158                 #include <linux/blkdev.h>
159         ], [
160                 struct block_device *bdev = NULL;
161                 void *holder = NULL;
163                 blkdev_put(bdev, holder);
164         ])
167 dnl #
168 dnl # 6.8.x API change
169 dnl # bdev_release() replaces blkdev_put()
170 dnl #
171 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_RELEASE], [
172         ZFS_LINUX_TEST_SRC([bdev_release], [
173                 #include <linux/fs.h>
174                 #include <linux/blkdev.h>
175         ], [
176                 struct bdev_handle *bdh = NULL;
177                 bdev_release(bdh);
178         ])
181 dnl #
182 dnl # 6.9.x API change
183 dnl #
184 dnl # bdev_release() now private, but because bdev_file_open_by_path() returns
185 dnl # struct file*, we can just use fput(). So the blkdev_put test no longer
186 dnl # fails if not found.
187 dnl #
189 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_PUT], [
190         AC_MSG_CHECKING([whether blkdev_put() exists])
191         ZFS_LINUX_TEST_RESULT([blkdev_put], [
192                 AC_MSG_RESULT(yes)
193                 AC_DEFINE(HAVE_BLKDEV_PUT, 1, [blkdev_put() exists])
194         ], [
195                 AC_MSG_RESULT(no)
196                 AC_MSG_CHECKING([whether blkdev_put() accepts void* as arg 2])
197                 ZFS_LINUX_TEST_RESULT([blkdev_put_holder], [
198                         AC_MSG_RESULT(yes)
199                         AC_DEFINE(HAVE_BLKDEV_PUT_HOLDER, 1,
200                                 [blkdev_put() accepts void* as arg 2])
201                 ], [
202                         AC_MSG_RESULT(no)
203                         AC_MSG_CHECKING([whether bdev_release() exists])
204                         ZFS_LINUX_TEST_RESULT([bdev_release], [
205                                 AC_MSG_RESULT(yes)
206                                 AC_DEFINE(HAVE_BDEV_RELEASE, 1,
207                                         [bdev_release() exists])
208                         ], [
209                                 AC_MSG_RESULT(no)
210                         ])
211                 ])
212         ])
215 dnl #
216 dnl # 4.1 API, exported blkdev_reread_part() symbol, back ported to the
217 dnl # 3.10.0 CentOS 7.x enterprise kernels.
218 dnl #
219 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_REREAD_PART], [
220         ZFS_LINUX_TEST_SRC([blkdev_reread_part], [
221                 #include <linux/fs.h>
222                 #include <linux/blkdev.h>
223         ], [
224                 struct block_device *bdev = NULL;
225                 int error;
227                 error = blkdev_reread_part(bdev);
228         ])
231 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_REREAD_PART], [
232         AC_MSG_CHECKING([whether blkdev_reread_part() exists])
233         ZFS_LINUX_TEST_RESULT([blkdev_reread_part], [
234                 AC_MSG_RESULT(yes)
235                 AC_DEFINE(HAVE_BLKDEV_REREAD_PART, 1,
236                     [blkdev_reread_part() exists])
237         ], [
238                 AC_MSG_RESULT(no)
239         ])
242 dnl #
243 dnl # check_disk_change() was removed in 5.10
244 dnl #
245 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_CHECK_DISK_CHANGE], [
246         ZFS_LINUX_TEST_SRC([check_disk_change], [
247                 #include <linux/fs.h>
248                 #include <linux/blkdev.h>
249         ], [
250                 struct block_device *bdev = NULL;
251                 bool error;
253                 error = check_disk_change(bdev);
254         ])
257 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_CHECK_DISK_CHANGE], [
258         AC_MSG_CHECKING([whether check_disk_change() exists])
259         ZFS_LINUX_TEST_RESULT([check_disk_change], [
260                 AC_MSG_RESULT(yes)
261                 AC_DEFINE(HAVE_CHECK_DISK_CHANGE, 1,
262                     [check_disk_change() exists])
263         ], [
264                 AC_MSG_RESULT(no)
265         ])
268 dnl #
269 dnl # 6.5.x API change
270 dnl # disk_check_media_change() was added
271 dnl #
272 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_DISK_CHECK_MEDIA_CHANGE], [
273         ZFS_LINUX_TEST_SRC([disk_check_media_change], [
274                 #include <linux/fs.h>
275                 #include <linux/blkdev.h>
276         ], [
277                 struct block_device *bdev = NULL;
278                 bool error;
280                 error = disk_check_media_change(bdev->bd_disk);
281         ])
284 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_DISK_CHECK_MEDIA_CHANGE], [
285         AC_MSG_CHECKING([whether disk_check_media_change() exists])
286         ZFS_LINUX_TEST_RESULT([disk_check_media_change], [
287                 AC_MSG_RESULT(yes)
288                 AC_DEFINE(HAVE_DISK_CHECK_MEDIA_CHANGE, 1,
289                     [disk_check_media_change() exists])
290         ], [
291                 AC_MSG_RESULT(no)
292         ])
295 dnl #
296 dnl # bdev_kobj() is introduced from 5.12
297 dnl #
298 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_KOBJ], [
299         ZFS_LINUX_TEST_SRC([bdev_kobj], [
300                 #include <linux/fs.h>
301                 #include <linux/blkdev.h>
302                 #include <linux/kobject.h>
303         ], [
304                 struct block_device *bdev = NULL;
305                 struct kobject *disk_kobj;
306                 disk_kobj = bdev_kobj(bdev);
307         ])
310 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_KOBJ], [
311         AC_MSG_CHECKING([whether bdev_kobj() exists])
312         ZFS_LINUX_TEST_RESULT([bdev_kobj], [
313                 AC_MSG_RESULT(yes)
314                 AC_DEFINE(HAVE_BDEV_KOBJ, 1,
315                     [bdev_kobj() exists])
316         ], [
317                 AC_MSG_RESULT(no)
318         ])
321 dnl #
322 dnl # part_to_dev() was removed in 5.12
323 dnl #
324 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_PART_TO_DEV], [
325         ZFS_LINUX_TEST_SRC([part_to_dev], [
326                 #include <linux/fs.h>
327                 #include <linux/blkdev.h>
328         ], [
329                 struct hd_struct *p = NULL;
330                 struct device *pdev;
331                 pdev = part_to_dev(p);
332         ])
335 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_PART_TO_DEV], [
336         AC_MSG_CHECKING([whether part_to_dev() exists])
337         ZFS_LINUX_TEST_RESULT([part_to_dev], [
338                 AC_MSG_RESULT(yes)
339                 AC_DEFINE(HAVE_PART_TO_DEV, 1,
340                     [part_to_dev() exists])
341         ], [
342                 AC_MSG_RESULT(no)
343         ])
346 dnl #
347 dnl # 5.10 API, check_disk_change() is removed, in favor of
348 dnl # bdev_check_media_change(), which doesn't force revalidation
349 dnl #
350 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_CHECK_MEDIA_CHANGE], [
351         ZFS_LINUX_TEST_SRC([bdev_check_media_change], [
352                 #include <linux/fs.h>
353                 #include <linux/blkdev.h>
354         ], [
355                 struct block_device *bdev = NULL;
356                 int error;
358                 error = bdev_check_media_change(bdev);
359         ])
362 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_CHECK_MEDIA_CHANGE], [
363         AC_MSG_CHECKING([whether bdev_check_media_change() exists])
364         ZFS_LINUX_TEST_RESULT([bdev_check_media_change], [
365                 AC_MSG_RESULT(yes)
366                 AC_DEFINE(HAVE_BDEV_CHECK_MEDIA_CHANGE, 1,
367                     [bdev_check_media_change() exists])
368         ], [
369                 AC_MSG_RESULT(no)
370         ])
373 dnl #
374 dnl # 2.6.22 API change
375 dnl # Single argument invalidate_bdev()
376 dnl #
377 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_INVALIDATE_BDEV], [
378         ZFS_LINUX_TEST_SRC([invalidate_bdev], [
379                 #include <linux/buffer_head.h>
380                 #include <linux/blkdev.h>
381         ],[
382                 struct block_device *bdev = NULL;
383                 invalidate_bdev(bdev);
384         ])
387 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_INVALIDATE_BDEV], [
388         AC_MSG_CHECKING([whether invalidate_bdev() exists])
389         ZFS_LINUX_TEST_RESULT([invalidate_bdev], [
390                 AC_MSG_RESULT(yes)
391         ],[
392                 ZFS_LINUX_TEST_ERROR([invalidate_bdev()])
393         ])
396 dnl #
397 dnl # 5.11 API, lookup_bdev() takes dev_t argument.
398 dnl # 2.6.27 API, lookup_bdev() was first exported.
399 dnl #
400 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_LOOKUP_BDEV], [
401         ZFS_LINUX_TEST_SRC([lookup_bdev_devt], [
402                 #include <linux/blkdev.h>
403         ], [
404                 int error __attribute__ ((unused));
405                 const char path[] = "/example/path";
406                 dev_t dev;
408                 error = lookup_bdev(path, &dev);
409         ])
411         ZFS_LINUX_TEST_SRC([lookup_bdev_1arg], [
412                 #include <linux/fs.h>
413                 #include <linux/blkdev.h>
414         ], [
415                 struct block_device *bdev __attribute__ ((unused));
416                 const char path[] = "/example/path";
418                 bdev = lookup_bdev(path);
419         ])
422 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_LOOKUP_BDEV], [
423         AC_MSG_CHECKING([whether lookup_bdev() wants dev_t arg])
424         ZFS_LINUX_TEST_RESULT_SYMBOL([lookup_bdev_devt],
425             [lookup_bdev], [fs/block_dev.c], [
426                 AC_MSG_RESULT(yes)
427                 AC_DEFINE(HAVE_DEVT_LOOKUP_BDEV, 1,
428                     [lookup_bdev() wants dev_t arg])
429         ], [
430                 AC_MSG_RESULT(no)
432                 AC_MSG_CHECKING([whether lookup_bdev() wants 1 arg])
433                 ZFS_LINUX_TEST_RESULT_SYMBOL([lookup_bdev_1arg],
434                     [lookup_bdev], [fs/block_dev.c], [
435                         AC_MSG_RESULT(yes)
436                         AC_DEFINE(HAVE_1ARG_LOOKUP_BDEV, 1,
437                             [lookup_bdev() wants 1 arg])
438                 ], [
439                         ZFS_LINUX_TEST_ERROR([lookup_bdev()])
440                 ])
441         ])
444 dnl #
445 dnl # 2.6.30 API change
446 dnl #
447 dnl # The bdev_physical_block_size() interface was added to provide a way
448 dnl # to determine the smallest write which can be performed without a
449 dnl # read-modify-write operation.
450 dnl #
451 dnl # Unfortunately, this interface isn't entirely reliable because
452 dnl # drives are sometimes known to misreport this value.
453 dnl #
454 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE], [
455         ZFS_LINUX_TEST_SRC([bdev_physical_block_size], [
456                 #include <linux/blkdev.h>
457         ],[
458                 struct block_device *bdev __attribute__ ((unused)) = NULL;
459                 bdev_physical_block_size(bdev);
460         ])
463 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE], [
464         AC_MSG_CHECKING([whether bdev_physical_block_size() is available])
465         ZFS_LINUX_TEST_RESULT([bdev_physical_block_size], [
466                 AC_MSG_RESULT(yes)
467         ],[
468                 ZFS_LINUX_TEST_ERROR([bdev_physical_block_size()])
469         ])
472 dnl #
473 dnl # 2.6.30 API change
474 dnl # Added bdev_logical_block_size().
475 dnl #
476 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE], [
477         ZFS_LINUX_TEST_SRC([bdev_logical_block_size], [
478                 #include <linux/blkdev.h>
479         ],[
480                 struct block_device *bdev __attribute__ ((unused)) = NULL;
481                 bdev_logical_block_size(bdev);
482         ])
485 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE], [
486         AC_MSG_CHECKING([whether bdev_logical_block_size() is available])
487         ZFS_LINUX_TEST_RESULT([bdev_logical_block_size], [
488                 AC_MSG_RESULT(yes)
489         ],[
490                 ZFS_LINUX_TEST_ERROR([bdev_logical_block_size()])
491         ])
494 dnl #
495 dnl # 5.11 API change
496 dnl # Added bdev_whole() helper.
497 dnl #
498 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_WHOLE], [
499         ZFS_LINUX_TEST_SRC([bdev_whole], [
500                 #include <linux/blkdev.h>
501         ],[
502                 struct block_device *bdev = NULL;
503                 bdev = bdev_whole(bdev);
504         ])
507 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE], [
508         AC_MSG_CHECKING([whether bdev_whole() is available])
509         ZFS_LINUX_TEST_RESULT([bdev_whole], [
510                 AC_MSG_RESULT(yes)
511                 AC_DEFINE(HAVE_BDEV_WHOLE, 1, [bdev_whole() is available])
512         ],[
513                 AC_MSG_RESULT(no)
514         ])
517 dnl #
518 dnl # 5.16 API change
519 dnl # Added bdev_nr_bytes() helper.
520 dnl #
521 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_NR_BYTES], [
522         ZFS_LINUX_TEST_SRC([bdev_nr_bytes], [
523                 #include <linux/blkdev.h>
524         ],[
525                 struct block_device *bdev = NULL;
526                 loff_t nr_bytes __attribute__ ((unused)) = 0;
527                 nr_bytes = bdev_nr_bytes(bdev);
528         ])
531 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_NR_BYTES], [
532         AC_MSG_CHECKING([whether bdev_nr_bytes() is available])
533         ZFS_LINUX_TEST_RESULT([bdev_nr_bytes], [
534                 AC_MSG_RESULT(yes)
535                 AC_DEFINE(HAVE_BDEV_NR_BYTES, 1, [bdev_nr_bytes() is available])
536         ],[
537                 AC_MSG_RESULT(no)
538         ])
541 dnl #
542 dnl # 5.20 API change,
543 dnl # Removed bdevname(), snprintf(.., %pg) should be used.
544 dnl #
545 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEVNAME], [
546         ZFS_LINUX_TEST_SRC([bdevname], [
547                 #include <linux/fs.h>
548                 #include <linux/blkdev.h>
549         ], [
550                 struct block_device *bdev __attribute__ ((unused)) = NULL;
551                 char path[BDEVNAME_SIZE];
553                 (void) bdevname(bdev, path);
554         ])
557 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEVNAME], [
558         AC_MSG_CHECKING([whether bdevname() exists])
559         ZFS_LINUX_TEST_RESULT([bdevname], [
560                 AC_DEFINE(HAVE_BDEVNAME, 1, [bdevname() is available])
561                 AC_MSG_RESULT(yes)
562         ], [
563                 AC_MSG_RESULT(no)
564         ])
567 dnl #
568 dnl # TRIM support: discard and secure erase. We make use of asynchronous
569 dnl #               functions when available.
570 dnl #
571 dnl # 3.10:
572 dnl #   sync discard:  blkdev_issue_discard(..., 0)
573 dnl #   sync erase:    blkdev_issue_discard(..., BLKDEV_DISCARD_SECURE)
574 dnl #   async discard: [not available]
575 dnl #   async erase:   [not available]
576 dnl #
577 dnl # 4.7:
578 dnl #   sync discard:  blkdev_issue_discard(..., 0)
579 dnl #   sync erase:    blkdev_issue_discard(..., BLKDEV_DISCARD_SECURE)
580 dnl #   async discard: __blkdev_issue_discard(..., 0)
581 dnl #   async erase:   __blkdev_issue_discard(..., BLKDEV_DISCARD_SECURE)
582 dnl #
583 dnl # 5.19:
584 dnl #   sync discard:  blkdev_issue_discard(...)
585 dnl #   sync erase:    blkdev_issue_secure_erase(...)
586 dnl #   async discard: __blkdev_issue_discard(...)
587 dnl #   async erase:   [not available]
588 dnl #
589 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_ISSUE_DISCARD], [
590         ZFS_LINUX_TEST_SRC([blkdev_issue_discard_noflags], [
591                 #include <linux/blkdev.h>
592         ],[
593                 struct block_device *bdev = NULL;
594                 sector_t sector = 0;
595                 sector_t nr_sects = 0;
596                 int error __attribute__ ((unused));
598                 error = blkdev_issue_discard(bdev,
599                     sector, nr_sects, GFP_KERNEL);
600         ])
601         ZFS_LINUX_TEST_SRC([blkdev_issue_discard_flags], [
602                 #include <linux/blkdev.h>
603         ],[
604                 struct block_device *bdev = NULL;
605                 sector_t sector = 0;
606                 sector_t nr_sects = 0;
607                 unsigned long flags = 0;
608                 int error __attribute__ ((unused));
610                 error = blkdev_issue_discard(bdev,
611                     sector, nr_sects, GFP_KERNEL, flags);
612         ])
613         ZFS_LINUX_TEST_SRC([blkdev_issue_discard_async_noflags], [
614                 #include <linux/blkdev.h>
615         ],[
616                 struct block_device *bdev = NULL;
617                 sector_t sector = 0;
618                 sector_t nr_sects = 0;
619                 struct bio *biop = NULL;
620                 int error __attribute__ ((unused));
622                 error = __blkdev_issue_discard(bdev,
623                     sector, nr_sects, GFP_KERNEL, &biop);
624         ])
625         ZFS_LINUX_TEST_SRC([blkdev_issue_discard_async_flags], [
626                 #include <linux/blkdev.h>
627         ],[
628                 struct block_device *bdev = NULL;
629                 sector_t sector = 0;
630                 sector_t nr_sects = 0;
631                 unsigned long flags = 0;
632                 struct bio *biop = NULL;
633                 int error __attribute__ ((unused));
635                 error = __blkdev_issue_discard(bdev,
636                     sector, nr_sects, GFP_KERNEL, flags, &biop);
637         ])
638         ZFS_LINUX_TEST_SRC([blkdev_issue_secure_erase], [
639                 #include <linux/blkdev.h>
640         ],[
641                 struct block_device *bdev = NULL;
642                 sector_t sector = 0;
643                 sector_t nr_sects = 0;
644                 int error __attribute__ ((unused));
646                 error = blkdev_issue_secure_erase(bdev,
647                     sector, nr_sects, GFP_KERNEL);
648         ])
651 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_ISSUE_DISCARD], [
652         AC_MSG_CHECKING([whether blkdev_issue_discard() is available])
653         ZFS_LINUX_TEST_RESULT([blkdev_issue_discard_noflags], [
654                 AC_MSG_RESULT(yes)
655                 AC_DEFINE(HAVE_BLKDEV_ISSUE_DISCARD_NOFLAGS, 1,
656                     [blkdev_issue_discard() is available])
657         ],[
658                 AC_MSG_RESULT(no)
659         ])
660         AC_MSG_CHECKING([whether blkdev_issue_discard(flags) is available])
661         ZFS_LINUX_TEST_RESULT([blkdev_issue_discard_flags], [
662                 AC_MSG_RESULT(yes)
663                 AC_DEFINE(HAVE_BLKDEV_ISSUE_DISCARD_FLAGS, 1,
664                     [blkdev_issue_discard(flags) is available])
665         ],[
666                 AC_MSG_RESULT(no)
667         ])
668         AC_MSG_CHECKING([whether __blkdev_issue_discard() is available])
669         ZFS_LINUX_TEST_RESULT([blkdev_issue_discard_async_noflags], [
670                 AC_MSG_RESULT(yes)
671                 AC_DEFINE(HAVE_BLKDEV_ISSUE_DISCARD_ASYNC_NOFLAGS, 1,
672                     [__blkdev_issue_discard() is available])
673         ],[
674                 AC_MSG_RESULT(no)
675         ])
676         AC_MSG_CHECKING([whether __blkdev_issue_discard(flags) is available])
677         ZFS_LINUX_TEST_RESULT([blkdev_issue_discard_async_flags], [
678                 AC_MSG_RESULT(yes)
679                 AC_DEFINE(HAVE_BLKDEV_ISSUE_DISCARD_ASYNC_FLAGS, 1,
680                     [__blkdev_issue_discard(flags) is available])
681         ],[
682                 AC_MSG_RESULT(no)
683         ])
684         AC_MSG_CHECKING([whether blkdev_issue_secure_erase() is available])
685         ZFS_LINUX_TEST_RESULT([blkdev_issue_secure_erase], [
686                 AC_MSG_RESULT(yes)
687                 AC_DEFINE(HAVE_BLKDEV_ISSUE_SECURE_ERASE, 1,
688                     [blkdev_issue_secure_erase() is available])
689         ],[
690                 AC_MSG_RESULT(no)
691         ])
694 dnl #
695 dnl # 5.13 API change
696 dnl # blkdev_get_by_path() no longer handles ERESTARTSYS
697 dnl #
698 dnl # Unfortunately we're forced to rely solely on the kernel version
699 dnl # number in order to determine the expected behavior.  This was an
700 dnl # internal change to blkdev_get_by_dev(), see commit a8ed1a0607.
701 dnl #
702 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_ERESTARTSYS], [
703         AC_MSG_CHECKING([whether blkdev_get_by_path() handles ERESTARTSYS])
704         AS_VERSION_COMPARE([$LINUX_VERSION], [5.13.0], [
705                 AC_MSG_RESULT(yes)
706                 AC_DEFINE(HAVE_BLKDEV_GET_ERESTARTSYS, 1,
707                         [blkdev_get_by_path() handles ERESTARTSYS])
708         ],[
709                 AC_MSG_RESULT(no)
710         ],[
711                 AC_MSG_RESULT(no)
712         ])
715 dnl #
716 dnl # 6.5.x API change
717 dnl # BLK_STS_NEXUS replaced with BLK_STS_RESV_CONFLICT
718 dnl #
719 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BLK_STS_RESV_CONFLICT], [
720         ZFS_LINUX_TEST_SRC([blk_sts_resv_conflict], [
721                 #include <linux/blkdev.h>
722         ],[
723                 blk_status_t s __attribute__ ((unused)) = BLK_STS_RESV_CONFLICT;
724         ])
727 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BLK_STS_RESV_CONFLICT], [
728         AC_MSG_CHECKING([whether BLK_STS_RESV_CONFLICT is defined])
729                 ZFS_LINUX_TEST_RESULT([blk_sts_resv_conflict], [
730                         AC_DEFINE(HAVE_BLK_STS_RESV_CONFLICT, 1, [BLK_STS_RESV_CONFLICT is defined])
731                         AC_MSG_RESULT(yes)
732                 ], [
733                         AC_MSG_RESULT(no)
734                 ])
735         ])
738 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV], [
739         ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH
740         ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH_4ARG
741         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_OPEN_BY_PATH
742         ZFS_AC_KERNEL_SRC_BDEV_FILE_OPEN_BY_PATH
743         ZFS_AC_KERNEL_SRC_BLKDEV_PUT
744         ZFS_AC_KERNEL_SRC_BLKDEV_PUT_HOLDER
745         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_RELEASE
746         ZFS_AC_KERNEL_SRC_BLKDEV_REREAD_PART
747         ZFS_AC_KERNEL_SRC_BLKDEV_INVALIDATE_BDEV
748         ZFS_AC_KERNEL_SRC_BLKDEV_LOOKUP_BDEV
749         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE
750         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE
751         ZFS_AC_KERNEL_SRC_BLKDEV_CHECK_DISK_CHANGE
752         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_CHECK_MEDIA_CHANGE
753         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_WHOLE
754         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_NR_BYTES
755         ZFS_AC_KERNEL_SRC_BLKDEV_BDEVNAME
756         ZFS_AC_KERNEL_SRC_BLKDEV_ISSUE_DISCARD
757         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_KOBJ
758         ZFS_AC_KERNEL_SRC_BLKDEV_PART_TO_DEV
759         ZFS_AC_KERNEL_SRC_BLKDEV_DISK_CHECK_MEDIA_CHANGE
760         ZFS_AC_KERNEL_SRC_BLKDEV_BLK_STS_RESV_CONFLICT
761         ZFS_AC_KERNEL_SRC_BLKDEV_BLK_MODE_T
764 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV], [
765         ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH
766         ZFS_AC_KERNEL_BLKDEV_PUT
767         ZFS_AC_KERNEL_BLKDEV_REREAD_PART
768         ZFS_AC_KERNEL_BLKDEV_INVALIDATE_BDEV
769         ZFS_AC_KERNEL_BLKDEV_LOOKUP_BDEV
770         ZFS_AC_KERNEL_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE
771         ZFS_AC_KERNEL_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE
772         ZFS_AC_KERNEL_BLKDEV_CHECK_DISK_CHANGE
773         ZFS_AC_KERNEL_BLKDEV_BDEV_CHECK_MEDIA_CHANGE
774         ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE
775         ZFS_AC_KERNEL_BLKDEV_BDEV_NR_BYTES
776         ZFS_AC_KERNEL_BLKDEV_BDEVNAME
777         ZFS_AC_KERNEL_BLKDEV_GET_ERESTARTSYS
778         ZFS_AC_KERNEL_BLKDEV_ISSUE_DISCARD
779         ZFS_AC_KERNEL_BLKDEV_BDEV_KOBJ
780         ZFS_AC_KERNEL_BLKDEV_PART_TO_DEV
781         ZFS_AC_KERNEL_BLKDEV_DISK_CHECK_MEDIA_CHANGE
782         ZFS_AC_KERNEL_BLKDEV_BLK_STS_RESV_CONFLICT
783         ZFS_AC_KERNEL_BLKDEV_BLK_MODE_T