xref: /freebsd/sys/contrib/openzfs/config/kernel-blkdev.m4 (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1dnl #
2dnl # 2.6.38 API change,
3dnl # Added blkdev_get_by_path()
4dnl #
5AC_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;
14
15		bdev = blkdev_get_by_path(path, mode, holder);
16	])
17])
18
19dnl #
20dnl # 6.5.x API change,
21dnl # blkdev_get_by_path() takes 4 args
22dnl #
23AC_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;
33
34		bdev = blkdev_get_by_path(path, mode, holder, &h);
35	])
36])
37
38dnl #
39dnl # 6.8.x API change
40dnl # bdev_open_by_path() replaces blkdev_get_by_path()
41dnl #
42AC_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;
52
53		bdh = bdev_open_by_path(path, mode, holder, &h);
54	])
55])
56
57AC_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	])
80])
81
82dnl #
83dnl # 6.5.x API change
84dnl # blk_mode_t was added as a type to supercede some places where fmode_t
85dnl # is used
86dnl #
87AC_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	])
94])
95
96AC_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	])
104])
105
106dnl #
107dnl # 2.6.38 API change,
108dnl # Added blkdev_put()
109dnl #
110AC_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;
117
118		blkdev_put(bdev, mode);
119	])
120])
121
122dnl #
123dnl # 6.5.x API change.
124dnl # blkdev_put() takes (void* holder) as arg 2
125dnl #
126AC_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;
133
134		blkdev_put(bdev, holder);
135	])
136])
137
138dnl #
139dnl # 6.8.x API change
140dnl # bdev_release() replaces blkdev_put()
141dnl #
142AC_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	])
150])
151
152AC_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	])
175])
176
177dnl #
178dnl # 4.1 API, exported blkdev_reread_part() symbol, back ported to the
179dnl # 3.10.0 CentOS 7.x enterprise kernels.
180dnl #
181AC_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;
188
189		error = blkdev_reread_part(bdev);
190	])
191])
192
193AC_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	])
202])
203
204dnl #
205dnl # check_disk_change() was removed in 5.10
206dnl #
207AC_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;
214
215		error = check_disk_change(bdev);
216	])
217])
218
219AC_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	])
228])
229
230dnl #
231dnl # 6.5.x API change
232dnl # disk_check_media_change() was added
233dnl #
234AC_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;
241
242		error = disk_check_media_change(bdev->bd_disk);
243	])
244])
245
246AC_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	])
255])
256
257dnl #
258dnl # bdev_kobj() is introduced from 5.12
259dnl #
260AC_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	])
270])
271
272AC_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	])
281])
282
283dnl #
284dnl # part_to_dev() was removed in 5.12
285dnl #
286AC_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	])
295])
296
297AC_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	])
306])
307
308dnl #
309dnl # 5.10 API, check_disk_change() is removed, in favor of
310dnl # bdev_check_media_change(), which doesn't force revalidation
311dnl #
312AC_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;
319
320		error = bdev_check_media_change(bdev);
321	])
322])
323
324AC_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	])
333])
334
335dnl #
336dnl # 2.6.22 API change
337dnl # Single argument invalidate_bdev()
338dnl #
339AC_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	])
347])
348
349AC_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	])
356])
357
358dnl #
359dnl # 5.11 API, lookup_bdev() takes dev_t argument.
360dnl # 2.6.27 API, lookup_bdev() was first exported.
361dnl # 4.4.0-6.21 API, lookup_bdev() on Ubuntu takes mode argument.
362dnl #
363AC_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;
370
371		error = lookup_bdev(path, &dev);
372	])
373
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";
380
381		bdev = lookup_bdev(path);
382	])
383
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";
389
390		bdev = lookup_bdev(path, FMODE_READ);
391	])
392])
393
394AC_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)
403
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)
412
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	])
424])
425
426dnl #
427dnl # 2.6.30 API change
428dnl #
429dnl # The bdev_physical_block_size() interface was added to provide a way
430dnl # to determine the smallest write which can be performed without a
431dnl # read-modify-write operation.
432dnl #
433dnl # Unfortunately, this interface isn't entirely reliable because
434dnl # drives are sometimes known to misreport this value.
435dnl #
436AC_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	])
443])
444
445AC_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	])
452])
453
454dnl #
455dnl # 2.6.30 API change
456dnl # Added bdev_logical_block_size().
457dnl #
458AC_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	])
465])
466
467AC_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	])
474])
475
476dnl #
477dnl # 5.11 API change
478dnl # Added bdev_whole() helper.
479dnl #
480AC_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	])
487])
488
489AC_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	])
497])
498
499dnl #
500dnl # 5.20 API change,
501dnl # Removed bdevname(), snprintf(.., %pg) should be used.
502dnl #
503AC_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];
510
511		(void) bdevname(bdev, path);
512	])
513])
514
515AC_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	])
523])
524
525dnl #
526dnl # 5.19 API: blkdev_issue_secure_erase()
527dnl # 4.7  API: __blkdev_issue_discard(..., BLKDEV_DISCARD_SECURE)
528dnl # 3.10 API: blkdev_issue_discard(..., BLKDEV_DISCARD_SECURE)
529dnl #
530AC_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));
538
539		error = blkdev_issue_secure_erase(bdev,
540		    sector, nr_sects, GFP_KERNEL);
541	])
542
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));
552
553		error = __blkdev_issue_discard(bdev,
554		    sector, nr_sects, GFP_KERNEL, flags, &biop);
555	])
556
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));
565
566		error = blkdev_issue_discard(bdev,
567		    sector, nr_sects, GFP_KERNEL, flags);
568	])
569])
570
571AC_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)
579
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)
587
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	])
598])
599
600dnl #
601dnl # 5.13 API change
602dnl # blkdev_get_by_path() no longer handles ERESTARTSYS
603dnl #
604dnl # Unfortunately we're forced to rely solely on the kernel version
605dnl # number in order to determine the expected behavior.  This was an
606dnl # internal change to blkdev_get_by_dev(), see commit a8ed1a0607.
607dnl #
608AC_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	])
619])
620
621dnl #
622dnl # 6.5.x API change
623dnl # BLK_STS_NEXUS replaced with BLK_STS_RESV_CONFLICT
624dnl #
625AC_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	])
631])
632
633AC_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	])
642])
643
644AC_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
666])
667
668AC_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
687])
688