]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Linux 5.20 compat: blk_cleanup_disk()
authorBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 4 Aug 2022 00:37:52 +0000 (17:37 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 4 Aug 2022 23:57:49 +0000 (16:57 -0700)
As of the Linux 5.20 kernel blk_cleanup_disk() has been removed,
all callers should use put_disk().

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #13728

config/kernel-make-request-fn.m4
module/os/linux/zfs/zvol_os.c

index 86b202a7a27249af200707f281b2bba721b8c3cc..f17416acca67218655ed3efb9b0b83c820f5328c 100644 (file)
@@ -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 <linux/blkdev.h>
+       ],[
+               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)
                ])
index 18b9fbd0ea554f821684b7be1b9063bc00aee0c5..8904dc5bb98a94150c332f2f7a4ec90d04a18a2b 100644 (file)
@@ -1232,7 +1232,11 @@ zvol_os_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);