summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2020-04-09 09:16:46 -0700
committerTony Hutter <[email protected]>2020-05-12 10:53:32 -0700
commite6142ac0f28891a0ef3de366a45bb857a17ee25a (patch)
tree8f8a7f16e60074116f13e3bbe724966b576a4622
parentea15efd4c9a36f238b8946e74885dabfdc8b18f2 (diff)
Linux 5.7 compat: blk_alloc_queue()
Commit https://github.com/torvalds/linux/commit/3d745ea5 simplified the blk_alloc_queue() interface by updating it to take the request queue as an argument. Add a wrapper function which accepts the new arguments and internally uses the available interfaces. Other minor changes include increasing the Linux-Maximum to 5.6 now that 5.6 has been released. It was not bumped to 5.7 because this release has not yet been finalized and is still subject to change. Added local 'struct zvol_state_os *zso' variable to zvol_alloc. Reviewed-by: George Melikov <[email protected]> Reviewed-by: Tony Hutter <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #10181 Closes #10187
-rw-r--r--META2
-rw-r--r--config/kernel-make-request-fn.m449
-rw-r--r--include/linux/blkdev_compat.h14
-rw-r--r--module/zfs/zvol.c3
4 files changed, 57 insertions, 11 deletions
diff --git a/META b/META
index 4871ede9c..357539128 100644
--- a/META
+++ b/META
@@ -6,5 +6,5 @@ Release: 1
Release-Tags: relext
License: CDDL
Author: OpenZFS on Linux
-Linux-Maximum: 5.4
+Linux-Maximum: 5.6
Linux-Minimum: 2.6.32
diff --git a/config/kernel-make-request-fn.m4 b/config/kernel-make-request-fn.m4
index 86339aa04..d26e12f99 100644
--- a/config/kernel-make-request-fn.m4
+++ b/config/kernel-make-request-fn.m4
@@ -25,20 +25,36 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_MAKE_REQUEST_FN], [
],[
blk_queue_make_request(NULL, &make_request);
])
+
+ ZFS_LINUX_TEST_SRC([blk_alloc_queue_request_fn], [
+ #include <linux/blkdev.h>
+ blk_qc_t make_request(struct request_queue *q,
+ struct bio *bio) { return (BLK_QC_T_NONE); }
+ ],[
+ struct request_queue *q __attribute__ ((unused));
+ q = blk_alloc_queue(make_request, NUMA_NO_NODE);
+ ])
])
AC_DEFUN([ZFS_AC_KERNEL_MAKE_REQUEST_FN], [
dnl #
- dnl # Legacy API
- dnl # make_request_fn returns int.
+ dnl # Linux 5.7 API Change
+ dnl # blk_alloc_queue() expects request function.
dnl #
- AC_MSG_CHECKING([whether make_request_fn() returns int])
- ZFS_LINUX_TEST_RESULT([make_request_fn_int], [
+ AC_MSG_CHECKING([whether blk_alloc_queue() expects request function])
+ ZFS_LINUX_TEST_RESULT([blk_alloc_queue_request_fn], [
+ AC_MSG_RESULT(yes)
+
+ dnl # Checked as part of the blk_alloc_queue_request_fn test
+ AC_MSG_CHECKING([whether make_request_fn() returns blk_qc_t])
AC_MSG_RESULT(yes)
- AC_DEFINE(MAKE_REQUEST_FN_RET, int,
+
+ AC_DEFINE(HAVE_BLK_ALLOC_QUEUE_REQUEST_FN, 1,
+ [blk_alloc_queue() expects request function])
+ AC_DEFINE(MAKE_REQUEST_FN_RET, blk_qc_t,
[make_request_fn() return type])
- AC_DEFINE(HAVE_MAKE_REQUEST_FN_RET_INT, 1,
- [Noting that make_request_fn() returns int])
+ AC_DEFINE(HAVE_MAKE_REQUEST_FN_RET_QC, 1,
+ [Noting that make_request_fn() returns blk_qc_t])
],[
AC_MSG_RESULT(no)
@@ -70,7 +86,24 @@ AC_DEFUN([ZFS_AC_KERNEL_MAKE_REQUEST_FN], [
[Noting that make_request_fn() ]
[returns blk_qc_t])
],[
- ZFS_LINUX_TEST_ERROR([make_request_fn])
+ AC_MSG_RESULT(no)
+
+ dnl #
+ dnl # Legacy API
+ dnl # make_request_fn returns int.
+ dnl #
+ AC_MSG_CHECKING(
+ [whether make_request_fn() returns int])
+ ZFS_LINUX_TEST_RESULT([make_request_fn_int], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(MAKE_REQUEST_FN_RET, int,
+ [make_request_fn() return type])
+ AC_DEFINE(HAVE_MAKE_REQUEST_FN_RET_INT,
+ 1, [Noting that make_request_fn() ]
+ [returns int])
+ ],[
+ ZFS_LINUX_TEST_ERROR([make_request_fn])
+ ])
])
])
])
diff --git a/include/linux/blkdev_compat.h b/include/linux/blkdev_compat.h
index ace461dc9..f3e97b77b 100644
--- a/include/linux/blkdev_compat.h
+++ b/include/linux/blkdev_compat.h
@@ -669,4 +669,18 @@ blk_generic_end_io_acct(struct request_queue *q, int rw,
#endif
}
+static inline struct request_queue *
+blk_generic_alloc_queue(make_request_fn make_request, int node_id)
+{
+#if defined(HAVE_BLK_ALLOC_QUEUE_REQUEST_FN)
+ return (blk_alloc_queue(make_request, node_id));
+#else
+ struct request_queue *q = blk_alloc_queue(GFP_KERNEL);
+ if (q != NULL)
+ blk_queue_make_request(q, make_request);
+
+ return (q);
+#endif
+}
+
#endif /* _ZFS_BLKDEV_H */
diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c
index 2d16c4482..7a55403e2 100644
--- a/module/zfs/zvol.c
+++ b/module/zfs/zvol.c
@@ -1703,11 +1703,10 @@ zvol_alloc(dev_t dev, const char *name)
mutex_init(&zv->zv_state_lock, NULL, MUTEX_DEFAULT, NULL);
- zv->zv_queue = blk_alloc_queue(GFP_ATOMIC);
+ zv->zv_queue = blk_generic_alloc_queue(zvol_request, NUMA_NO_NODE);
if (zv->zv_queue == NULL)
goto out_kmem;
- blk_queue_make_request(zv->zv_queue, zvol_request);
blk_queue_set_write_cache(zv->zv_queue, B_TRUE, B_TRUE);
/* Limit read-ahead to a single page to prevent over-prefetching. */