]> git.proxmox.com Git - mirror_zfs.git/commitdiff
zvol_os: fix compile with blk-mq on Linux 4.x
authorRob N <rob.norris@klarasystems.com>
Mon, 8 Apr 2024 18:38:49 +0000 (04:38 +1000)
committerGitHub <noreply@github.com>
Mon, 8 Apr 2024 18:38:49 +0000 (11:38 -0700)
99741bde5 accesses a cached blk-mq hardware context through the mq_hctx
field of struct request. However, this field did not exist until 5.0.
Before that, the private function blk_mq_map_queue() was used to dig it
out of broader queue context. This commit detects this situation, and
handles it with a poor-man's simulation of that function.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Ameer Hamza <ahamza@ixsystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16069

config/kernel-blk-queue.m4
module/os/linux/zfs/zvol_os.c

index bb5903b313ebbad372a699e084493447eb596c5a..15dbe1c7dff094af48152a41f8ba259f3b271c05 100644 (file)
@@ -377,6 +377,14 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_MQ], [
                (void) blk_mq_alloc_tag_set(&tag_set);
                return BLK_STS_OK;
        ], [])
+       ZFS_LINUX_TEST_SRC([blk_mq_rq_hctx], [
+               #include <linux/blk-mq.h>
+               #include <linux/blkdev.h>
+       ], [
+               struct request rq = {0};
+               struct blk_mq_hw_ctx *hctx = NULL;
+               rq.mq_hctx = hctx;
+       ], [])
 ])
 
 AC_DEFUN([ZFS_AC_KERNEL_BLK_MQ], [
@@ -384,6 +392,13 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_MQ], [
        ZFS_LINUX_TEST_RESULT([blk_mq], [
                AC_MSG_RESULT(yes)
                AC_DEFINE(HAVE_BLK_MQ, 1, [block multiqueue is available])
+               AC_MSG_CHECKING([whether block multiqueue hardware context is cached in struct request])
+               ZFS_LINUX_TEST_RESULT([blk_mq_rq_hctx], [
+                       AC_MSG_RESULT(yes)
+                       AC_DEFINE(HAVE_BLK_MQ_RQ_HCTX, 1, [block multiqueue hardware context is cached in struct request])
+               ], [
+                       AC_MSG_RESULT(no)
+               ])
        ], [
                AC_MSG_RESULT(no)
        ])
index e2a6ba3a7f32e2b5329c1f044ab2e3b54220f581..4b960daf89eec0383101a21ddebbe7842841300a 100644 (file)
@@ -551,7 +551,12 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq,
        uint_t taskq_hash;
 #ifdef HAVE_BLK_MQ
        if (rq)
+#ifdef HAVE_BLK_MQ_RQ_HCTX
                blk_mq_hw_queue = rq->mq_hctx->queue_num;
+#else
+               blk_mq_hw_queue =
+                   rq->q->queue_hw_ctx[rq->q->mq_map[rq->cpu]]->queue_num;
+#endif
 #endif
        taskq_hash = cityhash4((uintptr_t)zv, offset >> ZVOL_TASKQ_OFFSET_SHIFT,
            blk_mq_hw_queue, 0);