Verify parent_dev before calling udev_device_get_sysattr_value
[zfs.git] / config / kernel-blk-queue.m4
blobcd2b143e89a0892af2e7a1cc40154cfcf1210d44
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 # 6.11: bdi no longer available through request_queue, so get it from
29 dnl #       the gendisk attached to the queue
30 dnl #
31 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_BDI], [
32         ZFS_LINUX_TEST_SRC([blk_queue_bdi], [
33                 #include <linux/blkdev.h>
34         ],[
35                 struct request_queue q;
36                 struct backing_dev_info bdi;
37                 q.backing_dev_info = &bdi;
38         ])
41 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_BDI], [
42         AC_MSG_CHECKING([whether blk_queue bdi is dynamic])
43         ZFS_LINUX_TEST_RESULT([blk_queue_bdi], [
44                 AC_MSG_RESULT(yes)
45                 AC_DEFINE(HAVE_BLK_QUEUE_BDI_DYNAMIC, 1,
46                     [blk queue backing_dev_info is dynamic])
47         ],[
48                 AC_MSG_RESULT(no)
49         ])
52 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISK_BDI], [
53         ZFS_LINUX_TEST_SRC([blk_queue_disk_bdi], [
54                 #include <linux/blkdev.h>
55                 #include <linux/backing-dev.h>
56         ], [
57                 struct request_queue q;
58                 struct gendisk disk;
59                 struct backing_dev_info bdi __attribute__ ((unused));
60                 q.disk = &disk;
61                 q.disk->bdi = &bdi;
62         ])
65 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_DISK_BDI], [
66         AC_MSG_CHECKING([whether backing_dev_info is available through queue gendisk])
67         ZFS_LINUX_TEST_RESULT([blk_queue_disk_bdi], [
68                 AC_MSG_RESULT(yes)
69                 AC_DEFINE(HAVE_BLK_QUEUE_DISK_BDI, 1,
70                     [backing_dev_info is available through queue gendisk])
71         ],[
72                 AC_MSG_RESULT(no)
73         ])
76 dnl #
77 dnl # 5.9: added blk_queue_update_readahead(),
78 dnl # 5.15: renamed to disk_update_readahead()
79 dnl #
80 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_UPDATE_READAHEAD], [
81         ZFS_LINUX_TEST_SRC([blk_queue_update_readahead], [
82                 #include <linux/blkdev.h>
83         ],[
84                 struct request_queue q;
85                 blk_queue_update_readahead(&q);
86         ])
88         ZFS_LINUX_TEST_SRC([disk_update_readahead], [
89                 #include <linux/blkdev.h>
90         ],[
91                 struct gendisk disk;
92                 disk_update_readahead(&disk);
93         ])
96 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_UPDATE_READAHEAD], [
97         AC_MSG_CHECKING([whether blk_queue_update_readahead() exists])
98         ZFS_LINUX_TEST_RESULT([blk_queue_update_readahead], [
99                 AC_MSG_RESULT(yes)
100                 AC_DEFINE(HAVE_BLK_QUEUE_UPDATE_READAHEAD, 1,
101                     [blk_queue_update_readahead() exists])
102         ],[
103                 AC_MSG_RESULT(no)
105                 AC_MSG_CHECKING([whether disk_update_readahead() exists])
106                 ZFS_LINUX_TEST_RESULT([disk_update_readahead], [
107                         AC_MSG_RESULT(yes)
108                         AC_DEFINE(HAVE_DISK_UPDATE_READAHEAD, 1,
109                             [disk_update_readahead() exists])
110                 ],[
111                         AC_MSG_RESULT(no)
112                 ])
113         ])
116 dnl #
117 dnl # 5.19: bdev_max_discard_sectors() available
118 dnl # 2.6.32: blk_queue_discard() available
119 dnl #
120 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD], [
121         ZFS_LINUX_TEST_SRC([bdev_max_discard_sectors], [
122                 #include <linux/blkdev.h>
123         ],[
124                 struct block_device *bdev __attribute__ ((unused)) = NULL;
125                 unsigned int error __attribute__ ((unused));
127                 error = bdev_max_discard_sectors(bdev);
128         ])
130         ZFS_LINUX_TEST_SRC([blk_queue_discard], [
131                 #include <linux/blkdev.h>
132         ],[
133                 struct request_queue r;
134                 struct request_queue *q = &r;
135                 int value __attribute__ ((unused));
136                 memset(q, 0, sizeof(r));
137                 value = blk_queue_discard(q);
138         ],[-Wframe-larger-than=8192])
141 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_DISCARD], [
142         AC_MSG_CHECKING([whether bdev_max_discard_sectors() is available])
143         ZFS_LINUX_TEST_RESULT([bdev_max_discard_sectors], [
144                 AC_MSG_RESULT(yes)
145                 AC_DEFINE(HAVE_BDEV_MAX_DISCARD_SECTORS, 1,
146                     [bdev_max_discard_sectors() is available])
147         ],[
148                 AC_MSG_RESULT(no)
150                 AC_MSG_CHECKING([whether blk_queue_discard() is available])
151                 ZFS_LINUX_TEST_RESULT([blk_queue_discard], [
152                         AC_MSG_RESULT(yes)
153                         AC_DEFINE(HAVE_BLK_QUEUE_DISCARD, 1,
154                             [blk_queue_discard() is available])
155                 ],[
156                         ZFS_LINUX_TEST_ERROR([blk_queue_discard])
157                 ])
158         ])
161 dnl #
162 dnl # 5.19: bdev_max_secure_erase_sectors() available
163 dnl # 4.8: blk_queue_secure_erase() available
164 dnl #
165 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE], [
166         ZFS_LINUX_TEST_SRC([bdev_max_secure_erase_sectors], [
167                 #include <linux/blkdev.h>
168         ],[
169                 struct block_device *bdev __attribute__ ((unused)) = NULL;
170                 unsigned int error __attribute__ ((unused));
172                 error = bdev_max_secure_erase_sectors(bdev);
173         ])
175         ZFS_LINUX_TEST_SRC([blk_queue_secure_erase], [
176                 #include <linux/blkdev.h>
177         ],[
178                 struct request_queue r;
179                 struct request_queue *q = &r;
180                 int value __attribute__ ((unused));
181                 memset(q, 0, sizeof(r));
182                 value = blk_queue_secure_erase(q);
183         ],[-Wframe-larger-than=8192])
186 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE], [
187         AC_MSG_CHECKING([whether bdev_max_secure_erase_sectors() is available])
188         ZFS_LINUX_TEST_RESULT([bdev_max_secure_erase_sectors], [
189                 AC_MSG_RESULT(yes)
190                 AC_DEFINE(HAVE_BDEV_MAX_SECURE_ERASE_SECTORS, 1,
191                     [bdev_max_secure_erase_sectors() is available])
192         ],[
193                 AC_MSG_RESULT(no)
195                 AC_MSG_CHECKING([whether blk_queue_secure_erase() is available])
196                 ZFS_LINUX_TEST_RESULT([blk_queue_secure_erase], [
197                         AC_MSG_RESULT(yes)
198                         AC_DEFINE(HAVE_BLK_QUEUE_SECURE_ERASE, 1,
199                             [blk_queue_secure_erase() is available])
200                 ],[
201                         ZFS_LINUX_TEST_ERROR([blk_queue_secure_erase])
202                 ])
203         ])
206 dnl #
207 dnl # 2.6.34 API change
208 dnl # blk_queue_max_hw_sectors() replaces blk_queue_max_sectors().
209 dnl #
210 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_HW_SECTORS], [
211         ZFS_LINUX_TEST_SRC([blk_queue_max_hw_sectors], [
212                 #include <linux/blkdev.h>
213         ], [
214                 struct request_queue *q __attribute__ ((unused)) = NULL;
215                 (void) blk_queue_max_hw_sectors(q, BLK_SAFE_MAX_SECTORS);
216         ], [])
219 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS], [
220         AC_MSG_CHECKING([whether blk_queue_max_hw_sectors() is available])
221         ZFS_LINUX_TEST_RESULT([blk_queue_max_hw_sectors], [
222                 AC_MSG_RESULT(yes)
223         ],[
224                 AC_MSG_RESULT(no)
225         ])
228 dnl #
229 dnl # 2.6.34 API change
230 dnl # blk_queue_max_segments() consolidates blk_queue_max_hw_segments()
231 dnl # and blk_queue_max_phys_segments().
232 dnl #
233 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_SEGMENTS], [
234         ZFS_LINUX_TEST_SRC([blk_queue_max_segments], [
235                 #include <linux/blkdev.h>
236         ], [
237                 struct request_queue *q __attribute__ ((unused)) = NULL;
238                 (void) blk_queue_max_segments(q, BLK_MAX_SEGMENTS);
239         ], [])
242 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS], [
243         AC_MSG_CHECKING([whether blk_queue_max_segments() is available])
244         ZFS_LINUX_TEST_RESULT([blk_queue_max_segments], [
245                 AC_MSG_RESULT(yes)
246         ], [
247                 AC_MSG_RESULT(no)
248         ])
251 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_MQ_RQ_HCTX], [
252         ZFS_LINUX_TEST_SRC([blk_mq_rq_hctx], [
253                 #include <linux/blk-mq.h>
254                 #include <linux/blkdev.h>
255         ], [
256                 struct request rq = {0};
257                 struct blk_mq_hw_ctx *hctx = NULL;
258                 rq.mq_hctx = hctx;
259         ], [])
262 AC_DEFUN([ZFS_AC_KERNEL_BLK_MQ_RQ_HCTX], [
263         AC_MSG_CHECKING([whether block multiqueue hardware context is cached in struct request])
264         ZFS_LINUX_TEST_RESULT([blk_mq_rq_hctx], [
265                 AC_MSG_RESULT(yes)
266                 AC_DEFINE(HAVE_BLK_MQ_RQ_HCTX, 1, [block multiqueue hardware context is cached in struct request])
267         ], [
268                 AC_MSG_RESULT(no)
269         ])
272 AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE], [
273         ZFS_AC_KERNEL_SRC_BLK_QUEUE_PLUG
274         ZFS_AC_KERNEL_SRC_BLK_QUEUE_BDI
275         ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISK_BDI
276         ZFS_AC_KERNEL_SRC_BLK_QUEUE_UPDATE_READAHEAD
277         ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD
278         ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE
279         ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_HW_SECTORS
280         ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_SEGMENTS
281         ZFS_AC_KERNEL_SRC_BLK_MQ_RQ_HCTX
284 AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE], [
285         ZFS_AC_KERNEL_BLK_QUEUE_PLUG
286         ZFS_AC_KERNEL_BLK_QUEUE_BDI
287         ZFS_AC_KERNEL_BLK_QUEUE_DISK_BDI
288         ZFS_AC_KERNEL_BLK_QUEUE_UPDATE_READAHEAD
289         ZFS_AC_KERNEL_BLK_QUEUE_DISCARD
290         ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE
291         ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS
292         ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS
293         ZFS_AC_KERNEL_BLK_MQ_RQ_HCTX