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 19AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH], [ 20 AC_MSG_CHECKING([whether blkdev_get_by_path() exists]) 21 ZFS_LINUX_TEST_RESULT([blkdev_get_by_path], [ 22 AC_MSG_RESULT(yes) 23 ], [ 24 ZFS_LINUX_TEST_ERROR([blkdev_get_by_path()]) 25 ]) 26]) 27 28dnl # 29dnl # 2.6.38 API change, 30dnl # Added blkdev_put() 31dnl # 32AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_PUT], [ 33 ZFS_LINUX_TEST_SRC([blkdev_put], [ 34 #include <linux/fs.h> 35 #include <linux/blkdev.h> 36 ], [ 37 struct block_device *bdev = NULL; 38 fmode_t mode = 0; 39 40 blkdev_put(bdev, mode); 41 ]) 42]) 43 44AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_PUT], [ 45 AC_MSG_CHECKING([whether blkdev_put() exists]) 46 ZFS_LINUX_TEST_RESULT([blkdev_put], [ 47 AC_MSG_RESULT(yes) 48 ], [ 49 ZFS_LINUX_TEST_ERROR([blkdev_put()]) 50 ]) 51]) 52 53dnl # 54dnl # 4.1 API, exported blkdev_reread_part() symbol, back ported to the 55dnl # 3.10.0 CentOS 7.x enterprise kernels. 56dnl # 57AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_REREAD_PART], [ 58 ZFS_LINUX_TEST_SRC([blkdev_reread_part], [ 59 #include <linux/fs.h> 60 #include <linux/blkdev.h> 61 ], [ 62 struct block_device *bdev = NULL; 63 int error; 64 65 error = blkdev_reread_part(bdev); 66 ]) 67]) 68 69AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_REREAD_PART], [ 70 AC_MSG_CHECKING([whether blkdev_reread_part() exists]) 71 ZFS_LINUX_TEST_RESULT([blkdev_reread_part], [ 72 AC_MSG_RESULT(yes) 73 AC_DEFINE(HAVE_BLKDEV_REREAD_PART, 1, 74 [blkdev_reread_part() exists]) 75 ], [ 76 AC_MSG_RESULT(no) 77 ]) 78]) 79 80dnl # 81dnl # check_disk_change() was removed in 5.10 82dnl # 83AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_CHECK_DISK_CHANGE], [ 84 ZFS_LINUX_TEST_SRC([check_disk_change], [ 85 #include <linux/fs.h> 86 #include <linux/blkdev.h> 87 ], [ 88 struct block_device *bdev = NULL; 89 bool error; 90 91 error = check_disk_change(bdev); 92 ]) 93]) 94 95AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_CHECK_DISK_CHANGE], [ 96 AC_MSG_CHECKING([whether check_disk_change() exists]) 97 ZFS_LINUX_TEST_RESULT([check_disk_change], [ 98 AC_MSG_RESULT(yes) 99 AC_DEFINE(HAVE_CHECK_DISK_CHANGE, 1, 100 [check_disk_change() exists]) 101 ], [ 102 AC_MSG_RESULT(no) 103 ]) 104]) 105 106dnl # 107dnl # bdev_kobj() is introduced from 5.12 108dnl # 109AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_KOBJ], [ 110 ZFS_LINUX_TEST_SRC([bdev_kobj], [ 111 #include <linux/fs.h> 112 #include <linux/blkdev.h> 113 #include <linux/kobject.h> 114 ], [ 115 struct block_device *bdev = NULL; 116 struct kobject *disk_kobj; 117 disk_kobj = bdev_kobj(bdev); 118 ]) 119]) 120 121AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_KOBJ], [ 122 AC_MSG_CHECKING([whether bdev_kobj() exists]) 123 ZFS_LINUX_TEST_RESULT([bdev_kobj], [ 124 AC_MSG_RESULT(yes) 125 AC_DEFINE(HAVE_BDEV_KOBJ, 1, 126 [bdev_kobj() exists]) 127 ], [ 128 AC_MSG_RESULT(no) 129 ]) 130]) 131 132dnl # 133dnl # part_to_dev() was removed in 5.12 134dnl # 135AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_PART_TO_DEV], [ 136 ZFS_LINUX_TEST_SRC([part_to_dev], [ 137 #include <linux/fs.h> 138 #include <linux/blkdev.h> 139 ], [ 140 struct hd_struct *p = NULL; 141 struct device *pdev; 142 pdev = part_to_dev(p); 143 ]) 144]) 145 146AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_PART_TO_DEV], [ 147 AC_MSG_CHECKING([whether part_to_dev() exists]) 148 ZFS_LINUX_TEST_RESULT([part_to_dev], [ 149 AC_MSG_RESULT(yes) 150 AC_DEFINE(HAVE_PART_TO_DEV, 1, 151 [part_to_dev() exists]) 152 ], [ 153 AC_MSG_RESULT(no) 154 ]) 155]) 156 157dnl # 158dnl # 5.10 API, check_disk_change() is removed, in favor of 159dnl # bdev_check_media_change(), which doesn't force revalidation 160dnl # 161AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_CHECK_MEDIA_CHANGE], [ 162 ZFS_LINUX_TEST_SRC([bdev_check_media_change], [ 163 #include <linux/fs.h> 164 #include <linux/blkdev.h> 165 ], [ 166 struct block_device *bdev = NULL; 167 int error; 168 169 error = bdev_check_media_change(bdev); 170 ]) 171]) 172 173AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_CHECK_MEDIA_CHANGE], [ 174 AC_MSG_CHECKING([whether bdev_check_media_change() exists]) 175 ZFS_LINUX_TEST_RESULT([bdev_check_media_change], [ 176 AC_MSG_RESULT(yes) 177 AC_DEFINE(HAVE_BDEV_CHECK_MEDIA_CHANGE, 1, 178 [bdev_check_media_change() exists]) 179 ], [ 180 AC_MSG_RESULT(no) 181 ]) 182]) 183 184dnl # 185dnl # 2.6.22 API change 186dnl # Single argument invalidate_bdev() 187dnl # 188AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_INVALIDATE_BDEV], [ 189 ZFS_LINUX_TEST_SRC([invalidate_bdev], [ 190 #include <linux/buffer_head.h> 191 #include <linux/blkdev.h> 192 ],[ 193 struct block_device *bdev = NULL; 194 invalidate_bdev(bdev); 195 ]) 196]) 197 198AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_INVALIDATE_BDEV], [ 199 AC_MSG_CHECKING([whether invalidate_bdev() exists]) 200 ZFS_LINUX_TEST_RESULT([invalidate_bdev], [ 201 AC_MSG_RESULT(yes) 202 ],[ 203 ZFS_LINUX_TEST_ERROR([invalidate_bdev()]) 204 ]) 205]) 206 207dnl # 208dnl # 5.11 API, lookup_bdev() takes dev_t argument. 209dnl # 2.6.27 API, lookup_bdev() was first exported. 210dnl # 4.4.0-6.21 API, lookup_bdev() on Ubuntu takes mode argument. 211dnl # 212AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_LOOKUP_BDEV], [ 213 ZFS_LINUX_TEST_SRC([lookup_bdev_devt], [ 214 #include <linux/blkdev.h> 215 ], [ 216 int error __attribute__ ((unused)); 217 const char path[] = "/example/path"; 218 dev_t dev; 219 220 error = lookup_bdev(path, &dev); 221 ]) 222 223 ZFS_LINUX_TEST_SRC([lookup_bdev_1arg], [ 224 #include <linux/fs.h> 225 #include <linux/blkdev.h> 226 ], [ 227 struct block_device *bdev __attribute__ ((unused)); 228 const char path[] = "/example/path"; 229 230 bdev = lookup_bdev(path); 231 ]) 232 233 ZFS_LINUX_TEST_SRC([lookup_bdev_mode], [ 234 #include <linux/fs.h> 235 ], [ 236 struct block_device *bdev __attribute__ ((unused)); 237 const char path[] = "/example/path"; 238 239 bdev = lookup_bdev(path, FMODE_READ); 240 ]) 241]) 242 243AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_LOOKUP_BDEV], [ 244 AC_MSG_CHECKING([whether lookup_bdev() wants dev_t arg]) 245 ZFS_LINUX_TEST_RESULT_SYMBOL([lookup_bdev_devt], 246 [lookup_bdev], [fs/block_dev.c], [ 247 AC_MSG_RESULT(yes) 248 AC_DEFINE(HAVE_DEVT_LOOKUP_BDEV, 1, 249 [lookup_bdev() wants dev_t arg]) 250 ], [ 251 AC_MSG_RESULT(no) 252 253 AC_MSG_CHECKING([whether lookup_bdev() wants 1 arg]) 254 ZFS_LINUX_TEST_RESULT_SYMBOL([lookup_bdev_1arg], 255 [lookup_bdev], [fs/block_dev.c], [ 256 AC_MSG_RESULT(yes) 257 AC_DEFINE(HAVE_1ARG_LOOKUP_BDEV, 1, 258 [lookup_bdev() wants 1 arg]) 259 ], [ 260 AC_MSG_RESULT(no) 261 262 AC_MSG_CHECKING([whether lookup_bdev() wants mode arg]) 263 ZFS_LINUX_TEST_RESULT_SYMBOL([lookup_bdev_mode], 264 [lookup_bdev], [fs/block_dev.c], [ 265 AC_MSG_RESULT(yes) 266 AC_DEFINE(HAVE_MODE_LOOKUP_BDEV, 1, 267 [lookup_bdev() wants mode arg]) 268 ], [ 269 ZFS_LINUX_TEST_ERROR([lookup_bdev()]) 270 ]) 271 ]) 272 ]) 273]) 274 275dnl # 276dnl # 2.6.30 API change 277dnl # 278dnl # The bdev_physical_block_size() interface was added to provide a way 279dnl # to determine the smallest write which can be performed without a 280dnl # read-modify-write operation. 281dnl # 282dnl # Unfortunately, this interface isn't entirely reliable because 283dnl # drives are sometimes known to misreport this value. 284dnl # 285AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE], [ 286 ZFS_LINUX_TEST_SRC([bdev_physical_block_size], [ 287 #include <linux/blkdev.h> 288 ],[ 289 struct block_device *bdev __attribute__ ((unused)) = NULL; 290 bdev_physical_block_size(bdev); 291 ]) 292]) 293 294AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE], [ 295 AC_MSG_CHECKING([whether bdev_physical_block_size() is available]) 296 ZFS_LINUX_TEST_RESULT([bdev_physical_block_size], [ 297 AC_MSG_RESULT(yes) 298 ],[ 299 ZFS_LINUX_TEST_ERROR([bdev_physical_block_size()]) 300 ]) 301]) 302 303dnl # 304dnl # 2.6.30 API change 305dnl # Added bdev_logical_block_size(). 306dnl # 307AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE], [ 308 ZFS_LINUX_TEST_SRC([bdev_logical_block_size], [ 309 #include <linux/blkdev.h> 310 ],[ 311 struct block_device *bdev __attribute__ ((unused)) = NULL; 312 bdev_logical_block_size(bdev); 313 ]) 314]) 315 316AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE], [ 317 AC_MSG_CHECKING([whether bdev_logical_block_size() is available]) 318 ZFS_LINUX_TEST_RESULT([bdev_logical_block_size], [ 319 AC_MSG_RESULT(yes) 320 ],[ 321 ZFS_LINUX_TEST_ERROR([bdev_logical_block_size()]) 322 ]) 323]) 324 325dnl # 326dnl # 5.11 API change 327dnl # Added bdev_whole() helper. 328dnl # 329AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_WHOLE], [ 330 ZFS_LINUX_TEST_SRC([bdev_whole], [ 331 #include <linux/blkdev.h> 332 ],[ 333 struct block_device *bdev = NULL; 334 bdev = bdev_whole(bdev); 335 ]) 336]) 337 338AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE], [ 339 AC_MSG_CHECKING([whether bdev_whole() is available]) 340 ZFS_LINUX_TEST_RESULT([bdev_whole], [ 341 AC_MSG_RESULT(yes) 342 AC_DEFINE(HAVE_BDEV_WHOLE, 1, [bdev_whole() is available]) 343 ],[ 344 AC_MSG_RESULT(no) 345 ]) 346]) 347 348dnl # 349dnl # 5.20 API change, 350dnl # Removed bdevname(), snprintf(.., %pg) should be used. 351dnl # 352AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEVNAME], [ 353 ZFS_LINUX_TEST_SRC([bdevname], [ 354 #include <linux/fs.h> 355 #include <linux/blkdev.h> 356 ], [ 357 struct block_device *bdev __attribute__ ((unused)) = NULL; 358 char path[BDEVNAME_SIZE]; 359 360 (void) bdevname(bdev, path); 361 ]) 362]) 363 364AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEVNAME], [ 365 AC_MSG_CHECKING([whether bdevname() exists]) 366 ZFS_LINUX_TEST_RESULT([bdevname], [ 367 AC_DEFINE(HAVE_BDEVNAME, 1, [bdevname() is available]) 368 AC_MSG_RESULT(yes) 369 ], [ 370 AC_MSG_RESULT(no) 371 ]) 372]) 373 374dnl # 375dnl # 5.19 API: blkdev_issue_secure_erase() 376dnl # 3.10 API: blkdev_issue_discard(..., BLKDEV_DISCARD_SECURE) 377dnl # 378AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_ISSUE_SECURE_ERASE], [ 379 ZFS_LINUX_TEST_SRC([blkdev_issue_secure_erase], [ 380 #include <linux/blkdev.h> 381 ],[ 382 struct block_device *bdev = NULL; 383 sector_t sector = 0; 384 sector_t nr_sects = 0; 385 int error __attribute__ ((unused)); 386 387 error = blkdev_issue_secure_erase(bdev, 388 sector, nr_sects, GFP_KERNEL); 389 ]) 390 391 ZFS_LINUX_TEST_SRC([blkdev_issue_discard_flags], [ 392 #include <linux/blkdev.h> 393 ],[ 394 struct block_device *bdev = NULL; 395 sector_t sector = 0; 396 sector_t nr_sects = 0; 397 unsigned long flags = 0; 398 int error __attribute__ ((unused)); 399 400 error = blkdev_issue_discard(bdev, 401 sector, nr_sects, GFP_KERNEL, flags); 402 ]) 403]) 404 405AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_ISSUE_SECURE_ERASE], [ 406 AC_MSG_CHECKING([whether blkdev_issue_secure_erase() is available]) 407 ZFS_LINUX_TEST_RESULT([blkdev_issue_secure_erase], [ 408 AC_MSG_RESULT(yes) 409 AC_DEFINE(HAVE_BLKDEV_ISSUE_SECURE_ERASE, 1, 410 [blkdev_issue_secure_erase() is available]) 411 ],[ 412 AC_MSG_RESULT(no) 413 414 AC_MSG_CHECKING([whether blkdev_issue_discard() is available]) 415 ZFS_LINUX_TEST_RESULT([blkdev_issue_discard_flags], [ 416 AC_MSG_RESULT(yes) 417 AC_DEFINE(HAVE_BLKDEV_ISSUE_DISCARD, 1, 418 [blkdev_issue_discard() is available]) 419 ],[ 420 ZFS_LINUX_TEST_ERROR([blkdev_issue_discard()]) 421 ]) 422 ]) 423]) 424 425dnl # 426dnl # 5.13 API change 427dnl # blkdev_get_by_path() no longer handles ERESTARTSYS 428dnl # 429dnl # Unfortunately we're forced to rely solely on the kernel version 430dnl # number in order to determine the expected behavior. This was an 431dnl # internal change to blkdev_get_by_dev(), see commit a8ed1a0607. 432dnl # 433AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_ERESTARTSYS], [ 434 AC_MSG_CHECKING([whether blkdev_get_by_path() handles ERESTARTSYS]) 435 AS_VERSION_COMPARE([$LINUX_VERSION], [5.13.0], [ 436 AC_MSG_RESULT(yes) 437 AC_DEFINE(HAVE_BLKDEV_GET_ERESTARTSYS, 1, 438 [blkdev_get_by_path() handles ERESTARTSYS]) 439 ],[ 440 AC_MSG_RESULT(no) 441 ],[ 442 AC_MSG_RESULT(no) 443 ]) 444]) 445 446AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV], [ 447 ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH 448 ZFS_AC_KERNEL_SRC_BLKDEV_PUT 449 ZFS_AC_KERNEL_SRC_BLKDEV_REREAD_PART 450 ZFS_AC_KERNEL_SRC_BLKDEV_INVALIDATE_BDEV 451 ZFS_AC_KERNEL_SRC_BLKDEV_LOOKUP_BDEV 452 ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE 453 ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE 454 ZFS_AC_KERNEL_SRC_BLKDEV_CHECK_DISK_CHANGE 455 ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_CHECK_MEDIA_CHANGE 456 ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_WHOLE 457 ZFS_AC_KERNEL_SRC_BLKDEV_BDEVNAME 458 ZFS_AC_KERNEL_SRC_BLKDEV_ISSUE_SECURE_ERASE 459 ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_KOBJ 460 ZFS_AC_KERNEL_SRC_BLKDEV_PART_TO_DEV 461]) 462 463AC_DEFUN([ZFS_AC_KERNEL_BLKDEV], [ 464 ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH 465 ZFS_AC_KERNEL_BLKDEV_PUT 466 ZFS_AC_KERNEL_BLKDEV_REREAD_PART 467 ZFS_AC_KERNEL_BLKDEV_INVALIDATE_BDEV 468 ZFS_AC_KERNEL_BLKDEV_LOOKUP_BDEV 469 ZFS_AC_KERNEL_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE 470 ZFS_AC_KERNEL_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE 471 ZFS_AC_KERNEL_BLKDEV_CHECK_DISK_CHANGE 472 ZFS_AC_KERNEL_BLKDEV_BDEV_CHECK_MEDIA_CHANGE 473 ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE 474 ZFS_AC_KERNEL_BLKDEV_BDEVNAME 475 ZFS_AC_KERNEL_BLKDEV_GET_ERESTARTSYS 476 ZFS_AC_KERNEL_BLKDEV_ISSUE_SECURE_ERASE 477 ZFS_AC_KERNEL_BLKDEV_BDEV_KOBJ 478 ZFS_AC_KERNEL_BLKDEV_PART_TO_DEV 479]) 480