Skip to content

Commit f616605

Browse files
authored
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 <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #12532
1 parent ab15b1f commit f616605

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

config/kernel-blk-queue.m4

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,44 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_BDI], [
4747
])
4848
])
4949

50+
dnl #
51+
dnl # 5.9: added blk_queue_update_readahead(),
52+
dnl # 5.15: renamed to disk_update_readahead()
53+
dnl #
54+
AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_UPDATE_READAHEAD], [
55+
ZFS_LINUX_TEST_SRC([blk_queue_update_readahead], [
56+
#include <linux/blkdev.h>
57+
],[
58+
struct request_queue q;
59+
blk_queue_update_readahead(&q);
60+
])
61+
62+
ZFS_LINUX_TEST_SRC([disk_update_readahead], [
63+
#include <linux/blkdev.h>
64+
],[
65+
struct gendisk disk;
66+
disk_update_readahead(&disk);
67+
])
68+
])
69+
70+
AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_UPDATE_READAHEAD], [
71+
AC_MSG_CHECKING([whether blk_queue_update_readahead() exists])
72+
ZFS_LINUX_TEST_RESULT([blk_queue_update_readahead], [
73+
AC_MSG_RESULT(yes)
74+
AC_DEFINE(HAVE_BLK_QUEUE_UPDATE_READAHEAD, 1,
75+
[blk_queue_update_readahead() exists])
76+
],[
77+
AC_MSG_CHECKING([whether disk_update_readahead() exists])
78+
ZFS_LINUX_TEST_RESULT([disk_update_readahead], [
79+
AC_MSG_RESULT(yes)
80+
AC_DEFINE(HAVE_DISK_UPDATE_READAHEAD, 1,
81+
[disk_update_readahead() exists])
82+
],[
83+
AC_MSG_RESULT(no)
84+
])
85+
])
86+
])
87+
5088
dnl #
5189
dnl # 2.6.32 API,
5290
dnl # blk_queue_discard()
@@ -280,6 +318,7 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS], [
280318
AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE], [
281319
ZFS_AC_KERNEL_SRC_BLK_QUEUE_PLUG
282320
ZFS_AC_KERNEL_SRC_BLK_QUEUE_BDI
321+
ZFS_AC_KERNEL_SRC_BLK_QUEUE_UPDATE_READAHEAD
283322
ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD
284323
ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE
285324
ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAG_SET
@@ -292,6 +331,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE], [
292331
AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE], [
293332
ZFS_AC_KERNEL_BLK_QUEUE_PLUG
294333
ZFS_AC_KERNEL_BLK_QUEUE_BDI
334+
ZFS_AC_KERNEL_BLK_QUEUE_UPDATE_READAHEAD
295335
ZFS_AC_KERNEL_BLK_QUEUE_DISCARD
296336
ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE
297337
ZFS_AC_KERNEL_BLK_QUEUE_FLAG_SET

include/os/linux/kernel/linux/blkdev_compat.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,14 @@ blk_queue_set_write_cache(struct request_queue *q, bool wc, bool fua)
9292
static inline void
9393
blk_queue_set_read_ahead(struct request_queue *q, unsigned long ra_pages)
9494
{
95+
#if !defined(HAVE_BLK_QUEUE_UPDATE_READAHEAD) && \
96+
!defined(HAVE_DISK_UPDATE_READAHEAD)
9597
#ifdef HAVE_BLK_QUEUE_BDI_DYNAMIC
9698
q->backing_dev_info->ra_pages = ra_pages;
9799
#else
98100
q->backing_dev_info.ra_pages = ra_pages;
99101
#endif
102+
#endif
100103
}
101104

102105
#ifdef HAVE_BIO_BVEC_ITER

0 commit comments

Comments
 (0)