Re: [RFC V4 4/6] blk-iocost: make iocost pluggable

From: Christoph Hellwig
Date: Thu Feb 17 2022 - 03:52:50 EST


On Thu, Feb 17, 2022 at 11:13:47AM +0800, Wang Jianchao (Kuaishou) wrote:
> Make blk-iocost pluggable. Then we can close or open it through
> /sys/block/xxx/queue/qos.
>
> Signed-off-by: Wang Jianchao (Kuaishou) <jianchao.wan9@xxxxxxxxx>
> ---
> block/blk-iocost.c | 52 ++++++++++++++++++++++++++----------------
> block/blk-mq-debugfs.c | 2 --
> block/blk-rq-qos.h | 1 -
> 3 files changed, 32 insertions(+), 23 deletions(-)
>
> diff --git a/block/blk-iocost.c b/block/blk-iocost.c
> index 769b64394298..5a3a45985b49 100644
> --- a/block/blk-iocost.c
> +++ b/block/blk-iocost.c
> @@ -660,9 +660,10 @@ static struct ioc *rqos_to_ioc(struct rq_qos *rqos)
> return container_of(rqos, struct ioc, rqos);
> }
>
> +static struct rq_qos_ops ioc_rqos_ops;
> static struct ioc *q_to_ioc(struct request_queue *q)
> {
> - return rqos_to_ioc(rq_qos_id(q, RQ_QOS_COST));
> + return rqos_to_ioc(rq_qos_by_id(q, ioc_rqos_ops.id));
> }

This has a single caller, so just open code it.

> +static int blk_iocost_init(struct request_queue *q);
> +
> static struct rq_qos_ops ioc_rqos_ops = {
> + .name = "blk-iocost",
> + .flags = RQOS_FLAG_CGRP_POL,
> .throttle = ioc_rqos_throttle,
> .merge = ioc_rqos_merge,
> .done_bio = ioc_rqos_done_bio,
> .done = ioc_rqos_done,
> .queue_depth_changed = ioc_rqos_queue_depth_changed,
> .exit = ioc_rqos_exit,
> + .init = blk_iocost_init,
> };

Again, move rq_qos_ops below the init function to avoid the forward
declaration.