Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility update for 5.14 for blk_alloc_disk() #12362

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions config/kernel-blk-alloc-disk.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
dnl #
dnl # 5.14 API change
dnl # blk_alloc_queue deprecated in favor of blk_alloc_disk
dnl #
AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_ALLOC_DISK], [
ZFS_LINUX_TEST_SRC([blk_alloc_disk], [
#include <linux/genhd.h>
], [
struct gendisk *disk = NULL;
disk = blk_alloc_disk(0);
])
])

AC_DEFUN([ZFS_AC_KERNEL_BLK_ALLOC_DISK], [
AC_MSG_CHECKING([whether blk_alloc_disk() is available])
ZFS_LINUX_TEST_RESULT([blk_alloc_disk], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BLK_ALLOC_DISK, 1,
[blk_alloc_disk() is available])
], [
AC_MSG_RESULT(no)
])
])
2 changes: 2 additions & 0 deletions config/kernel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
ZFS_AC_KERNEL_SRC_SIGNAL_STOP
ZFS_AC_KERNEL_SRC_SIGINFO
ZFS_AC_KERNEL_SRC_SET_SPECIAL_STATE
ZFS_AC_KERNEL_SRC_BLK_ALLOC_DISK

AC_MSG_CHECKING([for available kernel interfaces])
ZFS_LINUX_TEST_COMPILE_ALL([kabi])
Expand Down Expand Up @@ -237,6 +238,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
ZFS_AC_KERNEL_SIGNAL_STOP
ZFS_AC_KERNEL_SIGINFO
ZFS_AC_KERNEL_SET_SPECIAL_STATE
ZFS_AC_KERNEL_BLK_ALLOC_DISK
])

dnl #
Expand Down
15 changes: 15 additions & 0 deletions module/os/linux/zfs/zvol_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,10 +794,19 @@ zvol_alloc(dev_t dev, const char *name)
list_link_init(&zv->zv_next);
mutex_init(&zv->zv_state_lock, NULL, MUTEX_DEFAULT, NULL);

#ifdef HAVE_BLK_ALLOC_DISK
zso->zvo_disk = blk_alloc_disk(NUMA_NO_NODE);
if (zso->zvo_disk == NULL)
goto out_kmem;

zso->zvo_queue = zso->zvo_disk->queue;
zso->zvo_disk->minors = ZVOL_MINORS;
#else
#ifdef HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS
zso->zvo_queue = blk_alloc_queue(NUMA_NO_NODE);
#else
zso->zvo_queue = blk_generic_alloc_queue(zvol_request, NUMA_NO_NODE);
#endif
#endif
if (zso->zvo_queue == NULL)
goto out_kmem;
Expand All @@ -810,9 +819,11 @@ zvol_alloc(dev_t dev, const char *name)
/* Disable write merging in favor of the ZIO pipeline. */
blk_queue_flag_set(QUEUE_FLAG_NOMERGES, zso->zvo_queue);

#ifndef HAVE_BLK_ALLOC_DISK
zso->zvo_disk = alloc_disk(ZVOL_MINORS);
if (zso->zvo_disk == NULL)
goto out_queue;
#endif

zso->zvo_queue->queuedata = zv;
zso->zvo_dev = dev;
Expand Down Expand Up @@ -851,7 +862,11 @@ zvol_alloc(dev_t dev, const char *name)
return (zv);

out_queue:
#ifdef HAVE_BLK_ALLOC_DISK
blk_cleanup_disk(zso->zvo_disk);
#else
blk_cleanup_queue(zso->zvo_queue);
#endif
out_kmem:
kmem_free(zso, sizeof (struct zvol_state_os));
kmem_free(zv, sizeof (zvol_state_t));
Expand Down