zdb: Fix false leak report for BRT objects
[zfs.git] / config / kernel-blkdev.m4
blobc5a353ca92035d4f118aecacc7c7f3f8a9990ec6
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 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH], [
58         AC_MSG_CHECKING([whether blkdev_get_by_path() exists and takes 3 args])
59         ZFS_LINUX_TEST_RESULT([blkdev_get_by_path], [
60                 AC_MSG_RESULT(yes)
61         ], [
62                 AC_MSG_RESULT(no)
63                 AC_MSG_CHECKING([whether blkdev_get_by_path() exists and takes 4 args])
64                 ZFS_LINUX_TEST_RESULT([blkdev_get_by_path_4arg], [
65                         AC_DEFINE(HAVE_BLKDEV_GET_BY_PATH_4ARG, 1,
66                                 [blkdev_get_by_path() exists and takes 4 args])
67                         AC_MSG_RESULT(yes)
68                 ], [
69                         AC_MSG_RESULT(no)
70                         AC_MSG_CHECKING([whether bdev_open_by_path() exists])
71                         ZFS_LINUX_TEST_RESULT([bdev_open_by_path], [
72                                 AC_DEFINE(HAVE_BDEV_OPEN_BY_PATH, 1,
73                                         [bdev_open_by_path() exists])
74                                 AC_MSG_RESULT(yes)
75                         ], [
76                                 ZFS_LINUX_TEST_ERROR([blkdev_get_by_path()])
77                         ])
78                 ])
79         ])
82 dnl #
83 dnl # 6.5.x API change
84 dnl # blk_mode_t was added as a type to supercede some places where fmode_t
85 dnl # is used
86 dnl #
87 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BLK_MODE_T], [
88         ZFS_LINUX_TEST_SRC([blk_mode_t], [
89                 #include <linux/fs.h>
90                 #include <linux/blkdev.h>
91         ], [
92                 blk_mode_t m __attribute((unused)) = (blk_mode_t)0;
93         ])
96 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BLK_MODE_T], [
97         AC_MSG_CHECKING([whether blk_mode_t is defined])
98         ZFS_LINUX_TEST_RESULT([blk_mode_t], [
99                 AC_MSG_RESULT(yes)
100                 AC_DEFINE(HAVE_BLK_MODE_T, 1, [blk_mode_t is defined])
101         ], [
102                 AC_MSG_RESULT(no)
103         ])
106 dnl #
107 dnl # 2.6.38 API change,
108 dnl # Added blkdev_put()
109 dnl #
110 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_PUT], [
111         ZFS_LINUX_TEST_SRC([blkdev_put], [
112                 #include <linux/fs.h>
113                 #include <linux/blkdev.h>
114         ], [
115                 struct block_device *bdev = NULL;
116                 fmode_t mode = 0;
118                 blkdev_put(bdev, mode);
119         ])
122 dnl #
123 dnl # 6.5.x API change.
124 dnl # blkdev_put() takes (void* holder) as arg 2
125 dnl #
126 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_PUT_HOLDER], [
127         ZFS_LINUX_TEST_SRC([blkdev_put_holder], [
128                 #include <linux/fs.h>
129                 #include <linux/blkdev.h>
130         ], [
131                 struct block_device *bdev = NULL;
132                 void *holder = NULL;
134                 blkdev_put(bdev, holder);
135         ])
138 dnl #
139 dnl # 6.8.x API change
140 dnl # bdev_release() replaces blkdev_put()
141 dnl #
142 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_RELEASE], [
143         ZFS_LINUX_TEST_SRC([bdev_release], [
144                 #include <linux/fs.h>
145                 #include <linux/blkdev.h>
146         ], [
147                 struct bdev_handle *bdh = NULL;
148                 bdev_release(bdh);
149         ])
152 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_PUT], [
153         AC_MSG_CHECKING([whether blkdev_put() exists])
154         ZFS_LINUX_TEST_RESULT([blkdev_put], [
155                 AC_MSG_RESULT(yes)
156         ], [
157                 AC_MSG_RESULT(no)
158                 AC_MSG_CHECKING([whether blkdev_put() accepts void* as arg 2])
159                 ZFS_LINUX_TEST_RESULT([blkdev_put_holder], [
160                         AC_MSG_RESULT(yes)
161                         AC_DEFINE(HAVE_BLKDEV_PUT_HOLDER, 1,
162                                 [blkdev_put() accepts void* as arg 2])
163                 ], [
164                         AC_MSG_RESULT(no)
165                         AC_MSG_CHECKING([whether bdev_release() exists])
166                         ZFS_LINUX_TEST_RESULT([bdev_release], [
167                                 AC_MSG_RESULT(yes)
168                                 AC_DEFINE(HAVE_BDEV_RELEASE, 1,
169                                         [bdev_release() exists])
170                         ], [
171                                 ZFS_LINUX_TEST_ERROR([blkdev_put()])
172                         ])
173                 ])
174         ])
177 dnl #
178 dnl # 4.1 API, exported blkdev_reread_part() symbol, back ported to the
179 dnl # 3.10.0 CentOS 7.x enterprise kernels.
180 dnl #
181 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_REREAD_PART], [
182         ZFS_LINUX_TEST_SRC([blkdev_reread_part], [
183                 #include <linux/fs.h>
184                 #include <linux/blkdev.h>
185         ], [
186                 struct block_device *bdev = NULL;
187                 int error;
189                 error = blkdev_reread_part(bdev);
190         ])
193 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_REREAD_PART], [
194         AC_MSG_CHECKING([whether blkdev_reread_part() exists])
195         ZFS_LINUX_TEST_RESULT([blkdev_reread_part], [
196                 AC_MSG_RESULT(yes)
197                 AC_DEFINE(HAVE_BLKDEV_REREAD_PART, 1,
198                     [blkdev_reread_part() exists])
199         ], [
200                 AC_MSG_RESULT(no)
201         ])
204 dnl #
205 dnl # check_disk_change() was removed in 5.10
206 dnl #
207 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_CHECK_DISK_CHANGE], [
208         ZFS_LINUX_TEST_SRC([check_disk_change], [
209                 #include <linux/fs.h>
210                 #include <linux/blkdev.h>
211         ], [
212                 struct block_device *bdev = NULL;
213                 bool error;
215                 error = check_disk_change(bdev);
216         ])
219 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_CHECK_DISK_CHANGE], [
220         AC_MSG_CHECKING([whether check_disk_change() exists])
221         ZFS_LINUX_TEST_RESULT([check_disk_change], [
222                 AC_MSG_RESULT(yes)
223                 AC_DEFINE(HAVE_CHECK_DISK_CHANGE, 1,
224                     [check_disk_change() exists])
225         ], [
226                 AC_MSG_RESULT(no)
227         ])
230 dnl #
231 dnl # 6.5.x API change
232 dnl # disk_check_media_change() was added
233 dnl #
234 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_DISK_CHECK_MEDIA_CHANGE], [
235         ZFS_LINUX_TEST_SRC([disk_check_media_change], [
236                 #include <linux/fs.h>
237                 #include <linux/blkdev.h>
238         ], [
239                 struct block_device *bdev = NULL;
240                 bool error;
242                 error = disk_check_media_change(bdev->bd_disk);
243         ])
246 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_DISK_CHECK_MEDIA_CHANGE], [
247         AC_MSG_CHECKING([whether disk_check_media_change() exists])
248         ZFS_LINUX_TEST_RESULT([disk_check_media_change], [
249                 AC_MSG_RESULT(yes)
250                 AC_DEFINE(HAVE_DISK_CHECK_MEDIA_CHANGE, 1,
251                     [disk_check_media_change() exists])
252         ], [
253                 AC_MSG_RESULT(no)
254         ])
257 dnl #
258 dnl # bdev_kobj() is introduced from 5.12
259 dnl #
260 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_KOBJ], [
261         ZFS_LINUX_TEST_SRC([bdev_kobj], [
262                 #include <linux/fs.h>
263                 #include <linux/blkdev.h>
264                 #include <linux/kobject.h>
265         ], [
266                 struct block_device *bdev = NULL;
267                 struct kobject *disk_kobj;
268                 disk_kobj = bdev_kobj(bdev);
269         ])
272 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_KOBJ], [
273         AC_MSG_CHECKING([whether bdev_kobj() exists])
274         ZFS_LINUX_TEST_RESULT([bdev_kobj], [
275                 AC_MSG_RESULT(yes)
276                 AC_DEFINE(HAVE_BDEV_KOBJ, 1,
277                     [bdev_kobj() exists])
278         ], [
279                 AC_MSG_RESULT(no)
280         ])
283 dnl #
284 dnl # part_to_dev() was removed in 5.12
285 dnl #
286 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_PART_TO_DEV], [
287         ZFS_LINUX_TEST_SRC([part_to_dev], [
288                 #include <linux/fs.h>
289                 #include <linux/blkdev.h>
290         ], [
291                 struct hd_struct *p = NULL;
292                 struct device *pdev;
293                 pdev = part_to_dev(p);
294         ])
297 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_PART_TO_DEV], [
298         AC_MSG_CHECKING([whether part_to_dev() exists])
299         ZFS_LINUX_TEST_RESULT([part_to_dev], [
300                 AC_MSG_RESULT(yes)
301                 AC_DEFINE(HAVE_PART_TO_DEV, 1,
302                     [part_to_dev() exists])
303         ], [
304                 AC_MSG_RESULT(no)
305         ])
308 dnl #
309 dnl # 5.10 API, check_disk_change() is removed, in favor of
310 dnl # bdev_check_media_change(), which doesn't force revalidation
311 dnl #
312 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_CHECK_MEDIA_CHANGE], [
313         ZFS_LINUX_TEST_SRC([bdev_check_media_change], [
314                 #include <linux/fs.h>
315                 #include <linux/blkdev.h>
316         ], [
317                 struct block_device *bdev = NULL;
318                 int error;
320                 error = bdev_check_media_change(bdev);
321         ])
324 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_CHECK_MEDIA_CHANGE], [
325         AC_MSG_CHECKING([whether bdev_check_media_change() exists])
326         ZFS_LINUX_TEST_RESULT([bdev_check_media_change], [
327                 AC_MSG_RESULT(yes)
328                 AC_DEFINE(HAVE_BDEV_CHECK_MEDIA_CHANGE, 1,
329                     [bdev_check_media_change() exists])
330         ], [
331                 AC_MSG_RESULT(no)
332         ])
335 dnl #
336 dnl # 2.6.22 API change
337 dnl # Single argument invalidate_bdev()
338 dnl #
339 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_INVALIDATE_BDEV], [
340         ZFS_LINUX_TEST_SRC([invalidate_bdev], [
341                 #include <linux/buffer_head.h>
342                 #include <linux/blkdev.h>
343         ],[
344                 struct block_device *bdev = NULL;
345                 invalidate_bdev(bdev);
346         ])
349 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_INVALIDATE_BDEV], [
350         AC_MSG_CHECKING([whether invalidate_bdev() exists])
351         ZFS_LINUX_TEST_RESULT([invalidate_bdev], [
352                 AC_MSG_RESULT(yes)
353         ],[
354                 ZFS_LINUX_TEST_ERROR([invalidate_bdev()])
355         ])
358 dnl #
359 dnl # 5.11 API, lookup_bdev() takes dev_t argument.
360 dnl # 2.6.27 API, lookup_bdev() was first exported.
361 dnl # 4.4.0-6.21 API, lookup_bdev() on Ubuntu takes mode argument.
362 dnl #
363 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_LOOKUP_BDEV], [
364         ZFS_LINUX_TEST_SRC([lookup_bdev_devt], [
365                 #include <linux/blkdev.h>
366         ], [
367                 int error __attribute__ ((unused));
368                 const char path[] = "/example/path";
369                 dev_t dev;
371                 error = lookup_bdev(path, &dev);
372         ])
374         ZFS_LINUX_TEST_SRC([lookup_bdev_1arg], [
375                 #include <linux/fs.h>
376                 #include <linux/blkdev.h>
377         ], [
378                 struct block_device *bdev __attribute__ ((unused));
379                 const char path[] = "/example/path";
381                 bdev = lookup_bdev(path);
382         ])
384         ZFS_LINUX_TEST_SRC([lookup_bdev_mode], [
385                 #include <linux/fs.h>
386         ], [
387                 struct block_device *bdev __attribute__ ((unused));
388                 const char path[] = "/example/path";
390                 bdev = lookup_bdev(path, FMODE_READ);
391         ])
394 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_LOOKUP_BDEV], [
395         AC_MSG_CHECKING([whether lookup_bdev() wants dev_t arg])
396         ZFS_LINUX_TEST_RESULT_SYMBOL([lookup_bdev_devt],
397             [lookup_bdev], [fs/block_dev.c], [
398                 AC_MSG_RESULT(yes)
399                 AC_DEFINE(HAVE_DEVT_LOOKUP_BDEV, 1,
400                     [lookup_bdev() wants dev_t arg])
401         ], [
402                 AC_MSG_RESULT(no)
404                 AC_MSG_CHECKING([whether lookup_bdev() wants 1 arg])
405                 ZFS_LINUX_TEST_RESULT_SYMBOL([lookup_bdev_1arg],
406                     [lookup_bdev], [fs/block_dev.c], [
407                         AC_MSG_RESULT(yes)
408                         AC_DEFINE(HAVE_1ARG_LOOKUP_BDEV, 1,
409                             [lookup_bdev() wants 1 arg])
410                 ], [
411                         AC_MSG_RESULT(no)
413                         AC_MSG_CHECKING([whether lookup_bdev() wants mode arg])
414                         ZFS_LINUX_TEST_RESULT_SYMBOL([lookup_bdev_mode],
415                             [lookup_bdev], [fs/block_dev.c], [
416                                 AC_MSG_RESULT(yes)
417                                 AC_DEFINE(HAVE_MODE_LOOKUP_BDEV, 1,
418                                     [lookup_bdev() wants mode arg])
419                         ], [
420                                 ZFS_LINUX_TEST_ERROR([lookup_bdev()])
421                         ])
422                 ])
423         ])
426 dnl #
427 dnl # 2.6.30 API change
428 dnl #
429 dnl # The bdev_physical_block_size() interface was added to provide a way
430 dnl # to determine the smallest write which can be performed without a
431 dnl # read-modify-write operation.
432 dnl #
433 dnl # Unfortunately, this interface isn't entirely reliable because
434 dnl # drives are sometimes known to misreport this value.
435 dnl #
436 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE], [
437         ZFS_LINUX_TEST_SRC([bdev_physical_block_size], [
438                 #include <linux/blkdev.h>
439         ],[
440                 struct block_device *bdev __attribute__ ((unused)) = NULL;
441                 bdev_physical_block_size(bdev);
442         ])
445 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE], [
446         AC_MSG_CHECKING([whether bdev_physical_block_size() is available])
447         ZFS_LINUX_TEST_RESULT([bdev_physical_block_size], [
448                 AC_MSG_RESULT(yes)
449         ],[
450                 ZFS_LINUX_TEST_ERROR([bdev_physical_block_size()])
451         ])
454 dnl #
455 dnl # 2.6.30 API change
456 dnl # Added bdev_logical_block_size().
457 dnl #
458 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE], [
459         ZFS_LINUX_TEST_SRC([bdev_logical_block_size], [
460                 #include <linux/blkdev.h>
461         ],[
462                 struct block_device *bdev __attribute__ ((unused)) = NULL;
463                 bdev_logical_block_size(bdev);
464         ])
467 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE], [
468         AC_MSG_CHECKING([whether bdev_logical_block_size() is available])
469         ZFS_LINUX_TEST_RESULT([bdev_logical_block_size], [
470                 AC_MSG_RESULT(yes)
471         ],[
472                 ZFS_LINUX_TEST_ERROR([bdev_logical_block_size()])
473         ])
476 dnl #
477 dnl # 5.11 API change
478 dnl # Added bdev_whole() helper.
479 dnl #
480 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_WHOLE], [
481         ZFS_LINUX_TEST_SRC([bdev_whole], [
482                 #include <linux/blkdev.h>
483         ],[
484                 struct block_device *bdev = NULL;
485                 bdev = bdev_whole(bdev);
486         ])
489 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE], [
490         AC_MSG_CHECKING([whether bdev_whole() is available])
491         ZFS_LINUX_TEST_RESULT([bdev_whole], [
492                 AC_MSG_RESULT(yes)
493                 AC_DEFINE(HAVE_BDEV_WHOLE, 1, [bdev_whole() is available])
494         ],[
495                 AC_MSG_RESULT(no)
496         ])
499 dnl #
500 dnl # 5.20 API change,
501 dnl # Removed bdevname(), snprintf(.., %pg) should be used.
502 dnl #
503 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEVNAME], [
504         ZFS_LINUX_TEST_SRC([bdevname], [
505                 #include <linux/fs.h>
506                 #include <linux/blkdev.h>
507         ], [
508                 struct block_device *bdev __attribute__ ((unused)) = NULL;
509                 char path[BDEVNAME_SIZE];
511                 (void) bdevname(bdev, path);
512         ])
515 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEVNAME], [
516         AC_MSG_CHECKING([whether bdevname() exists])
517         ZFS_LINUX_TEST_RESULT([bdevname], [
518                 AC_DEFINE(HAVE_BDEVNAME, 1, [bdevname() is available])
519                 AC_MSG_RESULT(yes)
520         ], [
521                 AC_MSG_RESULT(no)
522         ])
525 dnl #
526 dnl # 5.19 API: blkdev_issue_secure_erase()
527 dnl # 4.7  API: __blkdev_issue_discard(..., BLKDEV_DISCARD_SECURE)
528 dnl # 3.10 API: blkdev_issue_discard(..., BLKDEV_DISCARD_SECURE)
529 dnl #
530 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_ISSUE_SECURE_ERASE], [
531         ZFS_LINUX_TEST_SRC([blkdev_issue_secure_erase], [
532                 #include <linux/blkdev.h>
533         ],[
534                 struct block_device *bdev = NULL;
535                 sector_t sector = 0;
536                 sector_t nr_sects = 0;
537                 int error __attribute__ ((unused));
539                 error = blkdev_issue_secure_erase(bdev,
540                     sector, nr_sects, GFP_KERNEL);
541         ])
543         ZFS_LINUX_TEST_SRC([blkdev_issue_discard_async_flags], [
544                 #include <linux/blkdev.h>
545         ],[
546                 struct block_device *bdev = NULL;
547                 sector_t sector = 0;
548                 sector_t nr_sects = 0;
549                 unsigned long flags = 0;
550                 struct bio *biop = NULL;
551                 int error __attribute__ ((unused));
553                 error = __blkdev_issue_discard(bdev,
554                     sector, nr_sects, GFP_KERNEL, flags, &biop);
555         ])
557         ZFS_LINUX_TEST_SRC([blkdev_issue_discard_flags], [
558                 #include <linux/blkdev.h>
559         ],[
560                 struct block_device *bdev = NULL;
561                 sector_t sector = 0;
562                 sector_t nr_sects = 0;
563                 unsigned long flags = 0;
564                 int error __attribute__ ((unused));
566                 error = blkdev_issue_discard(bdev,
567                     sector, nr_sects, GFP_KERNEL, flags);
568         ])
571 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_ISSUE_SECURE_ERASE], [
572         AC_MSG_CHECKING([whether blkdev_issue_secure_erase() is available])
573         ZFS_LINUX_TEST_RESULT([blkdev_issue_secure_erase], [
574                 AC_MSG_RESULT(yes)
575                 AC_DEFINE(HAVE_BLKDEV_ISSUE_SECURE_ERASE, 1,
576                     [blkdev_issue_secure_erase() is available])
577         ],[
578                 AC_MSG_RESULT(no)
580                 AC_MSG_CHECKING([whether __blkdev_issue_discard() is available])
581                 ZFS_LINUX_TEST_RESULT([blkdev_issue_discard_async_flags], [
582                         AC_MSG_RESULT(yes)
583                         AC_DEFINE(HAVE_BLKDEV_ISSUE_DISCARD_ASYNC, 1,
584                             [__blkdev_issue_discard() is available])
585                 ],[
586                         AC_MSG_RESULT(no)
588                         AC_MSG_CHECKING([whether blkdev_issue_discard() is available])
589                         ZFS_LINUX_TEST_RESULT([blkdev_issue_discard_flags], [
590                                 AC_MSG_RESULT(yes)
591                                 AC_DEFINE(HAVE_BLKDEV_ISSUE_DISCARD, 1,
592                                         [blkdev_issue_discard() is available])
593                         ],[
594                                 ZFS_LINUX_TEST_ERROR([blkdev_issue_discard()])
595                         ])
596                 ])
597         ])
600 dnl #
601 dnl # 5.13 API change
602 dnl # blkdev_get_by_path() no longer handles ERESTARTSYS
603 dnl #
604 dnl # Unfortunately we're forced to rely solely on the kernel version
605 dnl # number in order to determine the expected behavior.  This was an
606 dnl # internal change to blkdev_get_by_dev(), see commit a8ed1a0607.
607 dnl #
608 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_ERESTARTSYS], [
609         AC_MSG_CHECKING([whether blkdev_get_by_path() handles ERESTARTSYS])
610         AS_VERSION_COMPARE([$LINUX_VERSION], [5.13.0], [
611                 AC_MSG_RESULT(yes)
612                 AC_DEFINE(HAVE_BLKDEV_GET_ERESTARTSYS, 1,
613                         [blkdev_get_by_path() handles ERESTARTSYS])
614         ],[
615                 AC_MSG_RESULT(no)
616         ],[
617                 AC_MSG_RESULT(no)
618         ])
621 dnl #
622 dnl # 6.5.x API change
623 dnl # BLK_STS_NEXUS replaced with BLK_STS_RESV_CONFLICT
624 dnl #
625 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BLK_STS_RESV_CONFLICT], [
626         ZFS_LINUX_TEST_SRC([blk_sts_resv_conflict], [
627                 #include <linux/blkdev.h>
628         ],[
629                 blk_status_t s __attribute__ ((unused)) = BLK_STS_RESV_CONFLICT;
630         ])
633 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BLK_STS_RESV_CONFLICT], [
634         AC_MSG_CHECKING([whether BLK_STS_RESV_CONFLICT is defined])
635                 ZFS_LINUX_TEST_RESULT([blk_sts_resv_conflict], [
636                         AC_DEFINE(HAVE_BLK_STS_RESV_CONFLICT, 1, [BLK_STS_RESV_CONFLICT is defined])
637                         AC_MSG_RESULT(yes)
638                 ], [
639                         AC_MSG_RESULT(no)
640                 ])
641         ])
644 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV], [
645         ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH
646         ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH_4ARG
647         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_OPEN_BY_PATH
648         ZFS_AC_KERNEL_SRC_BLKDEV_PUT
649         ZFS_AC_KERNEL_SRC_BLKDEV_PUT_HOLDER
650         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_RELEASE
651         ZFS_AC_KERNEL_SRC_BLKDEV_REREAD_PART
652         ZFS_AC_KERNEL_SRC_BLKDEV_INVALIDATE_BDEV
653         ZFS_AC_KERNEL_SRC_BLKDEV_LOOKUP_BDEV
654         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE
655         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE
656         ZFS_AC_KERNEL_SRC_BLKDEV_CHECK_DISK_CHANGE
657         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_CHECK_MEDIA_CHANGE
658         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_WHOLE
659         ZFS_AC_KERNEL_SRC_BLKDEV_BDEVNAME
660         ZFS_AC_KERNEL_SRC_BLKDEV_ISSUE_SECURE_ERASE
661         ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_KOBJ
662         ZFS_AC_KERNEL_SRC_BLKDEV_PART_TO_DEV
663         ZFS_AC_KERNEL_SRC_BLKDEV_DISK_CHECK_MEDIA_CHANGE
664         ZFS_AC_KERNEL_SRC_BLKDEV_BLK_STS_RESV_CONFLICT
665         ZFS_AC_KERNEL_SRC_BLKDEV_BLK_MODE_T
668 AC_DEFUN([ZFS_AC_KERNEL_BLKDEV], [
669         ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH
670         ZFS_AC_KERNEL_BLKDEV_PUT
671         ZFS_AC_KERNEL_BLKDEV_REREAD_PART
672         ZFS_AC_KERNEL_BLKDEV_INVALIDATE_BDEV
673         ZFS_AC_KERNEL_BLKDEV_LOOKUP_BDEV
674         ZFS_AC_KERNEL_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE
675         ZFS_AC_KERNEL_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE
676         ZFS_AC_KERNEL_BLKDEV_CHECK_DISK_CHANGE
677         ZFS_AC_KERNEL_BLKDEV_BDEV_CHECK_MEDIA_CHANGE
678         ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE
679         ZFS_AC_KERNEL_BLKDEV_BDEVNAME
680         ZFS_AC_KERNEL_BLKDEV_GET_ERESTARTSYS
681         ZFS_AC_KERNEL_BLKDEV_ISSUE_SECURE_ERASE
682         ZFS_AC_KERNEL_BLKDEV_BDEV_KOBJ
683         ZFS_AC_KERNEL_BLKDEV_PART_TO_DEV
684         ZFS_AC_KERNEL_BLKDEV_DISK_CHECK_MEDIA_CHANGE
685         ZFS_AC_KERNEL_BLKDEV_BLK_STS_RESV_CONFLICT
686         ZFS_AC_KERNEL_BLKDEV_BLK_MODE_T