summaryrefslogtreecommitdiff
path: root/block/blk-mq.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-10-12 13:12:15 +0200
committerJens Axboe <axboe@kernel.dk>2021-10-18 06:17:35 -0600
commitf70299f0d58e0e21f7f5f5ab27e601e8d3f0373e (patch)
treee38d169c9bc2db3ec2d8bda952e364efc8413667 /block/blk-mq.c
parent30da1b45b130c70945b033900f45c9d61d6f3b4a (diff)
downloadlwn-f70299f0d58e0e21f7f5f5ab27e601e8d3f0373e.tar.gz
lwn-f70299f0d58e0e21f7f5f5ab27e601e8d3f0373e.zip
blk-mq: factor out a blk_qc_to_hctx helper
Add a helper to get the hctx from a request_queue and cookie, and fold the blk_qc_t_to_queue_num helper into it as no other callers are left. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Tested-by: Mark Wunderlich <mark.wunderlich@intel.com> Link: https://lore.kernel.org/r/20211012111226.760968-6-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-mq.c')
-rw-r--r--block/blk-mq.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 97b911866de1..35b2ab0a373a 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -65,6 +65,12 @@ static int blk_mq_poll_stats_bkt(const struct request *rq)
return bucket;
}
+static inline struct blk_mq_hw_ctx *blk_qc_to_hctx(struct request_queue *q,
+ blk_qc_t qc)
+{
+ return q->queue_hw_ctx[(qc & ~BLK_QC_T_INTERNAL) >> BLK_QC_T_SHIFT];
+}
+
/*
* Check if any of the ctx, dispatch list or elevator
* have pending work in this hardware queue.
@@ -4071,7 +4077,7 @@ int blk_poll(struct request_queue *q, blk_qc_t cookie, bool spin)
if (current->plug)
blk_flush_plug_list(current->plug, false);
- hctx = q->queue_hw_ctx[blk_qc_t_to_queue_num(cookie)];
+ hctx = blk_qc_to_hctx(q, cookie);
/*
* If we sleep, have the caller restart the poll loop to reset