From 4063d7b6b4b387e9b21f1f066e153b50ae2cd819 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 3 Aug 2022 17:37:52 -0700 Subject: [PATCH] Linux 5.20 compat: blk_cleanup_disk() As of the Linux 5.20 kernel blk_cleanup_disk() has been removed, all callers should use put_disk(). Reviewed-by: Tony Hutter Signed-off-by: Brian Behlendorf Closes #13728 --- config/kernel-make-request-fn.m4 | 20 ++++++++++++++++++++ module/os/linux/zfs/zvol_os.c | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/config/kernel-make-request-fn.m4 b/config/kernel-make-request-fn.m4 index 86b202a7a2..f17416acca 100644 --- a/config/kernel-make-request-fn.m4 +++ b/config/kernel-make-request-fn.m4 @@ -49,6 +49,13 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_MAKE_REQUEST_FN], [ struct gendisk *disk __attribute__ ((unused)); disk = blk_alloc_disk(NUMA_NO_NODE); ]) + + ZFS_LINUX_TEST_SRC([blk_cleanup_disk], [ + #include + ],[ + struct gendisk *disk __attribute__ ((unused)); + blk_cleanup_disk(disk); + ]) ]) AC_DEFUN([ZFS_AC_KERNEL_MAKE_REQUEST_FN], [ @@ -73,6 +80,19 @@ AC_DEFUN([ZFS_AC_KERNEL_MAKE_REQUEST_FN], [ ZFS_LINUX_TEST_RESULT([blk_alloc_disk], [ AC_MSG_RESULT(yes) AC_DEFINE([HAVE_BLK_ALLOC_DISK], 1, [blk_alloc_disk() exists]) + + dnl # + dnl # 5.20 API change, + dnl # Removed blk_cleanup_disk(), put_disk() should be used. + dnl # + AC_MSG_CHECKING([whether blk_cleanup_disk() exists]) + ZFS_LINUX_TEST_RESULT([blk_cleanup_disk], [ + AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_BLK_CLEANUP_DISK], 1, + [blk_cleanup_disk() exists]) + ], [ + AC_MSG_RESULT(no) + ]) ], [ AC_MSG_RESULT(no) ]) diff --git a/module/os/linux/zfs/zvol_os.c b/module/os/linux/zfs/zvol_os.c index bb92c65ca8..cef047bec6 100644 --- a/module/os/linux/zfs/zvol_os.c +++ b/module/os/linux/zfs/zvol_os.c @@ -954,7 +954,11 @@ zvol_free(zvol_state_t *zv) del_gendisk(zv->zv_zso->zvo_disk); #if defined(HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS) && \ defined(HAVE_BLK_ALLOC_DISK) +#if defined(HAVE_BLK_CLEANUP_DISK) blk_cleanup_disk(zv->zv_zso->zvo_disk); +#else + put_disk(zv->zv_zso->zvo_disk); +#endif #else blk_cleanup_queue(zv->zv_zso->zvo_queue); put_disk(zv->zv_zso->zvo_disk);