summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Behlendorf <behlendorf1@llnl.gov>2021-09-08 08:03:13 -0700
committerTony Hutter <hutter2@llnl.gov>2021-09-14 15:41:42 -0700
commitad8dc99ed267357600cf2437d6e4f0562f7bf6e7 (patch)
tree16fb82569aead4352714da02ec15878bf39d64c4
parent6ca1f307082c3b650a2437a8c8f1f2a9b480c118 (diff)
Linux 5.15 compat: block device readahead
The 5.15 kernel moved the backing_dev_info structure out of the request queue structure which causes a build failure. Rather than look in the new location for the BDI we instead detect this upstream refactoring by the existance of either the blk_queue_update_readahead() or disk_update_readahead() functions. In either case, there's no longer any reason to manually set the ra_pages value since it will be overridden with a reasonable default (2x the block size) when blk_queue_io_opt() is called. Therefore, we update the compatibility wrapper to do nothing for 5.9 and newer kernels. While it's tempting to do the same for older kernels we want to keep the compatibility code to preserve the existing behavior. Removing it would effectively increase the default readahead to 128k. Reviewed-by: Tony Nguyen <tony.nguyen@delphix.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #12532
-rw-r--r--config/kernel-blk-queue.m440
-rw-r--r--include/os/linux/kernel/linux/blkdev_compat.h3
2 files changed, 43 insertions, 0 deletions
diff --git a/config/kernel-blk-queue.m4 b/config/kernel-blk-queue.m4
index 1dced82ce..ff5d2d370 100644
--- a/config/kernel-blk-queue.m4
+++ b/config/kernel-blk-queue.m4
@@ -48,6 +48,44 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_BDI], [
])
dnl #
+dnl # 5.9: added blk_queue_update_readahead(),
+dnl # 5.15: renamed to disk_update_readahead()
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_UPDATE_READAHEAD], [
+ ZFS_LINUX_TEST_SRC([blk_queue_update_readahead], [
+ #include <linux/blkdev.h>
+ ],[
+ struct request_queue q;
+ blk_queue_update_readahead(&q);
+ ])
+
+ ZFS_LINUX_TEST_SRC([disk_update_readahead], [
+ #include <linux/blkdev.h>
+ ],[
+ struct gendisk disk;
+ disk_update_readahead(&disk);
+ ])
+])
+
+AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_UPDATE_READAHEAD], [
+ AC_MSG_CHECKING([whether blk_queue_update_readahead() exists])
+ ZFS_LINUX_TEST_RESULT([blk_queue_update_readahead], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_BLK_QUEUE_UPDATE_READAHEAD, 1,
+ [blk_queue_update_readahead() exists])
+ ],[
+ AC_MSG_CHECKING([whether disk_update_readahead() exists])
+ ZFS_LINUX_TEST_RESULT([disk_update_readahead], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_DISK_UPDATE_READAHEAD, 1,
+ [disk_update_readahead() exists])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+ ])
+])
+
+dnl #
dnl # 2.6.32 API,
dnl # blk_queue_discard()
dnl #
@@ -280,6 +318,7 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS], [
AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE], [
ZFS_AC_KERNEL_SRC_BLK_QUEUE_PLUG
ZFS_AC_KERNEL_SRC_BLK_QUEUE_BDI
+ ZFS_AC_KERNEL_SRC_BLK_QUEUE_UPDATE_READAHEAD
ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD
ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE
ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_SET
@@ -292,6 +331,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE], [
AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE], [
ZFS_AC_KERNEL_BLK_QUEUE_PLUG
ZFS_AC_KERNEL_BLK_QUEUE_BDI
+ ZFS_AC_KERNEL_BLK_QUEUE_UPDATE_READAHEAD
ZFS_AC_KERNEL_BLK_QUEUE_DISCARD
ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE
ZFS_AC_KERNEL_BLK_QUEUE_FLAG_SET
diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h
index 87d541072..019d5390a 100644
--- a/include/os/linux/kernel/linux/blkdev_compat.h
+++ b/include/os/linux/kernel/linux/blkdev_compat.h
@@ -92,11 +92,14 @@ blk_queue_set_write_cache(struct request_queue *q, bool wc, bool fua)
static inline void
blk_queue_set_read_ahead(struct request_queue *q, unsigned long ra_pages)
{
+#if !defined(HAVE_BLK_QUEUE_UPDATE_READAHEAD) && \
+ !defined(HAVE_DISK_UPDATE_READAHEAD)
#ifdef HAVE_BLK_QUEUE_BDI_DYNAMIC
q->backing_dev_info->ra_pages = ra_pages;
#else
q->backing_dev_info.ra_pages = ra_pages;
#endif
+#endif
}
#ifdef HAVE_BIO_BVEC_ITER