Skip to content

Commit a49c957

Browse files
robnbehlendorf
authored andcommitted
linux/zvol_os: fix crash with blk-mq on Linux 4.19
03987f7 (#16069) added a workaround to get the blk-mq hardware context for older kernels that don't cache it in the struct request. However, this workaround appears to be incomplete. In 4.19, the rq data context is optional. If its not initialised, then the cached rq->cpu will be -1, and so using it to index into mq_map causes a crash. Given that the upstream 4.19 is now in extended LTS and rarely seen, RHEL8 4.18+ has long carried "modern" blk-mq support, and the cached hardware context has been available since 5.1, I'm not going to huge lengths to get queue selection correct for the very few people that are likely to feel it. To that end, we simply call raw_smp_processor_id() to get a valid CPU id and use that instead. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Paul Dagnelie <[email protected]> Signed-off-by: Rob Norris <[email protected]> Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Closes #17597
1 parent d1d7063 commit a49c957

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

module/os/linux/zfs/zvol_os.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,8 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq,
558558
#ifdef HAVE_BLK_MQ_RQ_HCTX
559559
blk_mq_hw_queue = rq->mq_hctx->queue_num;
560560
#else
561-
blk_mq_hw_queue =
562-
rq->q->queue_hw_ctx[rq->q->mq_map[rq->cpu]]->queue_num;
561+
blk_mq_hw_queue = rq->q->queue_hw_ctx[
562+
rq->q->mq_map[raw_smp_processor_id()]]->queue_num;
563563
#endif
564564
taskq_hash = cityhash3((uintptr_t)zv, offset >> ZVOL_TASKQ_OFFSET_SHIFT,
565565
blk_mq_hw_queue);

0 commit comments

Comments
 (0)