Re: [PATCH v2 06/11] blk-mq: Pass driver tags to blk_mq_clear_rq_mapping()

Ming Lei
2021-08-18T04:03:19Z

On Mon, Aug 09, 2021 at 10:29:33PM +0800, John Garry wrote:
> Function blk_mq_clear_rq_mapping() will be used for shared sbitmap tags
> in future, so pass a driver tags pointer instead of the tagset container
> and HW queue index.
>
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
> block/blk-mq.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 42c4b8d1a570..0bb596f4d061 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -2310,10 +2310,9 @@ static size_t order_to_size(unsigned int order)
> }
>
> /* called before freeing request pool in @tags */
> -static void blk_mq_clear_rq_mapping(struct blk_mq_tag_set *set,
> - struct blk_mq_tags *tags, unsigned int hctx_idx)
> +void blk_mq_clear_rq_mapping(struct blk_mq_tags *drv_tags,
> + struct blk_mq_tags *tags)
> {
> - struct blk_mq_tags *drv_tags = set->tags[hctx_idx];
> struct page *page;
> unsigned long flags;
>
> @@ -2322,7 +2321,7 @@ static void blk_mq_clear_rq_mapping(struct blk_mq_tag_set *set,
> unsigned long end = start + order_to_size(page->private);
> int i;
>
> - for (i = 0; i < set->queue_depth; i++) {
> + for (i = 0; i < drv_tags->nr_tags; i++) {
> struct request *rq = drv_tags->rqs[i];
> unsigned long rq_addr = (unsigned long)rq;
>
> @@ -2346,8 +2345,11 @@ static void blk_mq_clear_rq_mapping(struct blk_mq_tag_set *set,
> void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags,
> unsigned int hctx_idx)
> {
> + struct blk_mq_tags *drv_tags;
> struct page *page;
>
> + drv_tags = set->tags[hctx_idx];

Indent.

> +
> if (tags->static_rqs && set->ops->exit_request) {
> int i;
>
> @@ -2361,7 +2363,7 @@ void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags,
> }
> }
>
> - blk_mq_clear_rq_mapping(set, tags, hctx_idx);
> + blk_mq_clear_rq_mapping(drv_tags, tags);

Maybe you can pass set->tags[hctx_idx] directly since there is only one
reference on it.

--
Ming