Skip to content

Commit

Permalink
blk-mq: factor out a blk_qc_to_hctx helper
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Oct 18, 2021
1 parent 30da1b4 commit f70299f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 7 additions & 1 deletion block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions include/linux/blk_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,6 @@ static inline bool blk_qc_t_valid(blk_qc_t cookie)
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)
{
return cookie & ((1u << BLK_QC_T_SHIFT) - 1);
Expand Down

0 comments on commit f70299f

Please sign in to comment.