aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRich Ercolani <[email protected]>2022-01-14 05:08:33 -0500
committerTony Hutter <[email protected]>2022-02-04 08:33:52 -0800
commitc31c1146b6d795f305f7e09a3de13bcdd66f2ac4 (patch)
tree729258283564726185e0438ae92361d7bdf33d06
parentb3e08539510a3372fe55369a41547021f3d55c86 (diff)
Linux 5.16 compat: Added add_disk check for return
add_disk went from void to must-check int return. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Coleman Kane <[email protected]> Signed-off-by: Rich Ercolani <[email protected]> Closes #12975
-rw-r--r--config/kernel-add-disk.m427
-rw-r--r--config/kernel.m42
-rw-r--r--module/os/linux/zfs/zvol_os.c4
3 files changed, 33 insertions, 0 deletions
diff --git a/config/kernel-add-disk.m4 b/config/kernel-add-disk.m4
new file mode 100644
index 000000000..3bc40f1e7
--- /dev/null
+++ b/config/kernel-add-disk.m4
@@ -0,0 +1,27 @@
+dnl #
+dnl # 5.16 API change
+dnl # add_disk grew a must-check return code
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_SRC_ADD_DISK], [
+
+ ZFS_LINUX_TEST_SRC([add_disk_ret], [
+ #include <linux/genhd.h>
+ ], [
+ struct gendisk *disk = NULL;
+ int err = add_disk(disk);
+ err = err;
+ ])
+
+])
+
+AC_DEFUN([ZFS_AC_KERNEL_ADD_DISK], [
+ AC_MSG_CHECKING([whether add_disk() returns int])
+ ZFS_LINUX_TEST_RESULT([add_disk_ret],
+ [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_ADD_DISK_RET, 1,
+ [add_disk() returns int])
+ ], [
+ AC_MSG_RESULT(no)
+ ])
+])
diff --git a/config/kernel.m4 b/config/kernel.m4
index bdd3caed2..b3ed966b7 100644
--- a/config/kernel.m4
+++ b/config/kernel.m4
@@ -135,6 +135,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
ZFS_AC_KERNEL_SRC_VFS_SET_PAGE_DIRTY_NOBUFFERS
ZFS_AC_KERNEL_SRC_STANDALONE_LINUX_STDARG
ZFS_AC_KERNEL_SRC_PAGEMAP_FOLIO_WAIT_BIT
+ ZFS_AC_KERNEL_SRC_ADD_DISK
AC_MSG_CHECKING([for available kernel interfaces])
ZFS_LINUX_TEST_COMPILE_ALL([kabi])
@@ -243,6 +244,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
ZFS_AC_KERNEL_VFS_SET_PAGE_DIRTY_NOBUFFERS
ZFS_AC_KERNEL_STANDALONE_LINUX_STDARG
ZFS_AC_KERNEL_PAGEMAP_FOLIO_WAIT_BIT
+ ZFS_AC_KERNEL_ADD_DISK
])
dnl #
diff --git a/module/os/linux/zfs/zvol_os.c b/module/os/linux/zfs/zvol_os.c
index 69479b3f7..7a979eb91 100644
--- a/module/os/linux/zfs/zvol_os.c
+++ b/module/os/linux/zfs/zvol_os.c
@@ -1110,7 +1110,11 @@ out_doi:
rw_enter(&zvol_state_lock, RW_WRITER);
zvol_insert(zv);
rw_exit(&zvol_state_lock);
+#ifdef HAVE_ADD_DISK_RET
+ error = add_disk(zv->zv_zso->zvo_disk);
+#else
add_disk(zv->zv_zso->zvo_disk);
+#endif
} else {
ida_simple_remove(&zvol_ida, idx);
}