Add helper of blk_mq_get_hw_queue_node for retrieve hw queue's numa node. Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> Cc: Hannes Reinecke <hare@xxxxxxx> Cc: Bart Van Assche <bvanassche@xxxxxxx> Cc: John Garry <john.garry@xxxxxxxxxx> Cc: Christoph Hellwig <hch@xxxxxx> --- block/blk-mq.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index f9da2d803c18..5019d21e7ff8 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2263,6 +2263,18 @@ blk_qc_t blk_mq_submit_bio(struct bio *bio) } EXPORT_SYMBOL_GPL(blk_mq_submit_bio); /* only for request based dm */ +static int blk_mq_get_hw_queue_node(struct blk_mq_tag_set *set, + unsigned int hctx_idx) +{ + int node = blk_mq_hw_queue_to_node(&set->map[HCTX_TYPE_DEFAULT], + hctx_idx); + + if (node == NUMA_NO_NODE) + node = set->numa_node; + + return node; +} + void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags, unsigned int hctx_idx) { @@ -2309,11 +2321,7 @@ struct blk_mq_tags *blk_mq_alloc_rq_map(struct blk_mq_tag_set *set, unsigned int reserved_tags) { struct blk_mq_tags *tags; - int node; - - node = blk_mq_hw_queue_to_node(&set->map[HCTX_TYPE_DEFAULT], hctx_idx); - if (node == NUMA_NO_NODE) - node = set->numa_node; + int node = blk_mq_get_hw_queue_node(set, hctx_idx); tags = blk_mq_init_tags(nr_tags, reserved_tags, node, BLK_MQ_FLAG_TO_ALLOC_POLICY(set->flags)); @@ -2367,11 +2375,7 @@ int blk_mq_alloc_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags, { unsigned int i, j, entries_per_page; size_t rq_size, left; - int node; - - node = blk_mq_hw_queue_to_node(&set->map[HCTX_TYPE_DEFAULT], hctx_idx); - if (node == NUMA_NO_NODE) - node = set->numa_node; + int node = blk_mq_get_hw_queue_node(set, hctx_idx); INIT_LIST_HEAD(&tags->page_list); -- 2.25.2