Skip to content

Commit d014da0

Browse files
jonathonfckane
authored andcommitted
linux 5.13 compat: bdevops->revalidate_disk() removed (#12122)
Linux kernel commit 0f00b82e5413571ed225ddbccad6882d7ea60bc7 removes the revalidate_disk() handler from struct block_device_operations. This caused a regression, and this commit eliminates the call to it and the assignment in the block_device_operations static handler assignment code, when configure identifies that the kernel doesn't support that API handler. Reviewed-by: Colin Ian King <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Coleman Kane <[email protected]> Closes #11967 Closes #11977 (cherry picked from commit 48c7b0e) Signed-off-by: Jonathon Fernyhough <[email protected]> Co-authored-by: Coleman Kane <[email protected]>
1 parent 8f93ab5 commit d014da0

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

config/kernel-block-device-operations.m4

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,44 @@ AC_DEFUN([ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID], [
5252
])
5353
])
5454

55+
dnl #
56+
dnl # 5.13 API change
57+
dnl # block_device_operations->revalidate_disk() was removed
58+
dnl #
59+
AC_DEFUN([ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK], [
60+
ZFS_LINUX_TEST_SRC([block_device_operations_revalidate_disk], [
61+
#include <linux/blkdev.h>
62+
63+
int blk_revalidate_disk(struct gendisk *disk) {
64+
return(0);
65+
}
66+
67+
static const struct block_device_operations
68+
bops __attribute__ ((unused)) = {
69+
.revalidate_disk = blk_revalidate_disk,
70+
};
71+
], [], [$NO_UNUSED_BUT_SET_VARIABLE])
72+
])
73+
74+
AC_DEFUN([ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK], [
75+
AC_MSG_CHECKING([whether bops->revalidate_disk() exists])
76+
ZFS_LINUX_TEST_RESULT([block_device_operations_revalidate_disk], [
77+
AC_DEFINE([HAVE_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK], [1],
78+
[Define if revalidate_disk() in block_device_operations])
79+
AC_MSG_RESULT(yes)
80+
],[
81+
AC_MSG_RESULT(no)
82+
])
83+
])
84+
5585
AC_DEFUN([ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS], [
5686
ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_CHECK_EVENTS
5787
ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID
88+
ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK
5889
])
5990

6091
AC_DEFUN([ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS], [
6192
ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_CHECK_EVENTS
6293
ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID
94+
ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK
6395
])

include/os/linux/kernel/linux/blkdev_compat.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,18 +277,22 @@ bio_set_bi_error(struct bio *bio, int error)
277277
static inline int
278278
zfs_check_media_change(struct block_device *bdev)
279279
{
280+
#ifdef HAVE_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK
280281
struct gendisk *gd = bdev->bd_disk;
281282
const struct block_device_operations *bdo = gd->fops;
283+
#endif
282284

283285
if (!bdev_check_media_change(bdev))
284286
return (0);
285287

288+
#ifdef HAVE_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK
286289
/*
287290
* Force revalidation, to mimic the old behavior of
288291
* check_disk_change()
289292
*/
290293
if (bdo->revalidate_disk)
291294
bdo->revalidate_disk(gd);
295+
#endif
292296

293297
return (0);
294298
}

module/os/linux/zfs/zvol_os.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,9 @@ static struct block_device_operations zvol_ops = {
721721
.ioctl = zvol_ioctl,
722722
.compat_ioctl = zvol_compat_ioctl,
723723
.check_events = zvol_check_events,
724+
#ifdef HAVE_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK
724725
.revalidate_disk = zvol_revalidate_disk,
726+
#endif
725727
.getgeo = zvol_getgeo,
726728
.owner = THIS_MODULE,
727729
#ifdef HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS

0 commit comments

Comments
 (0)