Skip to content

Commit c26045b

Browse files
committed
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 <hutter2@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #13728
1 parent bebdf52 commit c26045b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

config/kernel-make-request-fn.m4

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_MAKE_REQUEST_FN], [
4949
struct gendisk *disk __attribute__ ((unused));
5050
disk = blk_alloc_disk(NUMA_NO_NODE);
5151
])
52+
53+
ZFS_LINUX_TEST_SRC([blk_cleanup_disk], [
54+
#include <linux/blkdev.h>
55+
],[
56+
struct gendisk *disk __attribute__ ((unused));
57+
blk_cleanup_disk(disk);
58+
])
5259
])
5360

5461
AC_DEFUN([ZFS_AC_KERNEL_MAKE_REQUEST_FN], [
@@ -73,6 +80,19 @@ AC_DEFUN([ZFS_AC_KERNEL_MAKE_REQUEST_FN], [
7380
ZFS_LINUX_TEST_RESULT([blk_alloc_disk], [
7481
AC_MSG_RESULT(yes)
7582
AC_DEFINE([HAVE_BLK_ALLOC_DISK], 1, [blk_alloc_disk() exists])
83+
84+
dnl #
85+
dnl # 5.20 API change,
86+
dnl # Removed blk_cleanup_disk(), put_disk() should be used.
87+
dnl #
88+
AC_MSG_CHECKING([whether blk_cleanup_disk() exists])
89+
ZFS_LINUX_TEST_RESULT([blk_cleanup_disk], [
90+
AC_MSG_RESULT(yes)
91+
AC_DEFINE([HAVE_BLK_CLEANUP_DISK], 1,
92+
[blk_cleanup_disk() exists])
93+
], [
94+
AC_MSG_RESULT(no)
95+
])
7696
], [
7797
AC_MSG_RESULT(no)
7898
])

module/os/linux/zfs/zvol_os.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,11 @@ zvol_os_free(zvol_state_t *zv)
12321232
del_gendisk(zv->zv_zso->zvo_disk);
12331233
#if defined(HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS) && \
12341234
defined(HAVE_BLK_ALLOC_DISK)
1235+
#if defined(HAVE_BLK_CLEANUP_DISK)
12351236
blk_cleanup_disk(zv->zv_zso->zvo_disk);
1237+
#else
1238+
put_disk(zv->zv_zso->zvo_disk);
1239+
#endif
12361240
#else
12371241
blk_cleanup_queue(zv->zv_zso->zvo_queue);
12381242
put_disk(zv->zv_zso->zvo_disk);

0 commit comments

Comments
 (0)