Commit f70299f0 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Tested-by: default avatarMark Wunderlich <mark.wunderlich@intel.com>
Link: https://lore.kernel.org/r/20211012111226.760968-6-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 30da1b45
...@@ -65,6 +65,12 @@ static int blk_mq_poll_stats_bkt(const struct request *rq) ...@@ -65,6 +65,12 @@ static int blk_mq_poll_stats_bkt(const struct request *rq)
return bucket; 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 * Check if any of the ctx, dispatch list or elevator
* have pending work in this hardware queue. * have pending work in this hardware queue.
...@@ -4071,7 +4077,7 @@ int blk_poll(struct request_queue *q, blk_qc_t cookie, bool spin) ...@@ -4071,7 +4077,7 @@ int blk_poll(struct request_queue *q, blk_qc_t cookie, bool spin)
if (current->plug) if (current->plug)
blk_flush_plug_list(current->plug, false); 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 * If we sleep, have the caller restart the poll loop to reset
......
...@@ -505,11 +505,6 @@ static inline bool blk_qc_t_valid(blk_qc_t cookie) ...@@ -505,11 +505,6 @@ static inline bool blk_qc_t_valid(blk_qc_t cookie)
return cookie != BLK_QC_T_NONE; return cookie != BLK_QC_T_NONE;
} }
static inline unsigned int blk_qc_t_to_queue_num(blk_qc_t cookie)
{
return (cookie & ~BLK_QC_T_INTERNAL) >> BLK_QC_T_SHIFT;
}
static inline unsigned int blk_qc_t_to_tag(blk_qc_t cookie) static inline unsigned int blk_qc_t_to_tag(blk_qc_t cookie)
{ {
return cookie & ((1u << BLK_QC_T_SHIFT) - 1); return cookie & ((1u << BLK_QC_T_SHIFT) - 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment