From a30fed54f4b1b00d18c7ff48f181da1007e405e6 Mon Sep 17 00:00:00 2001 From: Coleman Kane Date: Sun, 18 Oct 2020 13:06:18 -0400 Subject: [PATCH] Linux 5.10 compat: revalidate_disk_size() added A new function was added named revalidate_disk_size() and the old revalidate_disk() appears to have been deprecated. As the only ZFS code that calls this function is zvol_update_volsize, swapping the old function call out for the new one should be all that is required. Reviewed-by: Brian Behlendorf Signed-off-by: Coleman Kane Closes #11085 --- config/kernel-revalidate-disk-size.m4 | 24 ++++++++++++++++++++++++ config/kernel.m4 | 2 ++ module/os/linux/zfs/zvol_os.c | 4 ++++ 3 files changed, 30 insertions(+) create mode 100644 config/kernel-revalidate-disk-size.m4 diff --git a/config/kernel-revalidate-disk-size.m4 b/config/kernel-revalidate-disk-size.m4 new file mode 100644 index 000000000..de1146c10 --- /dev/null +++ b/config/kernel-revalidate-disk-size.m4 @@ -0,0 +1,24 @@ +dnl # +dnl # 5.10 API change +dnl # revalidate_disk() was replaced by revalidate_disk_size() +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_REVALIDATE_DISK_SIZE], [ + ZFS_LINUX_TEST_SRC([revalidate_disk_size], [ + #include + ], [ + struct gendisk *disk = NULL; + (void) revalidate_disk_size(disk, false); + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_REVALIDATE_DISK_SIZE], [ + AC_MSG_CHECKING([whether revalidate_disk_size() is available]) + ZFS_LINUX_TEST_RESULT_SYMBOL([revalidate_disk_size], + [revalidate_disk_size], [block/genhd.c], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_REVALIDATE_DISK_SIZE, 1, + [revalidate_disk_size() is available]) + ], [ + AC_MSG_RESULT(no) + ]) +]) diff --git a/config/kernel.m4 b/config/kernel.m4 index bbfbeb39b..3e01daa5e 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -62,6 +62,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_BLKDEV ZFS_AC_KERNEL_SRC_BLK_QUEUE ZFS_AC_KERNEL_SRC_GET_DISK_AND_MODULE + ZFS_AC_KERNEL_SRC_REVALIDATE_DISK_SIZE ZFS_AC_KERNEL_SRC_GET_DISK_RO ZFS_AC_KERNEL_SRC_GENERIC_READLINK_GLOBAL ZFS_AC_KERNEL_SRC_DISCARD_GRANULARITY @@ -158,6 +159,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_BLKDEV ZFS_AC_KERNEL_BLK_QUEUE ZFS_AC_KERNEL_GET_DISK_AND_MODULE + ZFS_AC_KERNEL_REVALIDATE_DISK_SIZE ZFS_AC_KERNEL_GET_DISK_RO ZFS_AC_KERNEL_GENERIC_READLINK_GLOBAL ZFS_AC_KERNEL_DISCARD_GRANULARITY diff --git a/module/os/linux/zfs/zvol_os.c b/module/os/linux/zfs/zvol_os.c index a29842ecd..6dfbdf708 100644 --- a/module/os/linux/zfs/zvol_os.c +++ b/module/os/linux/zfs/zvol_os.c @@ -657,7 +657,11 @@ static int zvol_update_volsize(zvol_state_t *zv, uint64_t volsize) { +#ifdef HAVE_REVALIDATE_DISK_SIZE + revalidate_disk_size(zv->zv_zso->zvo_disk, false); +#else revalidate_disk(zv->zv_zso->zvo_disk); +#endif return (0); }