Skip to content

Commit 980aca4

Browse files
committed
Linux 6.9 compat: blk_alloc_disk takes 2 args
Now, it takes queue limits, this is a trivial implementation with no queue limits, implementing proper queue limits is left as an exercise to the reader. Signed-off-by: Ryan Lahfa <[email protected]>
1 parent 08f57a3 commit 980aca4

File tree

2 files changed

+40
-14
lines changed

2 files changed

+40
-14
lines changed

config/kernel-make-request-fn.m4

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_MAKE_REQUEST_FN], [
5050
disk = blk_alloc_disk(NUMA_NO_NODE);
5151
])
5252
53+
ZFS_LINUX_TEST_SRC([blk_alloc_disk_2args], [
54+
#include <linux/blkdev.h>
55+
],[
56+
struct gendisk *disk __attribute__ ((unused));
57+
disk = blk_alloc_disk(NULL, NUMA_NO_NODE);
58+
])
59+
5360
ZFS_LINUX_TEST_SRC([blk_cleanup_disk], [
5461
#include <linux/blkdev.h>
5562
],[
@@ -71,30 +78,45 @@ AC_DEFUN([ZFS_AC_KERNEL_MAKE_REQUEST_FN], [
7178
AC_DEFINE(HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS, 1,
7279
[submit_bio is member of struct block_device_operations])
7380
81+
dnl
82+
dnl # Linux 6.9 API change
83+
dnl # blk_alloc_disk() takes 2 arguments:
84+
dnl # a queue limit and NUMA node ID.
7485
dnl #
75-
dnl # Linux 5.14 API Change:
76-
dnl # blk_alloc_queue() + alloc_disk() combo replaced by
77-
dnl # a single call to blk_alloc_disk().
78-
dnl #
79-
AC_MSG_CHECKING([whether blk_alloc_disk() exists])
80-
ZFS_LINUX_TEST_RESULT([blk_alloc_disk], [
86+
AC_MSG_CHECKING([whether blk_alloc_disk() takes 2 args])
87+
ZFS_LINUX_TEST_RESULT([blk_alloc_disk_2args], [
8188
AC_MSG_RESULT(yes)
8289
AC_DEFINE([HAVE_BLK_ALLOC_DISK], 1, [blk_alloc_disk() exists])
90+
AC_DEFINE([HAVE_BLK_ALLOC_DISK_2ARGS], 1, [blk_alloc_disk() takes 2 args])
91+
dnl # put_disk() should be used in 6.9.
92+
], [
93+
AC_MSG_RESULT(no)
8394
8495
dnl #
85-
dnl # 5.20 API change,
86-
dnl # Removed blk_cleanup_disk(), put_disk() should be used.
96+
dnl # Linux 5.14 API Change:
97+
dnl # blk_alloc_queue() + alloc_disk() combo replaced by
98+
dnl # a single call to blk_alloc_disk().
8799
dnl #
88-
AC_MSG_CHECKING([whether blk_cleanup_disk() exists])
89-
ZFS_LINUX_TEST_RESULT([blk_cleanup_disk], [
100+
AC_MSG_CHECKING([whether blk_alloc_disk() exists])
101+
ZFS_LINUX_TEST_RESULT([blk_alloc_disk], [
90102
AC_MSG_RESULT(yes)
91-
AC_DEFINE([HAVE_BLK_CLEANUP_DISK], 1,
92-
[blk_cleanup_disk() exists])
103+
AC_DEFINE([HAVE_BLK_ALLOC_DISK], 1, [blk_alloc_disk() exists])
104+
105+
dnl #
106+
dnl # 5.20 API change,
107+
dnl # Removed blk_cleanup_disk(), put_disk() should be used.
108+
dnl #
109+
AC_MSG_CHECKING([whether blk_cleanup_disk() exists])
110+
ZFS_LINUX_TEST_RESULT([blk_cleanup_disk], [
111+
AC_MSG_RESULT(yes)
112+
AC_DEFINE([HAVE_BLK_CLEANUP_DISK], 1,
113+
[blk_cleanup_disk() exists])
114+
], [
115+
AC_MSG_RESULT(no)
116+
])
93117
], [
94118
AC_MSG_RESULT(no)
95119
])
96-
], [
97-
AC_MSG_RESULT(no)
98120
])
99121
],[
100122
AC_MSG_RESULT(no)

module/os/linux/zfs/zvol_os.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,11 @@ zvol_alloc(dev_t dev, const char *name)
874874

875875
#ifdef HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS
876876
#ifdef HAVE_BLK_ALLOC_DISK
877+
#ifdef HAVE_BLK_ALLOC_DISK_2ARGS
878+
zso->zvo_disk = blk_alloc_disk(NULL, NUMA_NO_NODE);
879+
#else
877880
zso->zvo_disk = blk_alloc_disk(NUMA_NO_NODE);
881+
#endif
878882
if (zso->zvo_disk == NULL)
879883
goto out_kmem;
880884

0 commit comments

Comments
 (0)