Skip to content

Commit 3c5f354

Browse files
robntonyhutter
authored andcommitted
zvol_os: fix compile with blk-mq on Linux 4.x
99741bd 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 <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes #16069
1 parent 5c0fe09 commit 3c5f354

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

config/kernel-blk-queue.m4

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,28 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_MQ], [
377377
(void) blk_mq_alloc_tag_set(&tag_set);
378378
return BLK_STS_OK;
379379
], [])
380+
ZFS_LINUX_TEST_SRC([blk_mq_rq_hctx], [
381+
#include <linux/blk-mq.h>
382+
#include <linux/blkdev.h>
383+
], [
384+
struct request rq = {0};
385+
struct blk_mq_hw_ctx *hctx = NULL;
386+
rq.mq_hctx = hctx;
387+
], [])
380388
])
381389

382390
AC_DEFUN([ZFS_AC_KERNEL_BLK_MQ], [
383391
AC_MSG_CHECKING([whether block multiqueue with blk_status_t is available])
384392
ZFS_LINUX_TEST_RESULT([blk_mq], [
385393
AC_MSG_RESULT(yes)
386394
AC_DEFINE(HAVE_BLK_MQ, 1, [block multiqueue is available])
395+
AC_MSG_CHECKING([whether block multiqueue hardware context is cached in struct request])
396+
ZFS_LINUX_TEST_RESULT([blk_mq_rq_hctx], [
397+
AC_MSG_RESULT(yes)
398+
AC_DEFINE(HAVE_BLK_MQ_RQ_HCTX, 1, [block multiqueue hardware context is cached in struct request])
399+
], [
400+
AC_MSG_RESULT(no)
401+
])
387402
], [
388403
AC_MSG_RESULT(no)
389404
])

module/os/linux/zfs/zvol_os.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,12 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq,
551551
uint_t taskq_hash;
552552
#ifdef HAVE_BLK_MQ
553553
if (rq)
554+
#ifdef HAVE_BLK_MQ_RQ_HCTX
554555
blk_mq_hw_queue = rq->mq_hctx->queue_num;
556+
#else
557+
blk_mq_hw_queue =
558+
rq->q->queue_hw_ctx[rq->q->mq_map[rq->cpu]]->queue_num;
559+
#endif
555560
#endif
556561
taskq_hash = cityhash4((uintptr_t)zv, offset >> ZVOL_TASKQ_OFFSET_SHIFT,
557562
blk_mq_hw_queue, 0);

0 commit comments

Comments
 (0)